#-h- rev.r 1156 asc 27-apr-81 08:24:51 [002,100] #-h- defns 60 asc 27-apr-81 08:16:18 [002,100] # include general symbol definitions # include ratdef #-h- main 622 asc 27-apr-81 08:16:19 [002,100] # rev - reverse lines DRIVER(rev) character lin(MAXLINE) integer i, fd integer getarg, open call query("usage: rev [file] ...") fd = ERR for (i=1; getarg(i, lin, FILENAMESIZE) != EOF; i=i+1) { if (lin(1) == MINUS & lin(2) == EOS) fd = STDIN else { fd = open(lin, READ) if (fd == ERR) call cant(lin) } call revl(fd) if (fd != STDIN) call close(fd) } if (fd == ERR) #no files given, read STDIN call revl(STDIN) DRETURN end #-h- revl 288 asc 27-apr-81 08:16:20 [002,100] ## revl - reverse lines in file 'fd' subroutine revl(fd) integer fd, i integer getlin character lin(MAXLINE) for (i = getlin(lin, fd); i ^= EOF; i = getlin(lin, fd)) { for (i = i - 1; i > 0; i = i - 1) call putc(lin(i)) call putc(NEWLINE) } return end #-h- rev.rof 439 asc 08-may-81 17:10:20 [002,100] .pl 60 .bp 1 .in 0 .he 'REV (1)'7/11/79'REV (1)' .sp 2 .in +3 .fi .ti -3 NAME .br rev - reverse lines .nf .sp .ti -3 SYNOPSIS .br rev [files] ... .fi .sp .ti -3 DESCRIPTION .br Rev copies the named files to the standard output, reversing the order of the characters in every line. If no files are given, or the filename '-' is specified, rev reads from the standard input. .sp .ti -3 AUTHORS .br David Hanson and friends (U. of Arizona)