1: char number[3];
   2: int eflg;
   3: char w2006[100];
   4: flg 0;
   5: char realwd[100];
   6: char *wd {&realwd[1]};
   7: char *fptr;
   8: char *ffptr &ffbuf;
   9: char ffbuf[36];
  10: int neng;
  11: int npr;
  12: int table[2];   /*keep these four cards in order*/
  13: int tab1[26];
  14: int tab2[730];
  15: char tab3[19684];
  16: int logtab[256];
  17: float inctab[256];
  18: char nwd[100];
  19: int tot;
  20: int wtot;
  21: char *buf[3];
  22: file[3];
  23: ptr[3];
  24: char *name[3];
  25: bsp[768];
  26: 
  27: main(argc,argv) int argc; char *argv[]; {
  28:     char let,lt;
  29:     auto arg,t,sw,i,j,salt,er,c;
  30:     register k,l,m;
  31:     double junk;
  32:     int unl();
  33:     int ii;
  34:     double log(), exp(), pow();
  35: 
  36:     nice(-20);
  37:     inctab[0] = 1;
  38:     logtab[0] = -10;
  39:     for(ii=1; ii<256; ii++){
  40:         inctab[ii] = exp(-ii/30.497);
  41:         logtab[ii] = log(30.*pow(1.0333,ii+0.) - 30.) + .5;
  42:         }
  43:     logtab[1] = -10;
  44: 
  45:     number[2] = ' ';
  46:     buf[0] = bsp;
  47:     buf[1] = bsp + 0400;
  48:     buf[2] = bsp + 01000;
  49:     ptr[0] = 0; ptr[1] = 0;
  50:     ptr[2] = 1;
  51:     arg = 1;
  52:     while(argc>1 && argv[arg][0] == '-') {
  53:         switch(argv[arg][1]) {
  54:         default:
  55:             printf("Unrecognizable argument: %c\n",argv[arg][1]);
  56:                 exit();
  57:         case 0:
  58:         case 'n':
  59:                 neng++;
  60:                 break;
  61:         case '1':
  62:                 npr++;
  63:         }
  64:         arg++;
  65:         --argc;
  66:     }
  67:     if(!neng) {
  68:         salt = open("/usr/lib/salt",0);
  69:         er = read(salt,table,21200);
  70:             if(er != 21200)err("read salt");
  71:         close(salt);
  72:         }
  73:     if((signal(2,1) & 1) != 1)
  74:     signal(2,unl);
  75:     name[0] = "/usr/tmp/ttmpa1";
  76:     name[1] = "/usr/tmp/ttmpa2";
  77:     name[2] = "/usr/tmp/ttmpa3";
  78:     while((file[0] = open(name[0],1)) > 0){
  79:         close(file[0]);
  80:         for(j=0; j < 3; j++)name[j][13]++;
  81:         if(name[0][13] == 'z')err("creat tmp file");
  82:     }
  83:     file[0] = creat(name[0],0666);
  84:     fptr = argv[arg];
  85:     if(argc == 1) {argc = 2; arg = 0;}
  86:     while(--argc){
  87:         if(arg == 0){
  88:             file[2] = 0;
  89:         }else{
  90:             file[2] = open(argv[arg++],0);
  91:             if(file[2] < 0)err("open input file");
  92:         }
  93:         eflg = 1;
  94:         while((j = wdval(2)) != 0){
  95:             put(0,nwd,j);
  96:             k = -1;
  97:             l = 0;
  98:             m = 1;
  99:             if(inctab[table[0]] > (junk=rand()/32768.)) table[0]++;
 100:             while(m <= j){
 101:                 c = 27*wd[k++] + wd[l++];
 102:                 if(inctab[tab2[c]] > junk) tab2[c]++;
 103:                 c = 27*c + wd[m++];
 104:                 if(inctab[tab3[c]] > junk) tab3[c]++;
 105:             }
 106:             c = 27*wd[k] + wd[l];
 107:             if(inctab[tab2[c]] > junk) tab2[c]++;
 108:         }
 109:         if(file[2]) close(file[2]);
 110:     }
 111:     flsh(0,0);
 112:     close(file[0]);
 113:     sw = fork();
 114:         if(sw == 0){execl("/usr/bin/usort","usort","-o",name[2],name[0],0);
 115:             err("sort"); }
 116:         if(sw == -1)err("fork");
 117:     er = wait();
 118:         if(er != sw)err("probs");
 119:     file[0] = creat(name[0],0666);
 120:         if(file[0] < 0)err("creat tmp");
 121:     file[1] = open("/usr/lib/w2006",0);
 122:         if(file[1] < 0)err("open w2006");
 123:     ptr[1] = 1;
 124:     for(k=0;((c = w2006[k] = get(1)) != '\n');k++)
 125:         if(c == -1) break;
 126:     file[2] = open(name[2],0);
 127:     if(file[2] < 0)err("open tmp");
 128:     ptr[2] = 1;
 129: 
 130:     while(ptr[2]){
 131:         l=0;
 132:         for(k=0;((c = wd[k] = get(2)) != '\n');k++)
 133:             if(c == -1)goto done;
 134:         for(i=0; i<=k;i++){
 135:             if(wd[i] < w2006[l]){
 136:                 put(0,wd,k);
 137:                 break;
 138:             }
 139:             if(wd[i] > w2006[l]){
 140:                 for(l=0;((c = w2006[l] = get(1)) != '\n');l++)
 141:                 if(c == -1){
 142:                     put(0,wd,k);
 143:                     for(k=0;((c = wd[k] =get(2))!= -1);k++){
 144:                         put(0,wd,k);
 145:                         k = -1;
 146:                     }
 147:                     goto done;
 148:                 }
 149:                 i = -1;
 150:                 l=0;
 151:                 continue;
 152:             }
 153:             l++;
 154:         }
 155:     }
 156: done:
 157:     close(file[2]);
 158:     unlink(name[2]);
 159:     flsh(0,0);
 160:     close(file[1]);
 161:     close(file[0]);
 162:     ptr[1] = 1;
 163:     file[1] = open(name[0],0);
 164:         if(file[1] < 0)err("open tmp ");
 165:     file[0] = creat(name[1],0666);
 166:         if(file[0] < 0)err("create tmp");
 167:     while((j = nwdval(1)) != 0){
 168:         wtot = 0;
 169:         flg = 0;
 170:         k = -1; l = 0; m = 1;
 171:         while(m <= j){
 172:             tot = 0;
 173:             c = wd[k++]*27 + wd[l++];
 174:             tot =+ (logtab[tab2[c]]+logtab[tab2[wd[k]*27+wd[l]]]);
 175:             tot =>> 1;
 176:             c = c*27 + wd[m++];
 177:             tot =- logtab[tab3[c] & 0377];
 178:             if(tot > wtot) wtot = tot;
 179:             }
 180:         if(wtot < 0) wtot = 0;
 181:         t = conf(wtot,2,number);
 182:         put(0,number,2);
 183:         put(0,nwd,j);
 184:         }
 185:     flsh(0,0);
 186:     close(file[1]);
 187:     close(file[0]);
 188: 
 189:     sw = fork();
 190:         if(sw == 0){execl("/bin/sort","sort","+0nr", "+1","-o",name[1],name[1]
 191:             ,0);
 192:             err("sort"); }
 193:         if(sw == -1)err("fork");
 194:     er = wait();
 195:         if(er != sw)err("prob");
 196: 
 197:     sw = fork();
 198:         if(sw == 0){
 199:             if(npr) {
 200:                 execl("/bin/cat","cat",name[1],0);
 201:             } else {
 202:                 i = 0 ;
 203:                 while((c = "Possible typo's in "[i++])!=0)
 204:                     *ffptr++ = c;
 205:                 i = 0;
 206:                 while((c = fptr[i++]) != 0)
 207:                     *ffptr++ = c;
 208:                 *ffptr = 0;
 209:                 execl("/bin/pr","pr","-3", "-h",
 210:                 ffbuf,name[1],0);
 211:                 err("pr");
 212:         }
 213:     }
 214:         if(sw == -1)err("fork");
 215:     er = wait();
 216:         if(er != sw)err("prob");
 217:     unl();
 218: }
 219: 
 220: unl() {
 221:     register j;
 222:     j = 2;
 223:     while(j--)unlink(name[j]);
 224:     exit();
 225: }
 226: 
 227: 
 228: err(c) char c[];{
 229:     register j;
 230:     printf("cannot %s\n",c);
 231:     unl();
 232: }
 233: 
 234: get(ifile) int ifile;{
 235:     static char *ibuf[10];
 236:     if(--ptr[ifile]){
 237:         return(*ibuf[ifile]++ & 0377);}
 238:     if(ptr[ifile] = read(file[ifile],buf[ifile],512)){
 239:         if(ptr[ifile] < 0)goto prob;
 240:         ibuf[ifile] = buf[ifile];
 241:         return(*ibuf[ifile]++ & 0377);
 242:     }
 243:     ptr[ifile] = 1;
 244:     return(-1);
 245: 
 246: prob:
 247:     ptr[ifile] = 1;
 248:     printf("read error\n");
 249:     return(-1);
 250: }
 251: 
 252: put(ofile,s,optr) char s[]; {
 253:     register i;
 254: 
 255:     while(optr-- >= 0)
 256:          buf[ofile][(ptr[ofile] < 512)?ptr[ofile]++:flsh(ofile,1)] = *s++;
 257:     return;
 258: }
 259: 
 260: flsh(ofile,i){
 261:     register error;
 262:     error = write(file[ofile],buf[ofile],ptr[ofile]);
 263:     if(error < 0)goto prob;
 264: 
 265:     ptr[ofile] = i;
 266:     return(0);
 267: prob:
 268:     printf("write error on t.%d\n",file[ofile]);
 269:     unl();
 270: }
 271: 
 272: wdval(wfile) int wfile; {
 273:     static let,wflg;
 274:     register j;
 275: beg:
 276:     j = -1;
 277:     if(wflg == 1){wflg = 0;
 278:         goto st; }
 279:     while((let = get(wfile)) != '\n'){
 280: st:
 281:         switch(let){
 282:         case -1:    return(0);
 283:         case '%':   if(j != -1)break;
 284:                     goto ret;
 285:         case '-':
 286:                 if((let = get(wfile)) == '\n'){
 287:                     while((let = get(wfile)) == '\n')if(let == -1)return(0);
 288:                     goto st; }
 289:                 else {wflg = 1;
 290:                     goto ret; }
 291:         case '\'':
 292:                 if(eflg != 1){
 293:                     if(j < 1)goto beg;
 294:                         else break;
 295:                     }
 296:         case '.':
 297:                 if(eflg == 1){
 298:                     while((let = get(wfile)) != '\n')if(let == -1)return(0);
 299:                     goto beg; }
 300:                 else goto ret;
 301:         default:
 302:                 eflg = 0;
 303:                 if(let < 'A')goto ret;
 304:                 if(let <= 'Z'){ wd[++j] = let - 0100;
 305:                     nwd[j] = let + ' ';
 306:                     break; }
 307:                 if(let < 'a' || let > 'z')goto ret;
 308:                 wd[++j] = let - 0140;
 309:                 nwd[j] = let;
 310:             }
 311:          eflg = 0;  }
 312: 
 313:     eflg = 1;
 314: ret:
 315:     if(j < 1)goto beg;
 316:     nwd[++j] = '\n';
 317:     wd[j] = 0;
 318:     return(j);
 319: }
 320: 
 321: nwdval(wfile) int wfile;{
 322:     register j;
 323:     register char c;
 324:     j = -1;
 325:     do{
 326:         if(( c = nwd[++j] = get(wfile)) == -1)return(0);
 327:         wd[j] = c - 0140;
 328:     }
 329:     while(c != '\n');
 330:     wd[j] = '\0';
 331:     return(j);
 332: }
 333: conf(n,width,cbuf) char cbuf[]; {
 334:     register i,a;
 335: 
 336:     i = width;
 337:     while(i--)cbuf[i] = ' ';
 338: 
 339:     cbuf[(a = n/10)?conf(a,--width,cbuf):--width] = n%10 + '0';
 340: 
 341:     return(++width);
 342: }
 343: rand(){
 344:     static gorp;
 345:     gorp = (gorp + 625) & 077777;
 346:     return(gorp);
 347: }

