static char sccsid
[] = "@(#)diction.c 4.2 (Berkeley) 82/11/06";
* diction -- print all sentences containing one of default phrases
* 0 - ok, and some matches
0, 0, ' ', 0, 0, 0, 0, 0,
' ', '.', ' ', ' ', ' ', ' ', ' ', ' ',
' ', ' ', ' ', ' ', ' ', ' ', '.', ' ',
'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', ' ', ' ', ' ', ' ', ' ', '.',
' ', 'a', 'b', 'c', 'd', 'e', 'f', 'g',
'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
'x', 'y', 'z', ' ', ' ', ' ', ' ', ' ',
' ', 'a', 'b', 'c', 'd', 'e', 'f', 'g',
'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
'x', 'y', 'z', ' ', ' ', ' ', ' ', ' '
int nflag
= 1; /*use default file*/
int mflg
= 0; /*don't catch output*/
while (--argc
> 0 && (++argv
)[0][0]=='-')
fprintf(stderr
, "diction: unknown flag\n");
fprintf(stderr
,"diction: can't open default dictionary\n");
wordf
= fopen(filename
,"r");
fprintf(stderr
,"diction: can't open %s\n",filename
);
if(fopen(CATCH
,"r") != NULL
)
if((mine
=fopen(CATCH
,"a"))!=NULL
)mflg
=1;
else while (--argc
>= 0) {
printf("file %s: number of lines %ld number of phrases found %ld\n",
if(mflg
)fprintf(mine
,"number of sentences %ld %ld number of hits %ld %ld\n",nsent
,tl
,nhits
,th
);
if(!caps
&& !lineno
)printf("number of sentences %ld number of phrases found %ld\n",nsent
,nhits
);
if(!caps
)printf("totals: number of lines %ld number of phrases found %ld\n",tl
,th
);
register struct words
*c
;
if ((f
= open(file
, 0)) < 0) {
fprintf(stderr
, "diction: can't open %s\n", file
);
savc
= (struct words
*) 0;
if (p
== &buf
[1024]) p
= buf
;
if ((ccount
= read(f
, p
, &buf
[1024] - p
)) <= 0) break;
else if ((ccount
= read(f
, p
, 512)) <= 0) break;
fwrite(beg1
,sizeof(*beg1
),count1
,stdout
);
if(p
== &buf
[1024])p
=buf
;
if (c
->inp
== table
[*p
]) {
if(ccount
> savct
)ccount
+= savct
;
savc
= (struct words
*) 0;
if (c
->inp
== table
[*p
]) {
if((c
->inp
== table
[*(p
+1)]) && (c
->nst
!= 0)){
while((savc
=savc
->link
)!= 0){
if(savc
->inp
== table
[*(p
+1)]){
savc
= (struct words
*) 0;
if(c
->out
== (char)(0377)){
if(begp
< &buf
[0])begp
= &buf
[1024] - (&buf
[0]-begp
);
if(nlp
< &buf
[512])myst
=nlp
;
if(myst
< nlp
)myst
= nlp
;
if (table
[*p
++] == '.') {
if (p
== &buf
[1024]) p
= buf
;
if ((ccount
= read(f
, p
, &buf
[1024] - p
)) <= 0) break;
else if ((ccount
= read(f
, p
, 512)) <= 0) break;
fwrite(beg1
,sizeof(*beg1
),count1
,stdout
);
if(mflg
&& last
){putc('\n',mine
);myct
= 0;}
if(*p
== '\n')olcount
= lcount
+1;
fwrite(beg1
,sizeof(*beg1
),count1
,stdout
);
if((c
=getc(wordf
))==EOF
){
wordf
=fopen(filename
,"r");
fprintf("diction can't open %s\n",filename
);
if ((c
= *argptr
++) == '\0')
register struct words
*s
;
if (s
->inp
== 0) goto enter
;
if (smax
>= &w
[MAXSIZ
- 1]) overflo();
if (smax
>= &w
[MAXSIZ
- 1]) overflo();
} while ((c
= getargc()) != '\n' && c
!=EOF
);
fprintf(stderr
, "wordlist too large\n");
struct words
*queue
[QSIZE
];
struct words
**front
, **rear
;
register struct words
*s
;
init
: if ((s
->inp
) != 0) {
if (rear
>= &queue
[QSIZE
- 1]) overflo();
if ((s
= s
->link
) != 0) {
if (front
== &queue
[QSIZE
-1])
cloop
: if ((c
= s
->inp
) != 0) {
if (rear
>= &queue
[QSIZE
-1])
if (front
== queue
) overflo();
if (++rear
== front
) overflo();
floop
: if (state
== 0){ state
= w
;bstart
=1;}
qloop
: q
->fail
= state
->nst
;
if ((state
->nst
)->out
!= 0 && q
->out
== 0) q
->out
= (state
->nst
)->out
;
if((q
=q
->link
) != 0)goto qloop
;
else if ((state
= state
->link
) != 0)
else if(bstart
==0){state
=0; goto floop
;}
printf("s %d ch %c out %d nst %d link %d fail %d\n",s,
s->inp,s->out,s->nst,s->link,s->fail);
if(!caps
&& lineno
&& linemsg
){
printf("beginning line %ld",olcount
);
if(file
!= (char *)NULL
)printf(" %s\n",file
);
if(!caps
&& oct
> 60 && table
[*nlp
] == ' ' && nlp
!= begp
&& nlp
!= endp
){
if( oct
>45){putchar('\n');
if( oct
==0 || table
[*nlp
] != ' '){
if(islower(*nlp
))*nlp
= toupper(*nlp
);
if(!caps
&& *nlp
== '\n')*nlp
= ' ';
if(*nlp
== ' ' && oct
==0);
else if(!caps
) {putchar(*nlp
); oct
++;}
if(*(nlp
) != ' '){printf("]*");
if(oct
>60){putchar('\n');
if(myct
++ >= 72 || last
== 20){
if(last
== 20)last
=myct
=0;