      SUBROUTINE MAIN
      LOGICAL*1 ARG(512), LINBUF(512)
      INTEGER I, J, NFILES, FD
      INTEGER LENGTH, GETARG, OPEN, GETLIN
      COMMON /CSEDIT/ AQ, IQ, BUF(5000), LASTBF, NLINES, LINE1, LINE2, P
     *AT(128), PREVC, NFLAG
      INTEGER AQ
      INTEGER IQ
      LOGICAL*1 BUF
      INTEGER LASTBF
      INTEGER NLINES
      INTEGER LINE1
      INTEGER LINE2
      LOGICAL*1 PAT
      INTEGER PREVC
      INTEGER NFLAG
      LOGICAL*1 USE(64)
      DATA USE(1)/117/,USE(2)/115/,USE(3)/97/,USE(4)/103/,USE(5)/101/,US
     *E(6)/58/,USE(7)/32/,USE(8)/32/,USE(9)/115/,USE(10)/101/,USE(11)/10
     *0/,USE(12)/105/,USE(13)/116/,USE(14)/32/,USE(15)/91/,USE(16)/45/,U
     *SE(17)/110/,USE(18)/93/,USE(19)/32/,USE(20)/91/,USE(21)/91/,USE(22
     *)/45/,USE(23)/101/,USE(24)/32/,USE(25)/115/,USE(26)/99/,USE(27)/11
     *4/,USE(28)/105/,USE(29)/112/,USE(30)/116/,USE(31)/32/,USE(32)/124/
     *,USE(33)/32/,USE(34)/45/,USE(35)/102/,USE(36)/32/,USE(37)/115/,USE
     *(38)/102/,USE(39)/105/,USE(40)/108/,USE(41)/101/,USE(42)/115/,USE(
     *43)/93/,USE(44)/32/,USE(45)/124/,USE(46)/32/,USE(47)/115/,USE(48)/
     *99/,USE(49)/114/,USE(50)/105/,USE(51)/112/,USE(52)/116/,USE(53)/93
     */,USE(54)/32/,USE(55)/91/,USE(56)/102/,USE(57)/105/,USE(58)/108/,U
     *SE(59)/101/,USE(60)/93/,USE(61)/46/,USE(62)/46/,USE(63)/46/,USE(64
     *)/0/
      CALL QUERY(USE)
      PREVC = 1
      BUF(1+1) = 0
      LASTBF = 5+1+6
      NFLAG = 0
      NFILES = 0
      I = 1
      IF (.NOT.(GETARG (I, ARG, 512) .EQ. -1))GOTO 23000
      CALL ERROR(USE)
23000 CONTINUE
      IF (.NOT.(ARG(1) .EQ. 45 .AND. ARG(2) .EQ. 110))GOTO 23002
      NFLAG = 1
      I = I + 1
23002 CONTINUE
23004 IF (.NOT.(GETARG(I, ARG, 512) .NE. -1))GOTO 23006
      IF (.NOT.(ARG(1) .EQ. 45 .AND. ARG(2) .EQ. 102))GOTO 23007
      IF (.NOT.(GETARG(I + 1, ARG, 512) .EQ. -1))GOTO 23009
      CALL ERROR(USE)
23009 CONTINUE
      FD = OPEN(ARG, 1)
      IF (.NOT.(FD .EQ. -3))GOTO 23011
      CALL CANT(ARG)
23011 CONTINUE
23013 IF (.NOT.(GETLIN(ARG, FD) .NE. -1))GOTO 23014
      CALL COMPIL(ARG, FD)
      GOTO 23013
23014 CONTINUE
      CALL CLOSE(FD)
      GOTO 23008
23007 CONTINUE
      IF (.NOT.(ARG(1) .EQ. 45 .AND. ARG(2) .EQ. 101))GOTO 23015
      IF (.NOT.(GETARG(I + 1, ARG, 512) .EQ. -1))GOTO 23017
      CALL ERROR(USE)
23017 CONTINUE
      J = LENGTH(ARG)
      ARG(J+1) = 10
      ARG(J+2) = 0
      CALL COMPIL(ARG, 0)
      GOTO 23016
23015 CONTINUE
      GOTO 23006
23016 CONTINUE
23008 CONTINUE
23005 I = I + 2
      GOTO 23004
23006 CONTINUE
      IF (.NOT.(LASTBF .EQ. 5+1+6))GOTO 23019
      IF (.NOT.(GETARG(I, ARG, 512) .EQ. -1))GOTO 23021
      CALL ERROR(USE)
23021 CONTINUE
      J = LENGTH(ARG)
      ARG(J+1) = 10
      ARG(J+2) = 0
      CALL COMPIL(ARG, 0)
      I = I + 1
