      SUBROUTINE MAIN
      LOGICAL*1 BUF(512)
      INTEGER PAT(132), I, K
      INTEGER GETLIN, MATCH
      INTEGER J
      COMMON / CXFIND / LSTPTR, PTR(200)
      INTEGER LSTPTR
      INTEGER PTR
      INTEGER MEM(5000)
      LOGICAL*1 CMEM(10000)
      EQUIVALENCE (CMEM(1),MEM(1))
      COMMON/CDSMEM/MEM
      CALL QUERY(25Husage:  xfind patfile ...)
      CALL INIPAT(BUF, PAT)
23000 IF (.NOT.(GETLIN(BUF, 1) .NE. -1))GOTO 23001
      I=1
23002 IF (.NOT.(I .LE. LSTPTR))GOTO 23004
      J=PTR(I)
      K=1
23005 IF (.NOT.(MEM(J) .NE. 0))GOTO 23007
      PAT(K) = MEM(J)
23006 J=J+1
      K=K+1
      GOTO 23005
23007 CONTINUE
      PAT(K) = 0
      IF (.NOT.(MATCH(BUF, PAT) .EQ. 1))GOTO 23008
      CALL PUTLIN(BUF, 2)
      GOTO 23004
23008 CONTINUE
23003 I=I+1
      GOTO 23002
23004 CONTINUE
      GOTO 23000
23001 CONTINUE
      RETURN
      END
      INTEGER FUNCTION ENTER(PAT)
      INTEGER PAT(132), I, SIZE
      INTEGER NODE, J
      INTEGER DSGET
      INTEGER MEM(5000)
      LOGICAL*1 CMEM(10000)
      EQUIVALENCE (CMEM(1),MEM(1))
      COMMON/CDSMEM/MEM
      SIZE = 1
23010 IF (.NOT.(PAT(SIZE) .NE. 0))GOTO 23012
23011 SIZE = SIZE + 1
      GOTO 23010
23012 CONTINUE
      NODE = DSGET(SIZE)
      IF (.NOT.(NODE .EQ. 0))GOTO 23013
      CALL ERROR(39HToo many patterns for internal storage.)
23013 CONTINUE
      I=1
      J=NODE
23015 IF (.NOT.(PAT(I) .NE. 0))GOTO 23017
      MEM(J) = PAT(I)
23016 I=I+1
      J=J+1
      GOTO 23015
