|
|
1.1 ! root 1: # include "refer..c" ! 2: getq(v) ! 3: char *v[]; ! 4: { ! 5: # define BSIZ 250 ! 6: static char buff[BSIZ]; ! 7: static int eof = 0; ! 8: extern char *sinput; ! 9: char *p; ! 10: int c, n = 0, las = 0; ! 11: if (eof) return(-1); ! 12: p = buff; ! 13: while ( (c = (sinput ? *sinput++ : getchar()) ) > 0) ! 14: { ! 15: if (c== '\n') ! 16: break; ! 17: if (isalpha(c) || isdigit(c)) ! 18: { ! 19: if (las==0) ! 20: { ! 21: v[n++] = p; ! 22: las=1; ! 23: } ! 24: if (las++ <= 6) ! 25: *p++ = c; ! 26: } ! 27: else ! 28: { ! 29: if (las>0) ! 30: *p++ = 0; ! 31: las=0; ! 32: } ! 33: } ! 34: *p=0; ! 35: assert(p<buff+BSIZ); ! 36: if (sinput==0 && c<= 0) eof=1; ! 37: n = keycomp(v,n); ! 38: # if D1 ! 39: fprintf(stderr, "no. keys %d\n",n); ! 40: for(c=0; c<n; c++) ! 41: fprintf(stderr, "keys X%sX\n", v[c]); ! 42: # endif ! 43: return(n); ! 44: } ! 45: keycomp(v,n) /* compress keys */ ! 46: char *v[]; ! 47: { ! 48: int i, j, k; ! 49: for(i=j=0; i<n; i++) ! 50: { ! 51: for(k=0; k<j; k++) ! 52: if (strcmp(v[i], v[k])==0) ! 53: break; ! 54: if (k<j) /* found it */ ! 55: continue; ! 56: v[j++] = v[i]; ! 57: } ! 58: return(j); ! 59: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.