Annotation of researchv10no/cmd/refer/update/runup8.c, revision 1.1

1.1     ! root        1: # include "runup.h"
        !             2: long *histrt, *hnstrt, *hnew;
        !             3: fixib()
        !             4: {
        !             5: /* straighten up ia, ib */
        !             6: FILE *fbo, *fbn, *fno, *ft;
        !             7: long getl(), mappos();
        !             8: int it, lgind, lgnn, nocc;
        !             9: int *hfreq, did1, did2;
        !            10: long l1, l2, nowat;
        !            11: struct bibfile *bp;
        !            12: struct newfile *np;
        !            13: if (chatty) printf("Alterations read\n");
        !            14: fbo = fopen("Ind.ib", "r");
        !            15: fbn = fopen("XInd.ib", "w");
        !            16: fno = fopen("NN.ib", "r");
        !            17: assert(fbo!=NULL); assert(fbn!=NULL); assert(fno!=NULL);
        !            18: /* read in old hash pointers */
        !            19: ft = fopen("Ind.ia", "r");
        !            20: it = getw(ft);
        !            21: assert(it==nhash);
        !            22: lgind = getw(ft);
        !            23: histrt= calloc(nhash, sizeof(long));
        !            24: for(it=0; it<nhash; it++)
        !            25:        histrt[it] = getl(ft);
        !            26: fclose(ft);
        !            27: /* read in supplementary hash pointers */
        !            28: ft = fopen("NN.ia", "r");
        !            29: it = getw(ft);
        !            30: assert(it==nhash);
        !            31: lgnn = getw(ft);
        !            32: hnstrt= calloc(nhash, sizeof(long));
        !            33: for(it=0; it<nhash; it++)
        !            34:        hnstrt[it] = getl(ft);
        !            35: fclose(ft);
        !            36: 
        !            37: # if D3
        !            38: /* temporarily, dump the NN hash file */
        !            39: for(it=0; it<nhash; it++)
        !            40:        {
        !            41:        fseek (fno, hnstrt[it], 0);
        !            42:        while ((l2 = lgnn ? getl(fno) : (long)(getw(fno)))>=0)
        !            43:                printf("hash %d in %ld\n",it, l2);
        !            44:        }
        !            45: # endif
        !            46: # if D1
        !            47: printf("in fixib, lgind %d lgnn %d lgout %d nhash %d\n",lgind,lgnn,lgout, nhash);
        !            48: # endif
        !            49: /* now read through the hash files */
        !            50: hnew = calloc(nhash, sizeof(long));
        !            51: hfreq = calloc(nhash, sizeof(int));
        !            52: nowat=0;
        !            53: for(it=0; it <nhash; it++)
        !            54:        {
        !            55:        if (verbose && (it%100)==0)
        !            56:                printf("at hash %d got %.1f of %d sec.\n", it, tuse(), tlapse());
        !            57:        fseek (fbo, histrt[it], 0);
        !            58:        fseek (fno, hnstrt[it], 0);
        !            59:        hnew[it]=nowat;
        !            60:        bp = bibs;
        !            61:        nocc = 0;
        !            62:        did1 = did2 = 0;
        !            63:        np = news;
        !            64:        l1 = lgind ? getl(fbo) : (long)(getw(fbo));
        !            65:        l2 = lgnn  ? getl(fno) : (long)(getw(fno));
        !            66:        if (l1 == -1 && l2 == -1) 
        !            67:                {
        !            68: # if D1
        !            69:                printf("  none at hash %d\n",it);
        !            70: # endif
        !            71:                if (nowat > 0)
        !            72:                        hnew[it] = nowat - (lgout ? 4 : 2);
        !            73:                else
        !            74:                        lgout ? putl(-1L,fbn) : putw(-1,fbn);
        !            75:                nowat =ftell(fbn);
        !            76:                hfreq[it] = 0;
        !            77:                continue;
        !            78:                }
        !            79: # if D1
        !            80:        printf("Seeding at hash %d l1 %ld l2 %ld\n",it,l1,l2);
        !            81: # endif
        !            82:        while (l1 != -1 || l2 != -1)
        !            83:                {
        !            84: # if D2
        !            85:                if(vhash==it) printf("loop: l1 %ld l2 %ld bp %d np %d\n",l1,l2,bp-bibs,np-news);
        !            86: # endif
        !            87:                if (l1>=0 && did1==0)
        !            88:                        {
        !            89:                        for (; bp->bibfno >=0 && bp->bibival<l1; bp++)
        !            90:                                ;
        !            91: # if D2
        !            92:                        if(vhash==it) printf("bp now %d\n",bp-bibs);
        !            93: # endif
        !            94:                        if (bp->bibfno >=0 && l1 == bp->bibival)
        !            95:                                {
        !            96: # if D2
        !            97:                                if(vhash==it) printf("Matched bibval, ignoring %ld\n",l1);
        !            98: # endif
        !            99:                                l1 = lgind ? getl(fbo) : (long)(getw(fbo));
        !           100:                                did1=0;
        !           101: # if D2
        !           102:                                if(vhash==it) printf("New l1 read as %ld\n",l1);
        !           103: # endif
        !           104:                                continue;
        !           105:                                }
        !           106:                        l1 = mappos(l1);
        !           107: # if D2
        !           108:                        if(vhash==it) printf("after mappos offset l1 %ld\n",l1);
        !           109: # endif
        !           110:                        if (l1>=ins1) l1 += add;
        !           111: # if D2
        !           112:                        if(vhash==it) printf("l1 finally is %ld\n",l1);
        !           113: # endif
        !           114:                        did1=1;
        !           115:                        }
        !           116:                if (l2>=0 && did2==0)
        !           117:                        {
        !           118:                        for(; np->nn_ic>=0 && np->nn_ic < l2; np++);
        !           119:                        l2 = np->new_ic;
        !           120: # if D2
        !           121:                        if(vhash==it) printf("np at %d l2 now %ld\n",np-news,l2);
        !           122: # endif
        !           123:                        if (l2>=ins2) l2 += add;
        !           124: # if D2
        !           125:                        if(vhash==it) printf("l2 finally is %ld\n",l2);
        !           126: # endif
        !           127:                        did2=1;
        !           128:                        }
        !           129:                if (l1 >=0 && (l2 == -1 || l1<l2))
        !           130:                        {
        !           131: # if D2
        !           132:                        if(vhash==it) printf("Writing l1 %ld not l2 %ld lgout %d\n",l1,l2,lgout);
        !           133: # endif
        !           134:                        lgout ? putl(l1,fbn) : putw((int)l1,fbn);
        !           135:                        l1 = lgind ? getl(fbo) : (long)(getw(fbo));
        !           136:                        did1=0;
        !           137: # if D2
        !           138:                        if(vhash==it) printf("New l1 is %ld\n",l1);
        !           139: # endif
        !           140:                        nocc++;
        !           141:                        continue;
        !           142:                        }
        !           143:                if (l2 >= 0 && (l1 == -1 || l2<l1))
        !           144:                        {
        !           145: # if D2
        !           146:                        if(vhash==it) printf("Writing l2 %ld not l1 %ld lgout %d \n",l2,l1,lgout);
        !           147: # endif
        !           148:                        lgout ? putl(l2,fbn) : putw((int)l2,fbn);
        !           149:                        l2 = lgnn ? getl(fno) : (long)(getw(fno));
        !           150: # if D2
        !           151:                        if(vhash==it) printf("New l2 %ld\n",l2);
        !           152: # endif
        !           153:                        did2=0;
        !           154:                        nocc++;
        !           155:                        continue;
        !           156:                        }
        !           157: # if D1
        !           158:        printf("bad case l1 %ld l2 %ld\n",l1,l2);
        !           159: # endif
        !           160:                assert(0);
        !           161:                }
        !           162:        lgout ? putl(-1L, fbn) : putw(-1, fbn);
        !           163:        nowat = ftell(fbn);
        !           164:        hfreq[it] = nocc;
        !           165:        }
        !           166: fclose(fbn);
        !           167: fbn = fopen("XInd.ia", "w");
        !           168: assert(fbn!=NULL);
        !           169: putw(nhash, fbn);
        !           170: putw(lgout, fbn);
        !           171: for(it=0; it<nhash; it++)
        !           172:        putl(hnew[it], fbn);
        !           173: for(it=0; it<nhash; it++)
        !           174:        putw(hfreq[it], fbn);
        !           175: fclose(fbn);
        !           176: }
        !           177: long
        !           178: getl(f)
        !           179:        FILE *f;
        !           180: {
        !           181: long in;
        !           182: int j;
        !           183: j = fread(&in, sizeof(long), 1, f);
        !           184: if (j<=0) return(-1L);
        !           185: return(in);
        !           186: }
        !           187: putl(l, f)
        !           188:        long l;
        !           189:        FILE *f;
        !           190: {
        !           191: int i,j;
        !           192: i = l>>16;
        !           193: j = l;
        !           194: putw(i,f);
        !           195: putw(j,f);
        !           196: }

unix.superglobalmegacorp.com

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