1: # include <stdio.h>
   2: # include "prep.h"
   3: # define SKIP 0
   4: # define COLLECT 1
   5: # define SKIP2 2
   6: 
   7: int tlno = 1;
   8: 
   9: coll()
  10: {
  11:     cs = COLLECT;
  12:     temp[t1].beg = &line[l];
  13:     return;
  14: }
  15: 
  16: save()
  17: {
  18:     extern  only;
  19:     char    *pt1,*pt2,cbuf[30];
  20:     int val;
  21: 
  22:     if(cs != COLLECT) {
  23:         cs = SKIP;
  24:         return;
  25:     }
  26:     cs = SKIP;
  27:     line[l] = '\0';
  28:     temp[t1].ct = &line[l] - temp[t1].beg;
  29:     pt1 = temp[t1].beg-1;
  30:     pt2 = cbuf-1;
  31: 
  32:     wdnum++;
  33:     while(*++pt2 = *++pt1)
  34:         if(*pt2 >= 'A' && *pt2 <= 'Z')
  35:             *pt2 |= 040;
  36: 
  37:     if(igflg){
  38:         val = search(cbuf,temp[t1].ct,&itab,0);
  39:         if(!val == !only) goto yes;
  40: 
  41:         line[l] = c;
  42:         return;
  43:     }
  44: yes:
  45:     temp[t1++].wdno = wdnum;
  46:     line[l] = c;
  47:     return;
  48: }
  49: 
  50: ctout()
  51: {
  52:     register int    ct;
  53:     register char   *t2;
  54:     int t3;
  55:     long    xxx;
  56: 
  57:     if(lflag) {
  58:         fprintf(stderr, "line too long:  line %d\n",lno);
  59:         lflag = 0;
  60:     }
  61:     if(cs == COLLECT)   save();
  62: 
  63:     t3 = t1;
  64:     t1 = -1;
  65:     while(++t1 < t3) {
  66:         if(wdflg){
  67:             xxx = temp[t1].wdno;
  68:             conf(xxx, WIDTH, num);
  69:             put(num,WIDTH+1);
  70:         }
  71:         ct = temp[t1].ct;
  72:         t2 = temp[t1].beg - 1;
  73: /*		fprintf(stderr, "out: %s	%d\n", temp[t1].beg, ct);	/*DEBUG*/
  74:         while(ct--)
  75:             if(*++t2 >= 'A' && *t2 <= 'Z')
  76:                 *t2 |= 040;
  77: 
  78:         ct = temp[t1].ct;
  79:         while(*--t2 == '\'' && san == 0)
  80:             ct--;
  81: 
  82:         put(temp[t1].beg, ct);
  83:         put("\n", 1);
  84:     }
  85:     t1 = 0;
  86:     l = -1;
  87:     lno += tlno;
  88:     tlno = 1;
  89:     cs = SKIP;
  90:     return;
  91: }
  92: 
  93: conf(n,width,buf)
  94:     long n;
  95:     char    *buf;
  96: {
  97:     long    a;
  98:     auto i;
  99: 
 100:     i = width;
 101:     while(i--)  buf[i] = ' ';
 102: 
 103:     a = n/10;
 104:     if(a)
 105:         width = conf(a, --width, buf);
 106:     else
 107:         width--;
 108:     buf[width] = n%10 + '0';
 109: 
 110:     return(++width);
 111: }
 112: 
 113: hyphen()
 114: {
 115: /*	fprintf(stderr, "hyphen\n");	/*DEBUG*/
 116:     flag[++fl] = hyp1;
 117:     return(1);
 118: }
 119: 
 120: hyp1()
 121: {
 122: /*	fprintf(stderr, "hyp1 c = %o\n",c);	/*DEBUG*/
 123:     if(c !=  '\n') {
 124:         fl--;
 125:         l--;
 126:         save();
 127:         l++;
 128:         punc();
 129:         return(0);
 130:     } else {
 131:         l -= 2;
 132:         flag[fl] = hyp2;
 133:         hsw = 1;
 134:         return(1);
 135:     }
 136: }
 137: 
 138: hyp2()
 139: {
 140:     extern  (*acts[])();
 141: /*	fprintf(stderr, "hyp2 c = %o l = %d\n",c,l);	/*DEBUG*/
 142:     if(hsw && (tab[2][c] == 0)) {
 143:         l--;
 144:         if(c == '\n')   tlno++;
 145:         return(1);
 146:     }
 147:     hsw = 0;
 148:     if(c == '\n'){
 149:         l--;
 150:         return(1);
 151:     }
 152:     if(tab[cs][c]) {
 153:         line[l] = '\n';
 154:         (*acts[OUT])();
 155:         fl--;
 156:         return(0);
 157:     }
 158:     return(1);
 159: }
 160: 
 161: gobble2()
 162: {
 163:     static  ct2;
 164: 
 165:     if(cs == COLLECT)   save();
 166: 
 167:     if(flag[fl] != gobble2) {
 168:         ct2 = 1;
 169:         flag[++fl] = gobble2;
 170:         return(1);
 171:     }
 172:     if(ct2--)   return(1);
 173: 
 174:     fl--;
 175:     cs = SKIP;
 176:     return(1);
 177: }
 178: 
 179: bslash()
 180: {
 181:     if(cs == COLLECT)   save();
 182:     cs = SKIP2;
 183:     return(1);
 184: }
 185: 
 186: bsp()
 187: {
 188:     flag[++fl] = bsp1;
 189:     return(1);
 190: }
 191: 
 192: bsp1()
 193: {
 194:     fl--;
 195:     if(c == '"')    return(1);
 196: 
 197:     line[--l] = c;
 198:     return(0);
 199: }
 200: 
 201: punc()
 202: {
 203: 
 204:     if(cs == COLLECT)
 205:         save();
 206:     if(puncfl) {
 207:         temp[t1].beg = &line[l];
 208:         temp[t1].ct = 1;
 209:         temp[t1++].wdno = 0;
 210:     }
 211: }
 212: 
 213: search(symbol,length,params,install)
 214:     char    *symbol;
 215:     int length;
 216:     struct  htab    *params;
 217:     int install;
 218: {
 219:     char    *sp,*p;
 220:     static  int *hptr,hsiz,nsym;
 221:     static  int ssiz;
 222:     static  int curb;
 223:     static  char    *symt;
 224:     auto    h,i,j;
 225: 
 226:     if(hptr != params->hptr) {
 227:         hptr = params->hptr;
 228:         hsiz = params->hsiz;
 229:         symt = params->symt;
 230:         ssiz = params->ssiz;
 231:         curb = params->curb;
 232:         nsym = params->nsym;
 233:     }
 234: 
 235:     symbol[length] = '\0';
 236: /*fprintf(stderr, "ssiz = %d; nsym = %d; %s\n", ssiz, nsym, symbol);/*DEBUG*/
 237:     sp = symbol;
 238: 
 239:     i = length;
 240:     h = 1;
 241:     while(i--)
 242:         h *= *sp++;
 243: 
 244:     if(h == 0100000) {
 245:         h = 1;
 246:     } else {
 247:         h = h<0?(-h)%hsiz:h%hsiz;
 248:     }
 249:     if(h == 0)  h++;
 250: /*		fprintf(stderr, "%s %d\n",symbol,h);	/*DEBUG*/
 251: 
 252:     while((p = &symt[hptr[h]]) > symt) {
 253:         j = length + 2;
 254:         sp = symbol;
 255:         while(--j) {
 256:             if(*p++ != *sp++)   goto no;
 257:         }
 258:         return(*p);
 259: no:
 260:         h++;
 261:         if(h >= hsiz)   h -= hsiz;
 262:     }
 263:     if(install) {
 264:         if(++nsym >= hsiz) {
 265:             fprintf(stderr, "Too many symbols in ignore/only file.\n");
 266:             exit(1);
 267:         }
 268: 
 269:         hptr[h] = curb;
 270:         length++;
 271:         if((curb + length) >= ssiz) {
 272:             fprintf(stderr, "i/o file too big; ssiz = %d\n", ssiz);
 273:             exit(1);
 274:         }
 275: 
 276:         while(length--)
 277:             symt[curb++] = *symbol++;
 278:         symt[curb++] = install;
 279:         params->curb = curb;
 280:         params->nsym = nsym;
 281:     }
 282:     return(0);
 283: }

Defined functions

bslash defined in line 179; used 1 times
bsp defined in line 186; used 1 times
bsp1 defined in line 192; used 2 times
coll defined in line 9; used 2 times
conf defined in line 93; used 2 times
ctout defined in line 50; used 2 times
gobble2 defined in line 161; used 3 times
hyp1 defined in line 120; used 2 times
hyp2 defined in line 138; used 2 times
hyphen defined in line 113; used 1 times
punc defined in line 201; used 2 times
save defined in line 16; used 7 times
search defined in line 213; used 3 times

Defined variables

tlno defined in line 7; used 3 times

Defined macros

COLLECT defined in line 4; used 6 times
SKIP defined in line 3; used 4 times
SKIP2 defined in line 5; used 1 times
Last modified: 1981-07-10
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1418
Valid CSS Valid XHTML 1.0 Strict