From 47d72b2d6263508067c4532a16920991a64222a4 Mon Sep 17 00:00:00 2001 From: Tom London Date: Mon, 22 Jan 1979 07:29:58 -0500 Subject: [PATCH] Bell 32V development Work on file usr/src/cmd/refer/inv2.c Co-Authored-By: John Reiser Synthesized-from: 32v --- usr/src/cmd/refer/inv2.c | 90 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 usr/src/cmd/refer/inv2.c diff --git a/usr/src/cmd/refer/inv2.c b/usr/src/cmd/refer/inv2.c new file mode 100644 index 0000000000..a3f9e419df --- /dev/null +++ b/usr/src/cmd/refer/inv2.c @@ -0,0 +1,90 @@ +# include "stdio.h" +# include "assert.h" +newkeys (outf, inf, recf, nhash, fd, iflong) + FILE *outf, *inf, *recf, *fd; + int *iflong; +{ +/* reads key lines from inf; hashes and writes on outf; writes orig + key on recf, records pointer on outf too. + format of outf is : hash code space record pointer +*/ + +# define LINESIZ 1250 +long lp, ftell(); +long ld = 0; int ll = 0, lt = 0; +char line[LINESIZ]; +char key[30], bkeys[40]; +char *p, *s; +char *keyv[500]; +int i, nk, ndoc = 0, more = 0, c; + +lp = ftell (recf); +while (fgets(line, LINESIZ, inf)) + { + p = line; + while (*p != '\t') p++; + *p++ =0; + fputs(line, recf); + if (fd) + { + sprintf(bkeys, ";%ld", ld); + ll = strlen(p); + lt = strlen(bkeys); + fputs(bkeys, recf); + sprintf(bkeys, ",%d", ll); + lt += strlen(bkeys); + fputs(bkeys, recf); + ld += ll; + fputs(p, fd); + } + putc('\n',recf); + for(s=p; *s; s++); + if (*--s == '\n') + { + more=0; + *s=0; + } + else + more=1; + _assert (fd==0 || more==0); + nk = getargs(p, keyv); + if (more) + nk--; + for(i=0; ikey) + fprintf(outf, "%04d %06ld\n",hash(key)%nhash, lp); + s = key; + } + } + lp += (strlen(line)+lt+1); + ndoc++; + } +*iflong = (lp>=65536L); +if (sizeof(int)>2) *iflong=1; /* force long on VAX */ +fclose(recf); +return(ndoc); +} +trimnl(p) + char *p; +{ +while (*p) p++; +p--; +if (*p == '\n') *p=0; +} -- 2.20.1