%%s 153/43/64 %%d D 1.2 19-Jul-82 12:12:50 j 2 1 %%c Generally overhauled os to cause the overprints to be performed in as few %%c additional lines as possible. All tabs are expanded into stops every 8 %%c columns, and carriage returns are interpreted as well as backspaces. %%s 0/0/0 %%d D 1.1 25-Mar-82 12:10:24 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 %%D 2 #-h- os.r 1768 asc 25-mar-82 08:15:24 v1.1 (sw-tools v1.1) #-h- defns 213 asc 25-mar-82 08:15:14 v1.1 (sw-tools v1.1) %%E 2 %%I 2 #-h- os.r 4223 asc 19-jul-82 12:11:09 j (sventek j) #-h- defns 269 asc 19-jul-82 12:02:40 j (sventek j) %%E 2 ## definitions for overstrike tool # put on a file named 'defns' # Used only by overstrike define(NOSKIP,'+') #suppress carriage-return/line feed define(SKIP,' ') define(NEWPAGE,'1') # top of page on ^L %%D 2 #-h- main 612 asc 25-mar-82 08:15:14 v1.1 (sw-tools v1.1) %%E 2 %%I 2 define(NLINES,6) # line plus max of 5 overprint lines #-h- main 620 asc 19-jul-82 12:02:40 j (sventek j) %%E 2 ## os - convert backspaces into multiple lines DRIVER(os) character buf(MAXLINE) integer getarg, open, assign integer i call query("usage: os [file] ...") call filnfo(STDOUT, buf, i) if (assign(buf, STDOUT, PRINT) == ERR) call error("Cannot reset standard output to PRINT carriage control.") for (i=1; ; i=i+1) { if (getarg(i,buf,MAXLINE) == EOF) { if (i != 1) break int = STDIN } else if (buf(1) == '-' & buf(2) == EOS) int = STDIN else { int = open(buf,READ) if (int == ERR) call cant(buf) } %%D 2 call overs (int) %%E 2 %%I 2 call overs (int, STDOUT) %%E 2 if (int != STDIN) call close(int) } DRETURN end %%D 2 #-h- overs 724 asc 25-mar-82 08:15:15 v1.1 (sw-tools v1.1) ## overs - convert backspaces into multiple lines from file -int- subroutine overs(int) character getch character c integer col, newcol, int col = 1 repeat { newcol = col while (getch(c,int) == BACKSPACE) #eat up backspaces newcol = max(newcol-1, 1) if (newcol < col) #start overstrike line { call putc('@n') call putc(NOSKIP) for (col=1; col's into multiple lines from file ifd ## to file ofd subroutine overs(ifd, ofd) filedes ifd, ofd character buf(MAXLINE), outbuf(MAXLINE, NLINES) integer col, i integer getlin while (getlin(buf, ifd) != EOF) { call initbl(outbuf) # initialize matrix if (buf(1) == FF) # formfeed { outbuf(1,1) = '1' # top of page call scopy(buf, 2, buf, 1) # eliminate FF } else outbuf(1,1) = ' ' # just skip to next line call exptab(buf) # expand tabs into blanks col = 0 for (i = 1; buf(i) != '@n'; i = i + 1)# for each character if (buf(i) == '@r') # carriage return col = 0 else if (buf(i) == '@b') # backspace { col = col - 1 col = max(col, 0) # in case of error } else { col = col + 1 call packit(buf(i), outbuf, col) } call dumpbl(outbuf, ofd) } return end #-h- leng 223 asc 19-jul-82 12:02:42 j (sventek j) # function to return length of row i in matrix outbuf integer function leng(outbuf, i) character outbuf(MAXLINE, NLINES) integer i, j for (j = MAXLINE; j > 1; j = j - 1) if (outbuf(j,i) != ' ') break return(j) end #-h- prnt 240 asc 19-jul-82 12:02:43 j (sventek j) # subroutine to print row i of matrix on unit fd subroutine prnt(outbuf, i, n, fd) character outbuf(MAXLINE, NLINES) integer i, n, j filedes fd for (j = 1; j <= n; j = j + 1) call putch(outbuf(j,i), fd) call putch('@n', fd) return end #-h- dumpbl 330 asc 19-jul-82 12:02:43 j (sventek j) # subroutine to dump non-empty lines in matrix subroutine dumpbl(outbuf, fd) character outbuf(MAXLINE, NLINES) integer n, i integer leng filedes fd n = leng(outbuf, 1) call prnt(outbuf, 1, n, fd) for (i = 2; i <= NLINES; i = i + 1) { n = leng(outbuf, i) if (n <= 1) break call prnt(outbuf, i, n, fd) } return end #-h- packit 374 asc 19-jul-82 12:02:44 j (sventek j) # subroutine to pack character into column col in next available row in matrix subroutine packit(c, outbuf, col) character c, outbuf(MAXLINE, NLINES) integer col, i, j j = col + 1 # all columns are offset by one for (i = 1; i <= NLINES; i = i + 1) # find a row which is empty if (outbuf(j,i) == ' ') # found one { outbuf(j,i) = c break } return end #-h- initbl 265 asc 19-jul-82 12:02:45 j (sventek j) # initialize matrix of lines subroutine initbl(outbuf) character outbuf(MAXLINE, NLINES) integer i, j for (i = 1; i <= NLINES; i = i + 1) { outbuf(1,i) = '+' # overprint character for (j = 2; j <= MAXLINE; j = j + 1) outbuf(j,i) = ' ' } return end #-h- exptab 402 asc 19-jul-82 12:04:38 j (sventek j) # subroutine to expand tabs to stops every eight columns subroutine exptab(buf) character buf(MAXLINE), temp(MAXLINE) integer i, j for ([i=1; j=1]; buf(i) != EOS; i = i + 1) if (buf(i) == '@t') { repeat { temp(j) = ' ' j = j + 1 } until (mod(j,8) == 1) } else { temp(j) = buf(i) j = j + 1 } temp(j) = EOS call strcpy(temp, buf) return end %%E 2 #-h- os.fmt 660 asc 25-mar-82 08:15:25 v1.1 (sw-tools v1.1) .so ~bin/manhdr .hd Os (1) 16-Jan-79 convert backspaces into multiple lines for "printers" .sy os [file] ... .ds os (overstrike) looks for backspaces in the files specified and generates a sequence of print lines with carriage control codes to reproduce the effect of the backspaces. If no files are given, or the filename '-' appears, input is taken from the standard input. .fl .sa lpr - queue file to line printer .br ul - process overstrikes for "terminals" .di A message is printed if an input file cannot be opened; further processing is terminated. .au Original from Kernighan & Plauger's 'Software Tools', with modifications by Debbie Scherrer. .bu %%E 1