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

1.1     ! root        1: # include "runup.h"
        !             2: # define NEWN 100
        !             3: # define NEWCH 2000
        !             4: struct newfile news[NEWN];
        !             5: int lgout;
        !             6: long ins1, ins2, add;
        !             7: append(argc,argv)
        !             8:        char *argv[];
        !             9: {
        !            10: FILE *foth, *fcp;
        !            11: int i;
        !            12: char ln[200], nfile [100];
        !            13: long mappos();
        !            14: if (argc<=1) return;
        !            15: sprintf(nfile, "%s.x", newplace);
        !            16: if (access(nfile,6)!=0)  /* not there */
        !            17:        {
        !            18:        fcp = fopen(newplace, "r");
        !            19:        foth = fopen(nfile, "w");
        !            20:        assert(fcp!=NULL);
        !            21:        assert(foth!=NULL);
        !            22:        copyn(fcp, foth, 9999999L);
        !            23:        fclose(fcp);
        !            24:        fclose(foth);
        !            25:        }
        !            26: foth = fopen(nfile, "a");
        !            27: svmove(newplace);
        !            28: assert(foth!=NULL);
        !            29: for(i=1; i<argc; i++)
        !            30:        {
        !            31:        if (chatty) printf("%s\n",argv[i]);
        !            32:        if (argv[i][0] =='/')
        !            33:                strcpy(ln, argv[i]);
        !            34:        else
        !            35:                sprintf(ln, "%s/%s", rundir, argv[i]);
        !            36:        fcp= fopen(ln,"r");
        !            37:        assert(fcp!=NULL);
        !            38:        while (fgets(ln, 200, fcp))
        !            39:                fputs(ln, foth);
        !            40:        if (ln[0] != '\n') fputs("\n",foth);
        !            41:        fclose(fcp);
        !            42:        }
        !            43: fclose(foth);
        !            44: }
        !            45: 
        !            46: /* fix up Ind.ic file: make table of NN->In correspondences */
        !            47: fixic()
        !            48: {
        !            49: FILE *fio, *fin, *fnn;
        !            50: char indln[100]; long ind_st; int ind_lg; char ind_nm[100];
        !            51: char nnln[100]; long nn_st; int nn_lg; char nn_nm[100];
        !            52: int bibno;
        !            53: long lother, posnnic, atol();
        !            54: struct newfile *newp;
        !            55: struct bibfile *bp;
        !            56: unlink("XXIND");
        !            57: link("XInd.ic", "XXIND");
        !            58: unlink("XInd.ic");
        !            59: fio = fopen("XXIND", "r");
        !            60: fin = fopen("XInd.ic", "w");
        !            61: fnn = fopen("NN.ic", "r");
        !            62: assert(fio!=NULL);
        !            63: assert(fin!=NULL);
        !            64: assert(fnn!=NULL);
        !            65: newp=news;
        !            66: /* copy Ind file up to last previous "other" entry */
        !            67: while (fgets(indln, 100, fio))
        !            68:        {
        !            69:        register char *s1, *s2;
        !            70:        /* sscanf(indln, "%[^:]:%ld,%d", ind_nm, &ind_st, &ind_lg); */
        !            71:        /* the previous line has been replaced for efficiency's sake */
        !            72:        s1 = ind_nm; s2 = indln;
        !            73:        while (*s2!=':') *s1++ = *s2++;
        !            74:        *s1=0;
        !            75:        ind_st = atol(++s2);
        !            76:        while (*s2++!=',');
        !            77:        ind_lg = atoi(s2);
        !            78:        if (bcmp (newplace, 999999L, ind_nm, ind_st) == '<')
        !            79:                break;
        !            80:        fputs(indln, fin);
        !            81:        lother = ind_st+ind_lg;
        !            82:        }
        !            83: # if D1
        !            84:        printf("last IND entry was %s lother %ld\n", indln, lother);
        !            85: # endif
        !            86: ins1=ftell(fin);
        !            87: for (posnnic=0; fgets(nnln, 100, fnn); posnnic = ftell(fnn))
        !            88:        {
        !            89:        register char *s1, *s2;
        !            90: # if D1
        !            91:        printf("Line from NN %s", nnln);
        !            92: # endif
        !            93:        /* sscanf(nnln, "%[^:]:%ld,%d", nn_nm, &nn_st, &nn_lg); */
        !            94:        /* the previous line has been replaced for efficiency's sake */
        !            95:        s1 = nn_nm; s2 = nnln;
        !            96:        while (*s2!=':') *s1++ = *s2++;
        !            97:        *s1=0;
        !            98:        nn_st = atol(++s2);
        !            99:        while (*s2++!=',');
        !           100:        nn_lg = atoi(s2);
        !           101:        if (sscanf(lastsl(nn_nm), "bib%d", &bibno)==1) /* bib file */
        !           102:                {
        !           103:                for(bp=bibs; bp->bibfno>=0; bp++)
        !           104:                        {
        !           105:                        if (bp->bibfno == bibno)
        !           106:                                {
        !           107:                                newp->nn_ic = posnnic;
        !           108:                                newp->new_ic = mappos(bp->bibival);
        !           109:                                newp++;
        !           110:                                assert (newp< news+NEWN);
        !           111:                                break;
        !           112:                                }
        !           113:                        }
        !           114: # if D1
        !           115:                printf("bib file no. %d is bp %d\n", bibno, bp-bibs);
        !           116: # endif
        !           117:                assert(bp->bibfno>=0);
        !           118:                }
        !           119:        else /* file added */
        !           120:                {
        !           121:                newp->nn_ic = posnnic;
        !           122:                newp->new_ic = ftell(fin);
        !           123:                fprintf(fin, "%s:%ld,%d\n", newplace, lother, nn_lg);
        !           124: # if D1
        !           125:                printf("new at lot %ld from nn.st %ld nn.lg %d\n",lother,nn_st, nn_lg);
        !           126:                printf("new mapped from %ld to %ld\n", posnnic, lother);
        !           127: # endif
        !           128:                newp++;
        !           129:                assert(newp<news+NEWN);
        !           130:                lother += nn_lg;
        !           131:                }
        !           132:        }
        !           133: add = ftell(fin)-ins1;
        !           134: ins2 = ftell(fin);
        !           135: # if D1
        !           136: printf("From %ld (file 1) or %ld (file2) add %ld\n",ins1,ins2,add);
        !           137: # endif
        !           138: newp->nn_ic= -1;
        !           139: /* copy rest of Ind file */
        !           140: fputs(indln, fin);
        !           141: while (fgets(indln, 100, fio))
        !           142:        {
        !           143:        fputs(indln, fin);
        !           144:        }
        !           145: # if D1
        !           146: for(newp=news; newp->nn_ic>=0; newp++)
        !           147:        printf("new map %ld to %ld\n",newp->nn_ic, newp->new_ic);
        !           148: # endif
        !           149: lgout = ftell(fin) > 65536L;
        !           150: fclose(fin);
        !           151: }
        !           152: 
        !           153: lastsl(s)
        !           154:        char *s;
        !           155: {
        !           156: char *p;
        !           157: for(p=s; *p; p++)
        !           158:        if (*p=='/')
        !           159:                s=p+1;
        !           160: return(s);
        !           161: }

unix.superglobalmegacorp.com

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