23019 CONTINUE
      LINBUF(1) = 0
      LINENO = 0
      CALL DOCMDS(LINBUF, 0)
23023 IF (.NOT.(GETARG(I, ARG, 512) .NE. -1))GOTO 23025
      IF (.NOT.(ARG(1) .EQ. 45 .AND. ARG(2) .EQ. 0))GOTO 23026
      FD = 1
      GOTO 23027
23026 CONTINUE
      FD = OPEN(ARG, 1)
23027 CONTINUE
      IF (.NOT.(FD .EQ. -3))GOTO 23028
      CALL CANT(ARG)
23028 CONTINUE
      CALL SED(LINBUF, LINENO, FD)
      IF (.NOT.(FD .NE. 1))GOTO 23030
      CALL CLOSE(FD)
23030 CONTINUE
      NFILES = NFILES + 1
23024 I = I + 1
      GOTO 23023
23025 CONTINUE
      IF (.NOT.(NFILES .EQ. 0))GOTO 23032
      CALL SED(LINBUF, LINENO, 1)
23032 CONTINUE
      IF (.NOT.(LINBUF(1) .NE. 0))GOTO 23034
      LINENO = LINENO + 1
      I = BUF(1+1)
23036 IF (.NOT.(I .GT. 0))GOTO 23038
      IF (.NOT.(BUF(I+2) .EQ. -30000))GOTO 23039
      BUF(I+2) = -LINENO
23039 CONTINUE
      IF (.NOT.(BUF(I+3) .EQ. -30000))GOTO 23041
      BUF(I+3) = -LINENO
23041 CONTINUE
      IF (.NOT.(BUF(I+4) .EQ. 99))GOTO 23043
      IF (.NOT.(BUF(I+0) .EQ. 2))GOTO 23045
      BUF(I+0) = 1
23045 CONTINUE
      IF (.NOT.(BUF(I+0) .EQ. 3 .AND. (BUF(I+3) .GT. 0 .OR. -BUF(I+3) .G
     *E. LINENO)))GOTO 23047
      BUF(I+3) = -LINENO
23047 CONTINUE
23043 CONTINUE
23037 I = BUF(I+1)
      GOTO 23036
23038 CONTINUE
      CALL DOCMDS(LINBUF, LINENO)
23034 CONTINUE
      RETURN
      END
      INTEGER FUNCTION ADDSTR(S, STR, J, MAXSIZ)
      LOGICAL*1 S(100), STR(100)
      INTEGER J, MAXSIZ
      INTEGER I, ADDSET
      I = 1
23049 IF (.NOT.(S(I) .NE. 0))GOTO 23051
      IF (.NOT.(ADDSET(S(I), STR, J, MAXSIZ) .EQ. 0))GOTO 23052
      ADDSTR = 0
      RETURN
23052 CONTINUE
23050 I = I + 1
      GOTO 23049
23051 CONTINUE
      ADDSTR = 1
      RETURN
      END
      SUBROUTINE CATSUB(LIN, FROM, TO, SUB, NEW, K, MAXNEW)
      INTEGER ADDSET
      INTEGER FROM, I, J, JUNK, K, MAXNEW, TO
      LOGICAL*1 LIN(512), NEW(MAXNEW), SUB(128)
      I = 1
23054 IF (.NOT.(SUB(I) .NE. 0))GOTO 23056
      IF (.NOT.(SUB(I) .EQ. (-3)))GOTO 23057
      J = FROM
23059 IF (.NOT.(J .LT. TO))GOTO 23061
      JUNK = ADDSET(LIN(J), NEW, K, MAXNEW)
23060 J = J + 1
      GOTO 23059
23061 CONTINUE
      GOTO 23058
23057 CONTINUE
      JUNK = ADDSET(SUB(I), NEW, K, MAXNEW)
23058 CONTINUE
23055 I = I + 1
      GOTO 23054
23056 CONTINUE
      RETURN
      END
      INTEGER FUNCTION CKP(LIN, I, PFLAG, STATUS)
      LOGICAL*1 LIN(512)
      INTEGER I, J, PFLAG, STATUS
      LOGICAL*1 CLOWER
      J = I
      IF (.NOT.(CLOWER(LIN(J)) .EQ. 112))GOTO 23062
      J = J + 1
      PFLAG = 1
      GOTO 23063
23062 CONTINUE
      PFLAG = 0
23063 CONTINUE
      IF (.NOT.(LIN(J) .EQ. 10))GOTO 23064
      STATUS = 1
      GOTO 23065
23064 CONTINUE
      STATUS = -3
