|
|
1.1 ! root 1: #ifndef lint ! 2: static char *sccsid = "@(#)refer7.c 4.1 (Berkeley) 5/6/83"; ! 3: #endif ! 4: ! 5: #include "refer..c" ! 6: ! 7: int newr[250]; ! 8: ! 9: chkdup(tag) ! 10: char *tag; ! 11: { ! 12: int i; ! 13: ! 14: for(i = 1; i <= refnum; i++) { ! 15: if (strcmp(reftable[i], tag)==0) ! 16: return(i); ! 17: } ! 18: reftable[refnum+1] = rtp; ! 19: if (refnum >= NRFTBL) ! 20: err("too many references (%d) for table", refnum); ! 21: strcpy(rtp, tag); ! 22: while (*rtp++); ! 23: if (rtp > reftext + NRFTXT) ! 24: err("reference pointers too long (%d)", rtp-reftext); ! 25: return(0); ! 26: } ! 27: ! 28: dumpold() ! 29: { ! 30: FILE *fi; ! 31: int c, g1 = 0, nr = 1; ! 32: ! 33: if (!endpush) ! 34: return; ! 35: fclose(fo); ! 36: fo = NULL; ! 37: if (sort) { ! 38: char comm[100]; ! 39: sprintf(comm, "sort %s -o %s", tfile, tfile); ! 40: system(comm); ! 41: } ! 42: fi = fopen(tfile, "r"); ! 43: if (fi == NULL) ! 44: return; ! 45: flout(); ! 46: fprintf(ftemp, ".]<\n"); ! 47: while ((c = getc(fi)) > 0) { ! 48: if (c == '\n') { ! 49: nr++; ! 50: g1 = 0; ! 51: } ! 52: if (c == sep) ! 53: c = '\n'; ! 54: if (c == FLAG) { ! 55: /* make old-new ref number table */ ! 56: char tb[20]; ! 57: char *s = tb; ! 58: while ((c = getc(fi)) != FLAG) ! 59: *s++ = c; ! 60: *s = 0; ! 61: if (g1++ == 0) ! 62: newr[atoi(tb)] = nr; ! 63: #if EBUG ! 64: fprintf(stderr, ! 65: "nr %d assigned to atoi(tb) %d\n",nr,atoi(tb)); ! 66: # endif ! 67: fprintf(ftemp,"%d", nr); ! 68: continue; ! 69: } ! 70: putc(c, ftemp); ! 71: } ! 72: fclose(fi); ! 73: #ifndef TF ! 74: unlink(tfile); ! 75: #endif ! 76: fprintf(ftemp, ".]>\n"); ! 77: } ! 78: ! 79: recopy (fnam) ! 80: char *fnam; ! 81: { ! 82: int c; ! 83: ! 84: fclose(ftemp); ! 85: ftemp = fopen(fnam, "r"); ! 86: if (ftemp == NULL) { ! 87: fprintf(stderr, "Can't reopen %s\n", fnam); ! 88: exit(1); ! 89: } ! 90: while ((c = getc(ftemp)) != EOF) { ! 91: if (c == FLAG) { ! 92: char tb[10]; ! 93: char *s = tb; ! 94: while ((c = getc(ftemp)) != FLAG) ! 95: *s++ = c; ! 96: *s = 0; ! 97: printf("%d", newr[atoi(tb)]); ! 98: continue; ! 99: } ! 100: putchar(c); ! 101: } ! 102: fclose(ftemp); ! 103: unlink(fnam); ! 104: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.