      SUBROUTINE MAIN
      LOGICAL*1 BUF(400)
      INTEGER OPEN, GETARG, LENGTH, ALLDIG
      INTEGER TABS(400), INT, I, K, L
      CALL SETTAB(TABS)
      INT = -3
      I=1
23000 IF(.NOT.(GETARG(I, BUF, 400) .NE. -1))GOTO 23002
      IF(.NOT.(BUF(1) .EQ. 63))GOTO 23003
      CALL ERROR (40Husage:  detab [<t1>...] [+<n>] [file...])
23003 CONTINUE
      IF(.NOT.(BUF(1) .EQ. 43 .OR. ALLDIG(BUF) .EQ. 1))GOTO 23005
      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)
23008 CONTINUE
      IF(.NOT.(INT .EQ. -3))GOTO 23009
      CALL CANT(BUF)
23009 CONTINUE
      CALL DETAB (TABS, INT)
      IF(.NOT.(INT .NE. 1))GOTO 23011
      CALL CLOSE(INT)
23011 CONTINUE
23001 I=I+1
      GOTO 23000
23002 CONTINUE
      IF(.NOT.(INT .EQ. -3))GOTO 23013
      CALL DETAB(TABS, 1)
23013 CONTINUE
      RETURN
      END
      SUBROUTINE DETAB (TABS, INT)
      INTEGER INT
      LOGICAL*1 GETCH
      LOGICAL*1 C
      INTEGER TABS(100)
      INTEGER TABPOS
      INTEGER COL
      COL = 1
23015 IF(.NOT.(GETCH(C, INT) .NE. -1))GOTO 23016
      IF(.NOT.(C .EQ. 9))GOTO 23017
23019 CONTINUE
      CALL PUTC(32)
      COL = COL + 1
      IF(.NOT.(TABPOS(COL, TABS) .EQ. 1))GOTO 23022
      GOTO 23021
23022 CONTINUE
23020 GOTO 23019
23021 CONTINUE
      GOTO 23018
23017 CONTINUE
      IF(.NOT.(C .EQ. 10))GOTO 23024
      CALL PUTC(10)
      COL = 1
      GOTO 23025
23024 CONTINUE
      CALL PUTC(C)
      COL = COL + 1
23025 CONTINUE
23018 CONTINUE
      GOTO 23015
23016 CONTINUE
      RETURN
      END
      SUBROUTINE SETTAB(TABS)
      INTEGER ALLDIG
      INTEGER TABS(400), M, P, K, I, J, L
      INTEGER GETARG, CTOI
      LOGICAL*1 N(4)
      P = 0
      I=1
23026 IF(.NOT.(I.LE.400))GOTO 23028
      TABS(I) = 0
23027 I=I+1
      GOTO 23026
23028 CONTINUE
      J=1
23029 IF(.NOT.(GETARG(J,N,4).NE.-1))GOTO 23031
      K=1
      IF(.NOT.(N(1) .EQ. 43))GOTO 23032
      K = K + 1
23032 CONTINUE
      IF(.NOT.(ALLDIG(N(K)) .EQ. 0))GOTO 23034
      GOTO 23030
23034 CONTINUE
      L = CTOI(N,K)
      IF(.NOT.(L.LE.0 .OR. L.GT.400))GOTO 23036
      GOTO 23030
23036 CONTINUE
      IF(.NOT.(N(1).NE.43))GOTO 23038
      P = L
      TABS(P) = 1
      GOTO 23039
23038 CONTINUE
      IF(.NOT.(P.EQ.0))GOTO 23040
      P = L + 1
23040 CONTINUE
      M=P
23042 IF(.NOT.(M.LE.400))GOTO 23044
      TABS(M) = 1
23043 M=M+L
      GOTO 23042
23044 CONTINUE
23039 CONTINUE
23030 J=J+1
      GOTO 23029
23031 CONTINUE
      IF(.NOT.(P.EQ.0))GOTO 23045
      I=9
23047 IF(.NOT.(I.LE.400))GOTO 23049
      TABS(I) = 1
23048 I=I+8
      GOTO 23047
23049 CONTINUE
23045 CONTINUE
      RETURN
      END
      INTEGER FUNCTION TABPOS(COL, TABS)
      INTEGER COL, I, TABS(400)
      IF(.NOT.(COL .GT. 400))GOTO 23050
      TABPOS = 1
      GOTO 23051
23050 CONTINUE
      TABPOS = TABS(COL)
23051 CONTINUE
      RETURN
      END
