# include "refer..c" extern FILE *in; # define NFLD 30 # define TLEN 400 char one[ANSLEN]; int onelen ANSLEN; static char dr [100] ""; doref(firline) char *firline; { char buff[QLEN], dbuff[3*QLEN], answer[ANSLEN], temp[TLEN]; char line[LLINE]; char *p, **sr, *flds[NFLD], *r; int nf, nr, alph, query 0, chp, digs; /* get query */ buff[0] = dbuff[0] = 0; while (input(line)) { if (prefix(".]", line)) break; if (control(line[0])) query=1; strcat (query ? dbuff: buff, line); if (strlen(buff)>QLEN) err("buff too big (%d)", strlen(buff)); assert (strlen(dbuff) <3*QLEN); } if (strcmp (buff, "$LIST$\n")==0) { # if D1 fprintf(stderr, "dump sorted list\n"); # endif assert ( dbuff[0]==0); dumpold(); return; } answer[0] = 0; # ifdef D1 fprintf(stderr, "query is %s\n",buff); # endif for( p=buff; *p; p++) { if (isupper(*p)) *p |= 040; } alph = digs =0; for(p=buff; *p; p++) { if (isalpha(chp = *p)) alph++; else if (isdigit(*p)) digs++; else { *p=0; if ( (alph+digs<3) || common(p-alph)) { r = p-alph; while (r < p) *r++ = ' '; } if ( alph==0 && digs >0) { r = p-digs; # if D1 fprintf(stderr, "number, %d long, text is %s\n",digs,r); # endif if (digs != 4 || (atoi(r)/100 != 19)) { while (r
LLINE)
err("Accumulated answers too large",0);
strcat (answer, temp);
if (strlen(answer)>LLINE)
err("answer too long (%d)", strlen(answer));
if (newline(answer) > 0) break;
}
# if D1
fprintf(stderr, "answer:\n%s****\n", answer);
# endif
assert (strlen(one)