Defined functions

conf defined in line 333; used 2 times
err defined in line 228; used 17 times
flsh defined in line 260; used 4 times
get defined in line 234; used 9 times
main defined in line 27; never used
nwdval defined in line 321; used 1 times
put defined in line 252; used 6 times
rand defined in line 343; used 1 times
  • in line 99
unl defined in line 220; used 5 times
wdval defined in line 272; used 1 times
  • in line 94

Defined variables

buf defined in line 21; used 7 times
eflg defined in line 2; used 6 times
ffbuf defined in line 9; used 1 times
ffptr defined in line 8; used 3 times
fptr defined in line 7; used 2 times
inctab defined in line 17; used 6 times
logtab defined in line 16; used 6 times
name defined in line 24; used 19 times
neng defined in line 10; used 2 times
npr defined in line 11; used 2 times
number defined in line 1; used 3 times
nwd defined in line 18; used 6 times
realwd defined in line 5; used 1 times
  • in line 6
tab1 defined in line 13; never used
tab2 defined in line 14; used 6 times
tab3 defined in line 15; used 3 times
table defined in line 12; used 3 times
tot defined in line 19; used 6 times
w2006 defined in line 3; used 4 times
wd defined in line 6; used 22 times
wtot defined in line 20; used 6 times
Last modified: 1975-05-14
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1601
Valid CSS Valid XHTML 1.0 Strict