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

Defined functions

coll defined in line 11; used 2 times
comp defined in line 192; used 1 times
  • in line 48
conf defined in line 179; used 3 times
hyp1 defined in line 212; used 2 times
hyp2 defined in line 226; used 2 times
hyphen defined in line 204; used 1 times
out defined in line 54; used 4 times
pno defined in line 245; used 4 times
save defined in line 18; used 3 times
search defined in line 108; used 3 times

Defined variables

mone defined in line 8; never used
tlno defined in line 9; used 3 times

Defined macros

COLLECT defined in line 5; used 2 times
SKIP defined in line 4; used 2 times
SKIP2 defined in line 6; never used
Last modified: 1975-05-14
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1160
Valid CSS Valid XHTML 1.0 Strict