Bell 32V development
authorTom London <tbl@research.uucp>
Tue, 23 Jan 1979 01:01:55 +0000 (20:01 -0500)
committerTom London <tbl@research.uucp>
Tue, 23 Jan 1979 01:01:55 +0000 (20:01 -0500)
Work on file usr/src/cmd/refer/inv6.c

Co-Authored-By: John Reiser <jfr@research.uucp>
Synthesized-from: 32v

usr/src/cmd/refer/inv6.c [new file with mode: 0644]

diff --git a/usr/src/cmd/refer/inv6.c b/usr/src/cmd/refer/inv6.c
new file mode 100644 (file)
index 0000000..99dd21f
--- /dev/null
@@ -0,0 +1,73 @@
+# include "stdio.h"
+# include "assert.h"
+whash(ft, fa, fb, nhash, iflong, ptotct, phused)
+       FILE *fa, *fb, *ft;
+       int nhash, *phused;
+       long *ptotct;
+{
+char line[100];
+int hash = 0, hused = 0;
+long totct = 0L;
+int ct = 0;
+long point;
+long opoint = -1;
+int m;
+int k; long lp;
+long *hpt;
+int *hfreq = NULL;
+
+hpt = calloc (nhash+1, sizeof(*hpt));
+_assert (hpt != NULL);
+hfreq = calloc (nhash, sizeof(*hfreq));
+_assert (hfreq !=NULL);
+hpt[0] = 0;
+lp= 0;
+while (fgets(line, 100, ft))
+       {
+       totct++;
+       sscanf(line, "%d %ld", &k, &point);
+       if (hash < k)
+               {
+               hused++;
+               if (iflong) putl(-1L, fb); else putw(-1, fb);
+               hfreq[hash]=ct;
+               while (hash<k)
+                       {
+                       hpt[++hash] = lp;
+                       hfreq[hash] = 0;
+                       }
+               hpt[hash] = lp += iflong? sizeof(long) : sizeof(int);
+               opoint= -1;
+               ct=0;
+               }
+       if (point!=opoint)
+               {
+               if (iflong)
+                       putl(opoint=point, fb);
+               else
+                       putw( (int)(opoint=point), fb);
+               lp += iflong? sizeof(long) : sizeof(int);
+               ct++;
+               }
+       }
+if (iflong) putl(-1L, fb); else putw(-1,fb);
+while (hash<nhash)
+       hpt[++hash]=lp;
+fwrite(&nhash, sizeof(nhash), 1, fa);
+fwrite(&iflong, sizeof(iflong), 1, fa);
+fwrite(hpt, sizeof(*hpt), nhash, fa);
+fwrite (hfreq, sizeof(*hfreq), nhash, fa);
+*ptotct = totct;
+*phused = hused;
+}
+putl(ll, f)
+       long ll;
+       FILE *f;
+{
+putw(ll, f);
+}
+long getl(f)
+       FILE *f;
+{
+return(getw(f));
+}