23065 CONTINUE
      CKP = STATUS
      RETURN
      END
      SUBROUTINE COMPIL(LIN, FD)
      LOGICAL*1 LIN(512)
      INTEGER FD
      LOGICAL*1 FILE(40), SUB(128)
      INTEGER I, GFLAG, PFLAG, STATUS, FDW
      INTEGER ADDSET, ADDSTR, CREATE, GETRHS, GETFN, CKP, OPTPAT, DOTEXT
     *, GETLST, LENGTH
      LOGICAL*1 CLOWER
      COMMON /CSEDIT/ AQ, IQ, BUF(5000), LASTBF, NLINES, LINE1, LINE2, P
     *AT(128), PREVC, NFLAG
      INTEGER AQ
      INTEGER IQ
      LOGICAL*1 BUF
      INTEGER LASTBF
      INTEGER NLINES
      INTEGER LINE1
      INTEGER LINE2
      LOGICAL*1 PAT
      INTEGER PREVC
      INTEGER NFLAG
      STATUS = -3
      I = 1
      IF (.NOT.(GETLST(LIN, I, STATUS) .EQ. -3))GOTO 23066
      CALL PUTLIN(LIN, 3)
      CALL ERROR(17Hbad line numbers.)
23066 CONTINUE
      CALL SKIPBL(LIN, I)
      BUF(PREVC+1) = LASTBF
      PREVC = LASTBF
      STATUS = ADDSET(NLINES, BUF, LASTBF, 5000)
      STATUS = ADDSET(0, BUF, LASTBF, 5000)
      STATUS = ADDSET(LINE1, BUF, LASTBF, 5000)
      STATUS = ADDSET(LINE2, BUF, LASTBF, 5000)
      STATUS = ADDSET(CLOWER(LIN(I)), BUF, LASTBF, 5000)
      IF (.NOT.(CLOWER(LIN(I)) .EQ. 97 .AND. LIN(I+1) .EQ. 10 .AND. FD .
     *NE. 0))GOTO 23068
      STATUS = ADDSET(0, BUF, LASTBF, 5000)
      STATUS = DOTEXT(FD)
      GOTO 23069
23068 CONTINUE
      IF (.NOT.(CLOWER(LIN(I)) .EQ. 99 .AND. LIN(I+1) .EQ. 10 .AND. FD .
     *NE. 0))GOTO 23070
      STATUS = ADDSET(0, BUF, LASTBF, 5000)
      STATUS = DOTEXT(FD)
      GOTO 23071
23070 CONTINUE
      IF (.NOT.(CLOWER(LIN(I)) .EQ. 100 .AND. LIN(I+1) .EQ. 10))GOTO 230
     *72
      STATUS = 1
      GOTO 23073
23072 CONTINUE
      IF (.NOT.(CLOWER(LIN(I)) .EQ. 105 .AND. LIN(I+1) .EQ. 10 .AND. FD 
     *.NE. 0))GOTO 23074
      STATUS = ADDSET(0, BUF, LASTBF, 5000)
      STATUS = DOTEXT(FD)
      GOTO 23075
23074 CONTINUE
      IF (.NOT.(CLOWER(LIN(I)) .EQ. 112 .AND. LIN(I+1) .EQ. 10))GOTO 230
     *76
      STATUS = 1
      GOTO 23077
23076 CONTINUE
      IF (.NOT.(CLOWER(LIN(I)) .EQ. 114))GOTO 23078
      STATUS = ADDSET(0, BUF, LASTBF, 5000)
      STATUS = GETFN(LIN, I, FILE)
      IF (.NOT.(STATUS .EQ. 1))GOTO 23080
      STATUS = ADDSTR(FILE, BUF, LASTBF, 5000)
      STATUS = ADDSET(0, BUF, LASTBF, 5000)
23080 CONTINUE
      GOTO 23079
23078 CONTINUE
      IF (.NOT.(CLOWER(LIN(I)) .EQ. 115))GOTO 23082
      I = I + 1
      IF (.NOT.(OPTPAT(LIN, I) .EQ. 1))GOTO 23084
      IF (.NOT.(GETRHS(LIN, I, SUB, GFLAG) .EQ. 1))GOTO 23086
      STATUS = CKP(LIN, I + 1, PFLAG, STATUS)
23086 CONTINUE
23084 CONTINUE
      IF (.NOT.(STATUS .EQ. 1))GOTO 23088
      STATUS = ADDSET(GFLAG, BUF, LASTBF, 5000)
      STATUS = ADDSET(PFLAG, BUF, LASTBF, 5000)
      STATUS = ADDSET(LASTBF + 2, BUF, LASTBF, 5000)
      STATUS = ADDSET(LASTBF + LENGTH(PAT) + 2, BUF, LASTBF, 5000)
      STATUS = ADDSTR(PAT, BUF, LASTBF, 5000)
      STATUS = ADDSET(0, BUF, LASTBF, 5000)
      STATUS = ADDSTR(SUB, BUF, LASTBF, 5000)
      STATUS = ADDSET(0, BUF, LASTBF, 5000)
