Annotation of researchv8dc/cmd/spell/hashcheck.c, revision 1.1.1.1

1.1       root        1: /*     @(#)hashcheck.c 1.1     */
                      2: #include <stdio.h>
                      3: #include "hash.h"
                      4: long fetch();
                      5: unsigned short index[NI];
                      6: unsigned *table;
                      7: unsigned wp;
                      8: int bp;
                      9: #define U (BYTE*sizeof(unsigned))
                     10: #define L (BYTE*sizeof(long))
                     11: 
                     12: main()
                     13: {
                     14:        int i;
                     15:        long v;
                     16:        long a;
                     17:        extern char *malloc();
                     18:        rhuff(stdin);
                     19:        fread((char*)index, sizeof(*index), NI, stdin);
                     20:        table = (unsigned*)malloc(index[NI-1]*sizeof(*table));
                     21:        fread((char*)table, sizeof(*table), index[NI-1], stdin);
                     22:        for(i=0;i<NI-1;i++) {
                     23:                bp = U;
                     24:                v = (long)i<<(HASHWIDTH-INDEXWIDTH);
                     25:                for(wp=index[i];wp<index[i+1]; ) {
                     26:                        if(wp==index[i]&&bp==U)
                     27:                                a = fetch();
                     28:                        else {
                     29:                                a = fetch();
                     30:                                if(a==0)
                     31:                                        break;
                     32:                        }
                     33:                        if(wp>index[i+1]||
                     34:                                wp==index[i+1]&&bp<U)
                     35:                                break;
                     36:                        v += a;
                     37:                        printf("%.9lo\n",v);
                     38:                }
                     39:        }
                     40: }
                     41: 
                     42: long fetch()
                     43: {
                     44:        long w;
                     45:        long y = 0;
                     46:        int empty = L;
                     47:        int i = bp;
                     48:        int tp = wp;
                     49:        while(empty>=i) {
                     50:                empty -= i;
                     51:                i = U;
                     52:                y |= (long)table[tp++] << empty;
                     53:        }
                     54:        if(empty>0)
                     55:                y |= table[tp]>>i-empty;
                     56:        i = decode((y>>1)&((1L<<(BYTE*sizeof(y)-1))-1), &w);
                     57:        bp -= i;
                     58:        while(bp<=0) {
                     59:                bp += U;
                     60:                wp++;
                     61:        }
                     62:        return(w);
                     63: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.