home *** CD-ROM | disk | FTP | other *** search
- -h- findcons.fnd 305
- { findcons -- const declarations for find }
- const
- MAXPAT = MAXSTR;
- CLOSIZE = 1; { size of a closure entry }
- CLOSURE = STAR;
- BOL = PERCENT;
- EOL = DOLLAR;
- ANY = QUESTION;
- CCL = LBRACK;
- CCLEND = RBRACK;
- NEGATE = CARET;
- NCCL = EXCLAM; { cannot be the same as NEGATE }
- LITCHAR = LETC; { ord('c') }
-
- -h- findp.fnd 957
- { find -- find patterns in text }
- procedure find;
- {$include:'findcons.fnd'}
- var
- arg, lin, pat : string;
- iarg : integer;
- ifn : lstring(MAXFN); {input filename }
- ii : integer;
- {$include:'getpat.ted' }
- {$include:'match.ted' }
- begin
- if (not getarg(1, arg, MAXSTR)) then
- error('usage: find pattern [input-file ...]');
- if (not getpat(arg, pat)) then
- error('find: illegal pattern');
- iarg := 1;
- while (iarg = 1) or (iarg < nargs) do begin
- iarg := iarg + 1;
- if (getarg(iarg,arg,MAXSTR)) then begin
- for ii := 1 to length(arg) do ifn[ii] := chr(arg[ii]);
- ifn[0] := chr(length(arg));
- close(input);
- assign(input,ifn);
- reset(input);
- end;
- if (nargs > 2) then begin
- putc(LESS); putstr(arg, STDOUT); putc(GREATER); putc(NEWLINE);
- end;
- ii := 0;
- while (getline(lin, STDIN, MAXSTR)) do begin
- ii := ii + 1;
- if (match(lin, pat)) then begin
- putdec(ii,3); putc(COLON);
- putstr(lin, STDOUT)
- end;
- end;
- end;
- end;
- -h- findp.pas 509
- {$debug-}
- program outer (input,output);
-
- {$include:'globcons.inc'}
- {$include:'globtyps.inc'}
-
- {$include:'initio.dcl' }
- {$include:'flush.dcl' }
- {$include:'getline.dcl' }
- {$include:'putc.dcl' }
- {$include:'putstr.dcl' }
- {$include:'getarg.dcl' }
- {$include:'nargs.dcl' }
- {$include:'length.dcl' }
- {$include:'error.dcl' }
- {$include:'putdec.dcl' }
- {$include:'addstr.dcl' }
- {$include:'isalphan.dcl'}
- {$include:'esc.dcl' }
-
- {$include:'findp.fnd' }
- BEGIN
- minitio; initio;
- find;
- flush(0);
- END.
- -h- findp.mak 123
- findp+initio+getfcb+error+getarg+nargs+length+putc+
- getline+putdec+addstr+isalphan+esc+putcf+flush+
- itoc+getcf+getc+putstr