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