23088 CONTINUE
      GOTO 23083
23082 CONTINUE
      IF (.NOT.(CLOWER(LIN(I)) .EQ. 119))GOTO 23090
      STATUS = GETFN(LIN, I, FILE)
      IF (.NOT.(STATUS .EQ. 1))GOTO 23092
      FDW = CREATE(FILE, 2)
      IF (.NOT.(FDW .EQ. -3))GOTO 23094
      CALL CANT(FILE)
23094 CONTINUE
23092 CONTINUE
      STATUS = ADDSET(FDW, BUF, LASTBF, 5000)
      GOTO 23091
23090 CONTINUE
      IF (.NOT.(CLOWER(LIN(I)) .EQ. 61 .AND. LIN(I+1) .EQ. 10))GOTO 2309
     *6
      STATUS = 1
      GOTO 23097
23096 CONTINUE
      STATUS = -3
23097 CONTINUE
23091 CONTINUE
23083 CONTINUE
23079 CONTINUE
23077 CONTINUE
23075 CONTINUE
23073 CONTINUE
23071 CONTINUE
23069 CONTINUE
      IF (.NOT.(STATUS .NE. 1))GOTO 23098
      CALL PUTLIN(LIN, 3)
      IF (.NOT.(LASTBF .GT. 5000))GOTO 23100
      CALL ERROR(18Htoo many commands.)
      GOTO 23101
23100 CONTINUE
      CALL ERROR(16Hinvalid command.)
23101 CONTINUE
23098 CONTINUE
      RETURN
      END
      SUBROUTINE DOCMDS(LINBUF, LINENO)
      LOGICAL*1 LINBUF(512)
      INTEGER LINENO
      INTEGER I, N
      INTEGER MATCH
      COMMON /CSEDIT/ AQ, IQ, BUF(5000), LASTBF, NLINES, LINE1, LINE2, P
     *AT(128), PREVC, NFLAG
      INTEGER AQ
      INTEGER IQ
      LOGICAL*1 BUF
      INTEGER LASTBF
      INTEGER NLINES
      INTEGER LINE1
      INTEGER LINE2
      LOGICAL*1 PAT
      INTEGER PREVC
      INTEGER NFLAG
      AQ = 5+1
      BUF(AQ+5) = 0
      IQ = 1
      BUF(IQ+5) = 0
      I = BUF(1+1)
23102 IF (.NOT.(I .NE. 0))GOTO 23104
      NLINES = BUF(I+0)
      LINE1 = BUF(I+2)
      LINE2 = BUF(I+3)
      IF (.NOT.(NLINES .EQ. 0))GOTO 23105
      CALL DOCOM(I, LINBUF, LINENO)
      GOTO 23106
23105 CONTINUE
      IF (.NOT.(NLINES .EQ. 1))GOTO 23107
      IF (.NOT.(-LINE1 .EQ. LINENO))GOTO 23109
      CALL DOCOM(I, LINBUF, LINENO)
      GOTO 23110
23109 CONTINUE
      IF (.NOT.(LINE1 .GT. 0))GOTO 23111
      IF (.NOT.(MATCH(LINBUF, BUF(LINE1)) .GT. 0))GOTO 23113
      CALL DOCOM(I, LINBUF, LINENO)
23113 CONTINUE
23111 CONTINUE
23110 CONTINUE
      GOTO 23108
23107 CONTINUE
      IF (.NOT.(NLINES .EQ. 2))GOTO 23115
      IF (.NOT.(-LINE1 .EQ. LINENO))GOTO 23117
      BUF(I+0) = 3
      CALL DOCOM(I, LINBUF, LINENO)
      GOTO 23118
23117 CONTINUE
      IF (.NOT.(LINE1 .GT. 0))GOTO 23119
      IF (.NOT.(MATCH(LINBUF, BUF(LINE1)) .GT. 0))GOTO 23121
      BUF(I+0) = 3
      CALL DOCOM(I, LINBUF, LINENO)
23121 CONTINUE
23119 CONTINUE
23118 CONTINUE
      GOTO 23116
23115 CONTINUE
      IF (.NOT.(NLINES .EQ. 3))GOTO 23123
      IF (.NOT.(LINE2 .LE. 0))GOTO 23125
      IF (.NOT.(LINENO .GE. -LINE2))GOTO 23127
      BUF(I+0) = 2
23127 CONTINUE
      IF (.NOT.(LINENO .LE. -LINE2))GOTO 23129
      CALL DOCOM(I, LINBUF, LINENO)
