#-h- uniq.r 2084 asc 08-may-80 11:17:50 #-h- main 570 asc 08-may-80 11:17:41 #--------------------------------------------------------------------- # include symbol definitions # include symbols #--------------------------------------------------------------------- ## uniq -- main program #BKY subroutine driver # call initr4 # call uniq # call endr4 # end #BKY #assembly code main program (used to avoid loading fortran I/O) #BKY % #BKY ident main #BKY entry main #BKY vfd 42/0lmain,18/main #BKY ext driver #BKY rj uzero00 #BKY rj driver #BKY end main #BKY% #-h- uniqs 681 asc 08-may-80 11:17:42 ## uniq -strip adjacent duplicate lines # subroutine uniq subroutine main character buf(MAXLINE) integer open, getarg integer i, int, count data count /NO/ for (i=1; getarg(i, buf, MAXLINE) != EOF; i=i+1) { if (buf(1) == QMARK & buf(2) == EOS) call error ('usage: uniq [-c] [file].') else if (buf(1) == MINUS & (buf(2) == LETC | buf(2) == BIGC)) { count = YES next } else if (buf(1) == MINUS & buf(2) == EOS) int = STDIN else { int = open(buf,READ) if (int == ERR) call cant(buf) } call unik (int, count) if (int != STDIN) call close(int) } if (i == 1 | (i == 2 & count == YES)) #read from STDIN call unik (STDIN, count) return end #-h- unik 686 asc 08-may-80 11:17:43 ## unik - locate duplicate lines in file int subroutine unik (int, count) integer equal, getlin integer t, count, k character buf1(MAXLINE), buf2(MAXLINE) t = getlin(buf1, int) while (t != EOF) { k = 1 for (t=getlin(buf2,int); t!= EOF; t=getlin(buf2,int)) { if (equal(buf1, buf2) == NO) break k = k + 1 } if (count == YES) { call putdec(k, 5) call putc(BLANK) } call putlin(buf1, STDOUT) if (t == EOF) break k = 1 for (t=getlin(buf1,int); t!= EOF; t=getlin(buf1,int)) { if (equal(buf1,buf2) == NO) break k = k + 1 } if (count == YES) { call putdec(k, 5) call putc(BLANK) } call putlin(buf2, STDOUT) } return end