1: #ifndef lint 2: static char nhash_sccsid[] = "@(#)nhash.c 4.2 (Berkeley) 82/11/06"; 3: #endif not lint 4: 5: struct dict { 6: char *entry; 7: char val; 8: }; 9: extern struct dict ary_d[], cy_d[], ery_d[], fy_d[],gy_d[]; 10: extern struct dict ity_d[],ly_d[],ory_d[],ry_d[],ty_d[]; 11: extern struct dict dict[]; 12: extern struct dict abbrev_d[]; 13: char aahash(); 14: char lookup(); 15: char abbrev(); 16: char ary(); 17: char cy(); 18: char ery(); 19: char fy(); 20: char gy(); 21: char ity(); 22: char ly(); 23: char ory(); 24: char ry(); 25: char ty(); 26: 27: struct hnode { 28: char *aakey; 29: struct dict *aadata; 30: }; 31: char 32: aahash(s,ex,aatsize,aapr1,aapr2,tbl,data) 33: char *s; 34: struct hnode tbl[]; 35: struct dict *data; 36: { 37: char *cp; 38: int ii, key, c, p1, p2; 39: cp = s; 40: key =0; 41: while (c = *cp++) 42: key = key + (key<<5) + c; 43: key &= 077777; 44: p1 = key%aapr1; 45: p2 = key%aapr2; 46: if (p2==0) p2=17; 47: for(ii=0; ii<aatsize; ii++) 48: { 49: if (tbl[p1].aakey==0) 50: { /* new item */ 51: if (ex ==0) 52: { 53: tbl[p1].aakey = s; 54: tbl[p1].aadata= data; 55: return(tbl[p1].aadata->val); 56: } 57: else 58: return(0); 59: } 60: else 61: if(strcmp(tbl[p1].aakey, s)== 0) 62: { 63: return(tbl[p1].aadata->val); 64: } 65: p1 = (p1+p2)%aatsize; 66: } 67: fprintf(stderr, "hash table full:size %d\n",aatsize); 68: exit(); 69: } 70: getd(){ 71: struct dict *ptr; 72: ptr = dict; 73: while(ptr->entry != 0){ 74: lookup(ptr->entry,0,ptr); 75: ptr++; 76: } 77: } 78: getab(){ 79: struct dict *ptr; 80: ptr = abbrev_d; 81: while(ptr->entry != 0){ 82: abbrev(ptr->entry,0,ptr); 83: ptr++; 84: } 85: } 86: 87: struct hnode aa1root[499]; 88: #define aa1tsize 499 89: #define aa1p1 487 90: #define aa1p2 491 91: char 92: lookup(a0,a1,ptr) 93: char *a0; 94: struct dict *ptr; 95: { 96: return(aahash(a0,a1,aa1tsize,aa1p1,aa1p2,aa1root,ptr)); 97: } 98: struct hnode aa6root[113]; 99: #define aa6tsize 113 100: #define aa6p1 107 101: #define aa6p2 109 102: char 103: ary(a0,a1,ptr) 104: char *a0; 105: struct dict *ptr; 106: { 107: return(aahash(a0,a1,aa6tsize,aa6p1,aa6p2,aa6root,ptr)); 108: } 109: struct hnode aa9root[13]; 110: #define aa9tsize 13 111: #define aa9p1 7 112: #define aa9p2 1 113: char 114: cy(a0,a1,ptr) 115: char *a0; 116: struct dict *ptr; 117: { 118: return(aahash(a0,a1,aa9tsize,aa9p1,aa9p2,aa9root,ptr)); 119: } 120: struct hnode aa12root[59]; 121: #define aa12tsize 59 122: #define aa12p1 47 123: #define aa12p2 43 124: char 125: ery(a0,a1,ptr) 126: char *a0; 127: struct dict *ptr; 128: { 129: return(aahash(a0,a1,aa12tsize,aa12p1,aa12p2,aa12root,ptr)); 130: } 131: struct hnode aa16root[23]; 132: #define aa16tsize 23 133: #define aa16p1 17 134: #define aa16p2 19 135: char 136: fy(a0,a1,ptr) 137: char *a0; 138: struct dict *ptr; 139: { 140: return(aahash(a0,a1,aa16tsize,aa16p1,aa16p2,aa16root,ptr)); 141: } 142: struct hnode aa17root[29]; 143: #define aa17tsize 29 144: #define aa17p1 19 145: #define aa17p2 23 146: char 147: gy(a0,a1,ptr) 148: char *a0; 149: struct dict *ptr; 150: { 151: return(aahash(a0,a1,aa17tsize,aa17p1,aa17p2,aa17root,ptr)); 152: } 153: struct hnode aa27root[11]; 154: #define aa27tsize 11 155: #define aa27p1 5 156: #define aa27p2 7 157: char 158: ity(a0,a1,ptr) 159: char *a0; 160: struct dict *ptr; 161: { 162: return(aahash(a0,a1,aa27tsize,aa27p1,aa27p2,aa27root,ptr)); 163: } 164: struct hnode aa32root[281]; 165: #define aa32tsize 281 166: #define aa32p1 271 167: #define aa32p2 277 168: char 169: ly(a0,a1,ptr) 170: char *a0; 171: struct dict *ptr; 172: { 173: return(aahash(a0,a1,aa32tsize,aa32p1,aa32p2,aa32root,ptr)); 174: } 175: struct hnode aa36root[59]; 176: #define aa36tsize 59 177: #define aa36p1 47 178: #define aa36p2 43 179: char 180: ory(a0,a1,ptr) 181: char *a0; 182: struct dict *ptr; 183: { 184: return(aahash(a0,a1,aa36tsize,aa36p1,aa36p2,aa36root,ptr)); 185: } 186: struct hnode aa38root[59]; 187: #define aa38tsize 59 188: #define aa38p1 47 189: #define aa38p2 53 190: char 191: ry(a0,a1,ptr) 192: char *a0; 193: struct dict *ptr; 194: { 195: return(aahash(a0,a1,aa38tsize,aa38p1,aa38p2,aa38root,ptr)); 196: } 197: struct hnode aa41root[127]; 198: #define aa41tsize 127 199: #define aa41p1 109 200: #define aa41p2 113 201: char 202: ty(a0,a1,ptr) 203: char *a0; 204: struct dict *ptr; 205: { 206: return(aahash(a0,a1,aa41tsize,aa41p1,aa41p2,aa41root,ptr)); 207: } 208: struct fandd { 209: char (*fun)(); 210: struct dict *yd; 211: } arr[] = { 212: ary, ary_d, 213: cy, cy_d, 214: ery, ery_d, 215: fy, fy_d, 216: gy, gy_d, 217: ity, ity_d, 218: ly, ly_d, 219: ory, ory_d, 220: ry, ry_d, 221: ty, ty_d, 222: 0, 0 223: }; 224: 225: ygetd(){ 226: struct fandd *ptr; 227: struct dict *pp; 228: ptr=arr; 229: while(ptr->fun != 0){ 230: pp = ptr->yd; 231: while(pp->entry != 0){ 232: (*ptr->fun)(pp->entry,0,pp); 233: pp++; 234: } 235: ptr++; 236: } 237: } 238: struct hnode aa42root[71]; 239: #define aa42tsize 71 240: #define aa42p1 61 241: #define aa42p2 67 242: char 243: abbrev(a0,a1,ptr) 244: char *a0; 245: struct dict *ptr; 246: { 247: return(aahash(a0,a1,aa42tsize,aa42p1,aa42p2,aa42root,ptr)); 248: }