23129 CONTINUE
      GOTO 23126
23125 CONTINUE
      IF (.NOT.(LINE2 .GT. 0))GOTO 23131
      IF (.NOT.(MATCH(LINBUF, BUF(LINE2)) .GT. 0))GOTO 23133
      BUF(I+0) = 2
23133 CONTINUE
      CALL DOCOM(I, LINBUF, LINENO)
23131 CONTINUE
23126 CONTINUE
      GOTO 23124
23123 CONTINUE
      CALL ERROR(24Hin docmds: can't happen.)
23124 CONTINUE
23116 CONTINUE
23108 CONTINUE
23106 CONTINUE
      IF (.NOT.(LINBUF(1) .EQ. 0 .AND. LINENO .GT. 0))GOTO 23135
      GOTO 23104
23135 CONTINUE
23103 I = BUF(I+1)
      GOTO 23102
23104 CONTINUE
      I = BUF(1+5)
23137 IF (.NOT.(I .GT. 0))GOTO 23139
      CALL PUTLIN(BUF(I+6), 2)
23138 I = BUF(I+5)
      GOTO 23137
23139 CONTINUE
      IF (.NOT.(NFLAG .EQ. 0))GOTO 23140
      CALL PUTLIN(LINBUF, 2)
23140 CONTINUE
      I = BUF(5+1+5)
23142 IF (.NOT.(I .GT. 0))GOTO 23144
      IF (.NOT.(BUF(I+4) .EQ. 114))GOTO 23145
      CALL FCOPY(BUF(I+6), 2)
      GOTO 23146
23145 CONTINUE
      CALL PUTLIN(BUF(I+6), 2)
23146 CONTINUE
23143 I = BUF(I+5)
      GOTO 23142
23144 CONTINUE
      RETURN
      END
      SUBROUTINE DOCOM(I, LINBUF, LINENO)
      LOGICAL*1 LINBUF(512)
      INTEGER I, LINENO
      LOGICAL*1 CMD
      INTEGER K1, K2, JUNK
      COMMON /CSEDIT/ AQ, IQ, BUF(5000), LASTBF, NLINES, LINE1, LINE2, P
     *AT(128), PREVC, NFLAG
      INTEGER AQ
      INTEGER IQ
      LOGICAL*1 BUF
      INTEGER LASTBF
      INTEGER NLINES
      INTEGER LINE1
      INTEGER LINE2
      LOGICAL*1 PAT
      INTEGER PREVC
      INTEGER NFLAG
      CMD = BUF(I+4)
      IF (.NOT.(CMD .EQ. 97))GOTO 23147
      BUF(AQ+5) = I
      AQ = I
      BUF(I+5) = 0
      GOTO 23148
23147 CONTINUE
      IF (.NOT.(CMD .EQ. 99))GOTO 23149
      LINBUF(1) = 0
      IF (.NOT.(BUF(I+0) .LE. 2))GOTO 23151
      BUF(AQ+5) = I
      AQ = I
      BUF(I+5) = 0
23151 CONTINUE
      GOTO 23150
23149 CONTINUE
      IF (.NOT.(CMD .EQ. 100))GOTO 23153
      LINBUF(1) = 0
      GOTO 23154
23153 CONTINUE
      IF (.NOT.(CMD .EQ. 105))GOTO 23155
      BUF(IQ+5) = I
      IQ = I
      BUF(I+5) = 0
      GOTO 23156
23155 CONTINUE
      IF (.NOT.(CMD .EQ. 112))GOTO 23157
      CALL PUTLIN(LINBUF, 2)
      GOTO 23158
23157 CONTINUE
      IF (.NOT.(CMD .EQ. 114))GOTO 23159
      BUF(AQ+5) = I
      AQ = I
      BUF(I+5) = 0
      GOTO 23160
23159 CONTINUE
      IF (.NOT.(CMD .EQ. 115))GOTO 23161
      K1 = BUF(I+4+3)
      K2 = BUF(I+4+4)
      CALL SUBST(LINBUF, BUF(K1), BUF(K2), BUF(I+4+1), BUF(I+4+2))
      GOTO 23162
23161 CONTINUE
      IF (.NOT.(CMD .EQ. 119))GOTO 23163
      IF (.NOT.(BUF(I+4+1) .NE. 0))GOTO 23165
      CALL PUTLIN(LINBUF, BUF(I+4+1))
23165 CONTINUE
      GOTO 23164
23163 CONTINUE
      IF (.NOT.(CMD .EQ. 61))GOTO 23167
      CALL PUTINT(LINENO, 1,2)
      CALL PUTCH(10,2)
23167 CONTINUE
23164 CONTINUE
23162 CONTINUE
23160 CONTINUE
23158 CONTINUE
23156 CONTINUE
23154 CONTINUE
23150 CONTINUE
23148 CONTINUE
      RETURN
      END
      INTEGER FUNCTION DOTEXT(FD)
      INTEGER FD
      INTEGER GETLIN, ADDSET, ADDSTR
      LOGICAL*1 LIN(512)
      COMMON /CSEDIT/ AQ, IQ, BUF(5000), LASTBF, NLINES, LINE1, LINE2, P
     *AT(128), PREVC, NFLAG
      INTEGER AQ
      INTEGER IQ
      LOGICAL*1 BUF
      INTEGER LASTBF
      INTEGER NLINES
      INTEGER LINE1
      INTEGER LINE2
      LOGICAL*1 PAT
      INTEGER PREVC
      INTEGER NFLAG
23169 IF (.NOT.(GETLIN(LIN, FD) .NE. -1))GOTO 23170
      IF (.NOT.(LIN(1) .EQ. 46 .AND. LIN(2) .EQ. 10))GOTO 23171
      GOTO 23170
23171 CONTINUE
      JUNK = ADDSTR(LIN, BUF, LASTBF, 5000)
      GOTO 23169
23170 CONTINUE
      DOTEXT = ADDSET(0, BUF, LASTBF, 5000)
      RETURN
      END
      SUBROUTINE FCOPY(NAME, FDO)
      LOGICAL*1 NAME(100)
      INTEGER FDO
      INTEGER FDI
      INTEGER OPEN
      LOGICAL*1 C
      LOGICAL*1 GETCH
      FDI = OPEN(NAME, 1)
      IF (.NOT.(FDI .EQ. -3))GOTO 23173
      CALL CANT(NAME)
23173 CONTINUE
23175 IF (.NOT.(GETCH(C, FDI) .NE. -1))GOTO 23176
      CALL PUTCH(C, FDO)
      GOTO 23175
23176 CONTINUE
      CALL CLOSE(FDI)
      RETURN
      END
      INTEGER FUNCTION GETFN(LIN, I, FILE)
      LOGICAL*1 LIN(512), FILE(512)
      INTEGER I, J, K
      GETFN = -3
      IF (.NOT.(LIN(I + 1) .EQ. 32 .OR. LIN(I + 1) .EQ. 9))GOTO 23177
      J = I + 2
      CALL SKIPBL(LIN, J)
      K = 1
23179 IF (.NOT.(LIN(J) .NE. 10))GOTO 23181
      FILE(K) = LIN(J)
      J = J + 1
23180 K = K + 1
      GOTO 23179
23181 CONTINUE
      FILE(K) = 0
      IF (.NOT.(K .GT. 1))GOTO 23182
      GETFN = 1
23182 CONTINUE
23177 CONTINUE
      RETURN
      END
      INTEGER FUNCTION GETLST(LIN, I, STATUS)
      LOGICAL*1 LIN(512)
      INTEGER I
      INTEGER STATUS
      INTEGER NUM
      INTEGER GETONE
      COMMON /CSEDIT/ AQ, IQ, BUF(5000), LASTBF, NLINES, LINE1, LINE2, P
     *AT(128), PREVC, NFLAG
      INTEGER AQ
      INTEGER IQ
      LOGICAL*1 BUF
      INTEGER LASTBF
      INTEGER NLINES
      INTEGER LINE1
      INTEGER LINE2
      LOGICAL*1 PAT
      INTEGER PREVC
      INTEGER NFLAG
      NLINES = 0
      IF (.NOT.(GETONE(LIN, I, NUM) .EQ. -1))GOTO 23184
      GETLST=(1)
      RETURN
23184 CONTINUE
      LINE1 = NUM
      NLINES = NLINES + 1
      IF (.NOT.(LIN(I) .NE. 44))GOTO 23186
      GETLST=(1)
      RETURN
23186 CONTINUE
      I = I + 1
      IF (.NOT.(GETONE(LIN, I, NUM) .NE. 1))GOTO 23188
      GETLST=(-3)
      RETURN
23188 CONTINUE
      LINE2 = NUM
      NLINES = NLINES + 1
      GETLST=(1)
      RETURN
      END
      INTEGER FUNCTION GETONE(LIN, I, NUM)
      LOGICAL*1 LIN(512)
      INTEGER I, ISTART, NUM
      INTEGER ADDSTR, ADDSET, CTOI, OPTPAT
      COMMON /CSEDIT/ AQ, IQ, BUF(5000), LASTBF, NLINES, LINE1, LINE2, P
     *AT(128), PREVC, NFLAG
      INTEGER AQ
      INTEGER IQ
      LOGICAL*1 BUF
      INTEGER LASTBF
      INTEGER NLINES
      INTEGER LINE1
      INTEGER LINE2
      LOGICAL*1 PAT
      INTEGER PREVC
      INTEGER NFLAG
      GETONE = 1
      CALL SKIPBL(LIN, I)
      ISTART = I
      IF (.NOT.(LIN(I) .GE. 48 .AND. LIN(I) .LE. 57))GOTO 23190
      NUM = CTOI(LIN, I)
      I = I - 1
      IF (.NOT.(NUM .LT. 0))GOTO 23192
      GETONE = -3
23192 CONTINUE
      NUM = -NUM
      GOTO 23191
23190 CONTINUE
      IF (.NOT.(LIN(I) .EQ. 36))GOTO 23194
      NUM = -30000
      GOTO 23195
23194 CONTINUE
      IF (.NOT.(LIN(I) .EQ. 47))GOTO 23196
      IF (.NOT.(OPTPAT(LIN, I) .EQ. -3))GOTO 23198
      GETONE = -3
      GOTO 23199
23198 CONTINUE
      IF (.NOT.(LIN(I) .EQ. 47))GOTO 23200
      NUM = LASTBF
      JUNK = ADDSTR(PAT, BUF, LASTBF, 5000)
      IF (.NOT.(ADDSET(0, BUF, LASTBF, 5000) .EQ. 0))GOTO 23202
      GETONE = -3
23202 CONTINUE
23200 CONTINUE
23199 CONTINUE
      GOTO 23197
23196 CONTINUE
      GETONE = -1
23197 CONTINUE
23195 CONTINUE
23191 CONTINUE
      IF (.NOT.(GETONE .EQ. 1))GOTO 23204
      I = I + 1
23204 CONTINUE
      CALL SKIPBL(LIN, I)
      IF (.NOT.(I .LE. ISTART))GOTO 23206
      GETONE = -1
      GOTO 23207
23206 CONTINUE
      GETONE = 1
23207 CONTINUE
      RETURN
      END
      INTEGER FUNCTION GETRHS(LIN, I, SUB, GFLAG)
      LOGICAL*1 LIN(512), SUB(128)
      INTEGER MAKSUB
      LOGICAL*1 CLOWER
      INTEGER GFLAG, I
      GETRHS = -3
      IF (.NOT.(LIN(I) .EQ. 0))GOTO 23208
      RETURN
23208 CONTINUE
      IF (.NOT.(LIN(I + 1) .EQ. 0))GOTO 23210
      RETURN
23210 CONTINUE
      I = MAKSUB(LIN, I + 1, LIN(I), SUB)
      IF (.NOT.(I .EQ. -3))GOTO 23212
      RETURN
23212 CONTINUE
      IF (.NOT.(CLOWER(LIN(I + 1)) .EQ. 103))GOTO 23214
      I = I + 1
      GFLAG = 1
      GOTO 23215
23214 CONTINUE
      GFLAG = 0
23215 CONTINUE
      GETRHS = 1
      RETURN
      END
      INTEGER FUNCTION MAKSUB(ARG, FROM, DELIM, SUB)
      LOGICAL*1 ESC
      LOGICAL*1 ARG(128), DELIM, SUB(128)
      INTEGER ADDSET
      INTEGER FROM, I, J, JUNK
      J = 1
      I = FROM
23216 IF (.NOT.(ARG(I) .NE. DELIM .AND. ARG(I) .NE. 0))GOTO 23218
      IF (.NOT.(ARG(I) .EQ. 38))GOTO 23219
      JUNK = ADDSET((-3), SUB, J, 128)
      GOTO 23220
23219 CONTINUE
      JUNK = ADDSET(ESC(ARG, I), SUB, J, 128)
23220 CONTINUE
23217 I = I + 1
      GOTO 23216
23218 CONTINUE
      IF (.NOT.(ARG(I) .NE. DELIM))GOTO 23221
      MAKSUB = -3
      GOTO 23222
23221 CONTINUE
      IF (.NOT.(ADDSET(0, SUB, J, 128) .EQ. 0))GOTO 23223
      MAKSUB = -3
      GOTO 23224
23223 CONTINUE
      MAKSUB = I
23224 CONTINUE
23222 CONTINUE
      RETURN
      END
      INTEGER FUNCTION OPTPAT(LIN, I)
      LOGICAL*1 LIN(512)
      INTEGER MAKPAT
      INTEGER I
      COMMON /CSEDIT/ AQ, IQ, BUF(5000), LASTBF, NLINES, LINE1, LINE2, P
     *AT(128), PREVC, NFLAG
      INTEGER AQ
      INTEGER IQ
      LOGICAL*1 BUF
      INTEGER LASTBF
      INTEGER NLINES
      INTEGER LINE1
      INTEGER LINE2
      LOGICAL*1 PAT
      INTEGER PREVC
      INTEGER NFLAG
      IF (.NOT.(LIN(I) .EQ. 0))GOTO 23225
      I = -3
      GOTO 23226
23225 CONTINUE
      IF (.NOT.(LIN(I + 1) .EQ. 0))GOTO 23227
      I = -3
      GOTO 23228
23227 CONTINUE
      IF (.NOT.(LIN(I + 1) .EQ. LIN(I)))GOTO 23229
      I = I + 1
      GOTO 23230
23229 CONTINUE
      I = MAKPAT(LIN, I + 1, LIN(I), PAT)
23230 CONTINUE
23228 CONTINUE
23226 CONTINUE
      IF (.NOT.(PAT(1) .EQ. 0))GOTO 23231
      I = -3
23231 CONTINUE
      IF (.NOT.(I .EQ. -3))GOTO 23233
      PAT(1) = 0
      OPTPAT = -3
      GOTO 23234
23233 CONTINUE
      OPTPAT = 1
23234 CONTINUE
      RETURN
      END
      SUBROUTINE SED(LINBUF, LINENO, FD)
      LOGICAL*1 LINBUF(512)
      INTEGER LINENO, FD
      LOGICAL*1 BUF1(512), BUF2(512)
      INTEGER GETLIN
      COMMON /CSEDIT/ AQ, IQ, BUF(5000), LASTBF, NLINES, LINE1, LINE2, P
     *AT(128), PREVC, NFLAG
      INTEGER AQ
      INTEGER IQ
      LOGICAL*1 BUF
      INTEGER LASTBF
      INTEGER NLINES
      INTEGER LINE1
      INTEGER LINE2
      LOGICAL*1 PAT
      INTEGER PREVC
      INTEGER NFLAG
      IF (.NOT.(GETLIN(BUF1, FD) .EQ. -1))GOTO 23235
      RETURN
23235 CONTINUE
      IF (.NOT.(LINENO .GT. 0))GOTO 23237
      LINENO = LINENO + 1
      CALL DOCMDS(LINBUF, LINENO)
23237 CONTINUE
23239 CONTINUE
      IF (.NOT.(GETLIN(BUF2, FD) .EQ. -1))GOTO 23242
      CALL SCOPY(BUF1, 1, LINBUF, 1)
      GOTO 23241
23242 CONTINUE
      LINENO = LINENO + 1
      CALL DOCMDS(BUF1, LINENO)
      IF (.NOT.(GETLIN(BUF1, FD) .EQ. -1))GOTO 23244
      CALL SCOPY(BUF2, 1, LINBUF, 1)
      GOTO 23241
23244 CONTINUE
      LINENO = LINENO + 1
      CALL DOCMDS(BUF2, LINENO)
23240 GOTO 23239
23241 CONTINUE
      RETURN
      END
      SUBROUTINE SUBST(TXT, PAT, SUB, GFLAG, PFLAG)
      LOGICAL*1 TXT(512), PAT(100), SUB(100)
      INTEGER GFLAG, PFLAG
      LOGICAL*1 NEW(512)
      INTEGER ADDSET, AMATCH
      INTEGER J, JUNK, K, LASTM, M, SUBBED
      J = 1
      SUBBED = 0
      LASTM = 0
      K = 1
23246 IF (.NOT.(TXT(K) .NE. 0))GOTO 23248
      IF (.NOT.(GFLAG .EQ. 1 .OR. SUBBED .EQ. 0))GOTO 23249
      M = AMATCH(TXT, K, PAT)
      GOTO 23250
23249 CONTINUE
      M = 0
23250 CONTINUE
      IF (.NOT.(M .GT. 0 .AND. LASTM .NE. M))GOTO 23251
      SUBBED = 1
      CALL CATSUB(TXT, K, M, SUB, NEW, J, 512)
      LASTM = M
23251 CONTINUE
      IF (.NOT.(M .EQ. 0 .OR. M .EQ. K))GOTO 23253
      JUNK = ADDSET(TXT(K), NEW, J, 512)
      K = K + 1
      GOTO 23254
23253 CONTINUE
      K = M
23254 CONTINUE
23247 GOTO 23246
23248 CONTINUE
      IF (.NOT.(SUBBED .EQ. 1))GOTO 23255
      IF (.NOT.(ADDSET(0, NEW, J, 512) .EQ. 0))GOTO 23257
      RETURN
23257 CONTINUE
      CALL SCOPY(NEW, 1, TXT, 1)
      IF (.NOT.(PFLAG .EQ. 1))GOTO 23259
      CALL PUTLIN(TXT, 2)
23259 CONTINUE
23255 CONTINUE
      RETURN
      END