23017 CONTINUE
      MEM(J) = 0
      ENTER=(NODE)
      RETURN
      END
      SUBROUTINE FERROR(FILE, BUF, REASON)
      LOGICAL*1 FILE(100), BUF(100), REASON(100)
      LOGICAL*1 ERR1(24)
      LOGICAL*1 ERR2(11)
      LOGICAL*1 ERR3(17)
      DATA ERR1(1)/69/,ERR1(2)/114/,ERR1(3)/114/,ERR1(4)/111/,ERR1(5)/11
     *4/,ERR1(6)/32/,ERR1(7)/112/,ERR1(8)/114/,ERR1(9)/111/,ERR1(10)/99/
     *,ERR1(11)/101/,ERR1(12)/115/,ERR1(13)/115/,ERR1(14)/105/,ERR1(15)/
     *110/,ERR1(16)/103/,ERR1(17)/32/,ERR1(18)/102/,ERR1(19)/105/,ERR1(2
     *0)/108/,ERR1(21)/101/,ERR1(22)/58/,ERR1(23)/32/,ERR1(24)/0/
      DATA ERR2(1)/44/,ERR2(2)/32/,ERR2(3)/114/,ERR2(4)/101/,ERR2(5)/97/
     *,ERR2(6)/115/,ERR2(7)/111/,ERR2(8)/110/,ERR2(9)/58/,ERR2(10)/32/,E
     *RR2(11)/0/
      DATA ERR3(1)/79/,ERR3(2)/102/,ERR3(3)/102/,ERR3(4)/101/,ERR3(5)/11
     *0/,ERR3(6)/100/,ERR3(7)/105/,ERR3(8)/110/,ERR3(9)/103/,ERR3(10)/32
     */,ERR3(11)/108/,ERR3(12)/105/,ERR3(13)/110/,ERR3(14)/101/,ERR3(15)
     */58/,ERR3(16)/32/,ERR3(17)/0/
      CALL PUTLIN(ERR1, 3)
      CALL PUTLIN(FILE, 3)
      CALL PUTLIN(ERR2, 3)
      CALL PUTLNL(REASON, 3)
      CALL PUTLIN(ERR3, 3)
      CALL PUTLNL(BUF, 3)
      CALL ENDST(-3)
      RETURN
      END
      SUBROUTINE INIPAT(BUF, PAT)
      LOGICAL*1 BUF(100), PATFIL(40)
      INTEGER PAT(132), I, J
      INTEGER GETARG, GETLIN, LENGTH, MAKPAT
      INTEGER FD
      INTEGER OPEN
      INTEGER ENTER
      COMMON / CXFIND / LSTPTR, PTR(200)
      INTEGER LSTPTR
      INTEGER PTR
      INTEGER MEM(5000)
      LOGICAL*1 CMEM(10000)
      EQUIVALENCE (CMEM(1),MEM(1))
      COMMON/CDSMEM/MEM
      LOGICAL*1 ILLPAT(17)
      LOGICAL*1 PTROVF(40)
      DATA ILLPAT(1)/73/,ILLPAT(2)/108/,ILLPAT(3)/108/,ILLPAT(4)/101/,IL
     *LPAT(5)/103/,ILLPAT(6)/97/,ILLPAT(7)/108/,ILLPAT(8)/32/,ILLPAT(9)/
     *112/,ILLPAT(10)/97/,ILLPAT(11)/116/,ILLPAT(12)/116/,ILLPAT(13)/101
     */,ILLPAT(14)/114/,ILLPAT(15)/110/,ILLPAT(16)/46/,ILLPAT(17)/0/
      DATA PTROVF(1)/84/,PTROVF(2)/111/,PTROVF(3)/111/,PTROVF(4)/32/,PTR
     *OVF(5)/109/,PTROVF(6)/97/,PTROVF(7)/110/,PTROVF(8)/121/,PTROVF(9)/
     *32/,PTROVF(10)/112/,PTROVF(11)/97/,PTROVF(12)/116/,PTROVF(13)/116/
     *,PTROVF(14)/101/,PTROVF(15)/114/,PTROVF(16)/110/,PTROVF(17)/115/,P
     *TROVF(18)/32/,PTROVF(19)/102/,PTROVF(20)/111/,PTROVF(21)/114/,PTRO
     *VF(22)/32/,PTROVF(23)/105/,PTROVF(24)/110/,PTROVF(25)/116/,PTROVF(
     *26)/101/,PTROVF(27)/114/,PTROVF(28)/110/,PTROVF(29)/97/,PTROVF(30)
     */108/,PTROVF(31)/32/,PTROVF(32)/115/,PTROVF(33)/116/,PTROVF(34)/11
     *1/,PTROVF(35)/114/,PTROVF(36)/97/,PTROVF(37)/103/,PTROVF(38)/101/,
     *PTROVF(39)/46/,PTROVF(40)/0/
      LTRPTR = 0
      CALL DSINIT(5000)
      I=1
23018 IF (.NOT.(GETARG(I, PATFIL, 40) .NE. -1))GOTO 23020
      FD = OPEN(PATFIL, 1)
      IF (.NOT.(FD .EQ. -3))GOTO 23021
      CALL CANT(PATFIL)
23021 CONTINUE
23023 IF (.NOT.(GETLIN(BUF, FD) .NE. -1))GOTO 23024
      J = LENGTH(BUF)
      BUF(J) = 0
      IF (.NOT.(MAKPAT(BUF, 1, 0, PAT) .EQ. -3))GOTO 23025
      CALL FERROR(PATFIL, BUF, ILLPAT)
23025 CONTINUE
      LSTPTR = LSTPTR + 1
      IF (.NOT.(LSTPTR .GT. 200))GOTO 23027
      CALL FERROR(PATFIL, BUF, PTROVF)
23027 CONTINUE
      PTR(LSTPTR) = ENTER(PAT)
      GOTO 23023
23024 CONTINUE
      CALL CLOSE(FD)
23019 I=I+1
      GOTO 23018
23020 CONTINUE
      RETURN
      END
