%%s 0/0/0 %%d D 1.1 25-Mar-82 12:16:21 v1.1 1 0 %%c Version 1.1 is the Spring 1982 Distribution of the LBL/Hughes release %%c of the Software Tools Virtual Operating System software and documentation. %%T %%I 1 #-h- kwicsym 179 asc 25-mar-82 09:04:16 v1.1 (sw-tools v1.1) ## definitions for kwic and unrot tools # put on a filed called 'kwicsym' define(FOLD,'$') #character to indicate beginning of folded line define(MAXOUT,80) #width of index #-h- unrot.r 2177 asc 25-mar-82 09:04:18 v1.1 (sw-tools v1.1) #-h- main 612 asc 25-mar-82 09:03:57 v1.1 (sw-tools v1.1) ## unrot - unrotate lines rotated by kwic include kwicsym DRIVER(unrot) character buf(MAXLINE) integer getarg, open, ctoi integer i, int, width, j, n data width /MAXOUT/ call query("usage: unrot [-n] [file] ...") for (i=1; getarg(i,buf,MAXLINE)!=EOF; i=i+1) { if (buf(1) == '-' & buf(2) != EOS) { j = 2 n = ctoi(buf,j) if (n > 0) width = n next } else if (buf(1) == '-') int = STDIN else { int = open(buf, READ) if (int == ERR) call cant(buf) } call nrot (int, width) if (int != STDIN) call close(int) } if (i==1) call nrot (STDIN, width) DRETURN end #-h- nrot 1057 asc 25-mar-82 09:03:59 v1.1 (sw-tools v1.1) ## nrot - unrotate lines from file -int- subroutine nrot(int, width) character inbuf(MAXLINE), outbuf(MAXLINE) integer getlin, index integer int, i, j, width, middle middle = max(width/2, 1) while (getlin(inbuf, int) != EOF) { for (i=1; i1 & inbuf(i-1) == ' ') if (nextj(+1,inbuf,i,j) >= width - 1) j = 1 if (j >= width - 1) j = 1 outbuf(j) = inbuf(i) } if (inbuf(i) == FOLD) #copy second half { j = middle #working backwards for (i=index(inbuf,'@n')-1; i>0; i=i-1) { if (inbuf(i) == FOLD) break j = j -1 if (inbuf(i+1) == ' ') if (nextj(-1,inbuf,i,j) <= 0) j = width - 2 if (j <= 0) j = width - 2 outbuf(j) = inbuf(i) } } for (i=width-2; i > 0; i=i-1) if (outbuf(i) != ' ') #delete trailing blanks break outbuf(i+1) = '@n' #terminate line properly outbuf(i+2) = EOS call putlin(outbuf, STDOUT) } return end #-h- nextj 289 asc 25-mar-82 09:04:01 v1.1 (sw-tools v1.1) ## nextj - see if enough space for another word integer function nextj(incmnt,buf,i,j) character buf(ARB) integer incmnt, i, j, k nextj = j for (k=i; k>0; k = k + incmnt) { if (buf(k) == ' ' | buf(k) == FOLD | buf(k) == '@n') break nextj = nextj + incmnt } return end #-h- unrot.fmt 589 asc 25-mar-82 09:04:20 v1.1 (sw-tools v1.1) .so ~bin/manhdr .hd Unrot (1) 15-Jan-79 unrotate lines rotated by kwic .sy unrot [-n] [file] ... .ds unrot processes the rotated output of 'kwic' to generate a keyword-in-context index. The -n flag may be used to specify the width of the output lines. The default is 80. If no input files are given, or the filename '-' appears, lines will be read from standard input. .fl .sa kwic; sort .di A message is printed if an input file cannot be opened; further processing is terminated. .au Original from Kernighan and Plauger's 'Software Tools', with modifications by Debbie Scherrer. .bu %%E 1