Annotation of 3BSD/cmd/refer/refer7.c, revision 1.1.1.1

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

unix.superglobalmegacorp.com

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