      SUBROUTINE MAIN
      LOGICAL*1 BUF(512)
      INTEGER OPEN, GETARG
      INTEGER I, INT, COUNT
      DATA COUNT /0/
      CALL QUERY(28Husage:  uniq [-c] [file] ...)
      I=1
23000 IF (.NOT.(GETARG(I, BUF, 512) .NE. -1))GOTO 23002
      IF (.NOT.(BUF(1) .EQ. 45 .AND. (BUF(2) .EQ. 99 .OR. BUF(2) .EQ. 67
     *)))GOTO 23003
      COUNT = 1
      GOTO 23001
23003 CONTINUE
      IF (.NOT.(BUF(1) .EQ. 45 .AND. BUF(2) .EQ. 0))GOTO 23005
      INT = 1
      GOTO 23006
23005 CONTINUE
      INT = OPEN(BUF,1)
      IF (.NOT.(INT .EQ. -3))GOTO 23007
      CALL CANT(BUF)
23007 CONTINUE
23006 CONTINUE
23004 CONTINUE
      CALL UNIQUE (INT, COUNT)
      IF (.NOT.(INT .NE. 1))GOTO 23009
      CALL CLOSE(INT)
23009 CONTINUE
23001 I=I+1
      GOTO 23000
23002 CONTINUE
      IF (.NOT.(I .EQ. 1 .OR. (I .EQ. 2 .AND. COUNT .EQ. 1)))GOTO 23011
      CALL UNIQUE (1, COUNT)
23011 CONTINUE
      RETURN
      END
      SUBROUTINE UNIQUE (INT, COUNT)
      INTEGER EQUAL, GETLIN
      INTEGER T, COUNT, K
      LOGICAL*1 BUF1(512), BUF2(512)
      T = GETLIN(BUF1, INT)
23013 IF (.NOT.(T .NE. -1))GOTO 23014
      K = 1
      T=GETLIN(BUF2,INT)
23015 IF (.NOT.(T.NE. -1))GOTO 23017
      IF (.NOT.(EQUAL(BUF1, BUF2) .EQ. 0))GOTO 23018
      GOTO 23017
23018 CONTINUE
      K = K + 1
23016 T=GETLIN(BUF2,INT)
      GOTO 23015
23017 CONTINUE
      IF (.NOT.(COUNT .EQ. 1))GOTO 23020
      CALL PUTINT(K, 5,2)
      CALL PUTCH(32,2)
23020 CONTINUE
      CALL PUTLIN(BUF1, 2)
      IF (.NOT.(T .EQ. -1))GOTO 23022
      GOTO 23014
23022 CONTINUE
      K = 1
      T=GETLIN(BUF1,INT)
23024 IF (.NOT.(T.NE. -1))GOTO 23026
      IF (.NOT.(EQUAL(BUF1,BUF2) .EQ. 0))GOTO 23027
      GOTO 23026
23027 CONTINUE
      K = K + 1
23025 T=GETLIN(BUF1,INT)
      GOTO 23024
23026 CONTINUE
      IF (.NOT.(COUNT .EQ. 1))GOTO 23029
      CALL PUTINT(K, 5,2)
      CALL PUTCH(32,2)
23029 CONTINUE
      CALL PUTLIN(BUF2, 2)
      GOTO 23013
23014 CONTINUE
      RETURN
      END
