|
|
1.1 ! root 1: # include "runup.h" ! 2: sortbib() ! 3: { ! 4: struct bibfile *bibp; ! 5: extern int comp(), exch(); ! 6: int nb; ! 7: for(bibp=bibs; bibp->bibfno>=0; bibp++) ! 8: ; ! 9: nb=bibp-bibs; ! 10: shell(nb, comp, exch); ! 11: # if D1 ! 12: printf("sorted %d bibs\n", nb); ! 13: { ! 14: struct bibfile *bp; ! 15: for(bp=bibs; bp->bibfno>=0; bp++) ! 16: printf(" bib%03d\n",bp->bibfno); ! 17: } ! 18: # endif ! 19: } ! 20: comp(i,j) ! 21: { ! 22: int k; ! 23: k = strcmp(bibs[i].bibfref, bibs[j].bibfref); ! 24: if (k!=0) return(k<0); ! 25: if (bibs[i].bibfstrt == bibs[j].bibfstrt) ! 26: { ! 27: fprintf(stderr, "Error: files bib%03d and bib%03d are redundant\n",bibs[i].bibfno, bibs[j].bibfno); ! 28: unlock(); ! 29: exit(1); ! 30: } ! 31: return(bibs[i].bibfstrt-bibs[j].bibfstrt<0); ! 32: } ! 33: exch(i,j) ! 34: { ! 35: struct bibfile tb; ! 36: tb=bibs[i]; ! 37: bibs[i]=bibs[j]; ! 38: bibs[j]=tb; ! 39: } ! 40: # define NMV 100 ! 41: # define NB 1000 ! 42: char *tomove[NMV]; ! 43: int nm = 0; ! 44: char nmbuff[NB]; ! 45: char *nbmp = nmbuff; ! 46: svmove(s) ! 47: char *s; ! 48: { ! 49: int i; ! 50: for(i=0;i<nm;i++) ! 51: if (strcmp(tomove[i], s)==SAME) ! 52: return; ! 53: tomove[nm++] = nbmp; ! 54: while (*nbmp++ = *s++); ! 55: assert(nbmp<nmbuff+NB); ! 56: assert(nm<NMV); ! 57: return; ! 58: } ! 59: remove() ! 60: { ! 61: int i; ! 62: struct bibfile *bp; ! 63: char newver[100]; ! 64: unlink("XXIND"); ! 65: for(i=0; i<nm; i++) ! 66: { ! 67: sprintf(newver, "%s.x", tomove[i]); ! 68: if (access(newver, 4)!=0) ! 69: continue; ! 70: unlink(tomove[i]); ! 71: link(newver, tomove[i]); ! 72: unlink(newver); ! 73: } ! 74: unlink("Ind.ia"); link("XInd.ia", "Ind.ia"); unlink("XInd.ia"); ! 75: unlink("Ind.ib"); link("XInd.ib", "Ind.ib"); unlink("XInd.ib"); ! 76: unlink("Ind.ic"); link("XInd.ic", "Ind.ic"); unlink("XInd.ic"); ! 77: unlink("NN.ia"); unlink ("NN.ib"); unlink("NN.ic"); ! 78: chdir (rundir); ! 79: for (bp=bibs; bp->bibfno>=0; bp++) ! 80: { ! 81: sprintf(newver, "bib%03d", bp->bibfno); ! 82: unlink(newver); ! 83: } ! 84: } ! 85: ! 86: garbage() ! 87: { ! 88: /* called on interrupt only */ ! 89: int i; ! 90: char newver[100]; ! 91: fprintf(stderr, "Interrupt.\n"); ! 92: for (i=0; i<nm; i++) ! 93: unlink(sprintf(newver, "%s.x", tomove[i])); ! 94: unlink("XInd.ia"); unlink("XInd.ib"); unlink("XInd.ic"); ! 95: unlink("XXIND"); ! 96: unlink("NN.ia"); unlink("NN.ib"); unlink("NN.ic"); ! 97: unlink(sprintf(newver, "%s.x", newplace)); /* other */ ! 98: unlock(); ! 99: exit(1); ! 100: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.