%%s 0/0/0 %%d D 1.1 25-Mar-82 12:10:16 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- cnum 266 asc 25-mar-82 08:14:52 v1.1 (sw-tools v1.1) # cnum - Common block for the number tool. common /cnum/ linnum, numdig, zfill, lin(MAXLINE) integer linnum # Current line number. integer numdig # Number of digits in line numbers. integer zfill # Zero-fill flag. character lin # Buffer for line of text. #-h- cpost 183 asc 25-mar-82 08:14:52 v1.1 (sw-tools v1.1) # cpost - Common block for data needed by post routine in number tool. common /cpost/ numcol, tabspc integer numcol # Column to start line number. integer tabspc # Tab spacing. #-h- number.r 3126 asc 25-mar-82 08:14:53 v1.1 (sw-tools v1.1) #-h- main 1429 asc 25-mar-82 08:14:41 v1.1 (sw-tools v1.1) ### number Prepend or postpend n-digit line numbers to input lines. DRIVER(number) character c, argbuf(MAXARG) character clower # function(s) filedes fd filedes open # function(s) integer argno, i integer ctoi, getarg, getlin # function(s) integer increm # Line number increment. integer prepnd # YES = Prepend number to line. NO => postpend. include cnum include cpost linnum = 1 increm = 1 numdig = 7 prepnd = YES zfill = NO numcol = 73 tabspc = 8 call query( "usage: number [-f] [-z] [-i] [-s] [-d] [-] file ...") for( argno = 1 ; getarg( argno, argbuf, MAXARG) != EOF ; argno = argno + 1 ) { if( argbuf(1) == '-' ) { if( argbuf(2) == EOS ) # Bare '-' fd = STDIN else { c = clower(argbuf(2)) i = 3 if( c == 'f' ) { prepnd = NO numdig = 8 } if( c == 'z' ) zfill = YES if( c == 'i' ) increm = ctoi( argbuf, i) if( c == 's' ) linnum = ctoi( argbuf, i) if( c == 'd' ) numdig = ctoi( argbuf, i) call delarg(argno) argno = argno - 1 next } } else { fd = open( argbuf, READ) if( fd == ERR ) call cant(argbuf) } for( ; getlin(lin, fd) != EOF ; linnum = linnum + increm ) { if( prepnd == YES ) call pre # Output line number before line. else call post # Output line number after line. } call close(fd) } DRETURN end #-h- pre 384 asc 25-mar-82 08:14:42 v1.1 (sw-tools v1.1) ### pre Prepend line number to lin. subroutine pre include cnum character num(MAXCHARS) integer junk integer gitocf if( zfill == YES ) { junk = gitocf( linnum, num, MAXCHARS, 10, numdig, '0') call putlin( num, STDOUT) } else call putdec( linnum, numdig) call putc(' ') # Ensure 1 blank after number. call putlin( lin, STDOUT) # Output the line. return end #-h- post 1094 asc 25-mar-82 08:14:42 v1.1 (sw-tools v1.1) ### post Postpend line number to lin. subroutine post include cnum include cpost character num(MAXCHARS) integer length, mod, gitocf # function(s) integer junk character c # Current input character. integer iindex # Index of current input character. integer linlen # Length of current input line. integer oindex # Index of current output character. linlen = length(lin) if( lin(linlen) == '@n' ) # Remove trailing '@n' from line. lin(linlen) = EOS oindex = 1 for( iindex = 1 ; lin(iindex) != EOS ; iindex = iindex + 1 ) { c = lin(iindex) oindex = oindex + 1 if( c != '@t' ) # Output the character normally. call putc(c) else # Expand the tab. { call putc(' ') for( ; mod(oindex, tabspc) != 1 ; oindex = oindex + 1 ) call putc(' ') } } for( ; oindex < numcol ; oindex = oindex + 1 ) call putc(' ') # Output blanks until numcol is reached. if( zfill == YES ) { junk = gitocf( linnum, num, MAXCHARS, 10, numdig, '0') call putlin( num, STDOUT) } else call putdec( linnum, numdig) # Output the line number. call putc('@n') return end #-h- number.fmt 774 asc 25-mar-82 08:14:55 v1.1 (sw-tools v1.1) .so ~bin/manhdr .hd Number (1) 21-Oct-81 number lines .sy number [-f] [-z] [-i] [-s] [-d] [-] file ... .ds Number copies its input to STDOUT, adding line numbers to each line. The options are: .sp .in +4 .ti -2 - read input from STDIN. .sp .ti -2 -f (Fortran) start numbers in column 73. Default is 1. .ti -2 The number of digits is set to 8 ("-d8"). .sp .ti -2 -z zero-fill numbers. Default is blank-fill. .sp .ti -2 -i set line number increment to . .sp .ti -2 -s start numbering with . .sp .ti -2 -d make numbers digits long. default is 7. .in -4 .fl none .di none .au Dave Martin (Hughes Aircraft) .bu Tabs are assumed to be 8 spaces wide starting in column 9. .br The -f option assumes lines are less than 73 columns long. %%E 1