refer bugs

Rich Antonorsi{zz32ra ricardo at sdcc3.UUCP
Fri Dec 14 03:34:21 AEST 1984


Subject: refer does not work on the pyramids.  
Index:	/usr/src/usr.bin/refer 4.2BSD

Description:
	Refer does not work on the Pyramids. More specifically, it would
	core dump when creating the Index files ( using inv and mkey ).
Repeat-By:
	It fails intermitently.
		../refer/mkey $files | ../refer/inv -n $indexfiles
Fix:
	I have included a set of fixes. Some of them might not be completely
	neccessary, i.e some of the casting. I also added a summary list of
	the changes. The file hunt9.c can be deleted completely. I still haven't
	found a use for it. If you know of any please send me mail.


ADDBIB.c
********

got rid of unused variables : repeat and escape. Also defined correctly the
type of status as union wait. Some casting was done.
reset error on stdin after receiving EOF with clearerr(stdin).
=============================================================================

DELIV2.c
********

got rid of function zalloc() all together.... added parenthesis to the
hashing funcition to resolve ambiguities
=============================================================================

GLUE1.c
*******

changed  the zalloc() calls to be calloc() and did some casting
Reset usedir[] to find previously referenced items
=============================================================================

GLUE2.c
*******

defined status correctly as a union wait
=============================================================================

GLUE4.c
*******

got rid of *qf and int oldc that were never used.Some casting
=============================================================================

GLUE5.c
*******

got rid of zalloc() calls added some casting
=============================================================================

HUNT1.c
*******

redefined master so as to match the way it is passed as a parameter,i.e.
to be a union. Also initialized the variable falseflg =0 since it
was causing random behaviour on the pyramids. Some casting was also done
Missing parameter indexdate was added to the call to findline.
Reset usedir[] to find previously referenced items
=============================================================================

HUNT2.c
*******

changed zalloc() calls to be calloc() Also substituted prevcoord.b and .a
with prevdrop.b or .a since prevcoord does not have a .b or .a field.
Some casting
=============================================================================

HUNT5.c
*******

Modified master parameter to eliminate inconsistent declaration
resulting in an error in result routine on Pyramids.   RA/ss
=============================================================================

HUNT6.c
*******

got rid of variable got. Some casting
=============================================================================

INV1.c
******

Made sure that *fd got initialized before being passed to newkeys ( IMPORTANT )
deleted variable *ftc. Defined status correctly ( union wait)
Added the missing parameter 'nhash' to the call to recopy.
Changed the syscall mv with a faster rename
=============================================================================

INV5.c
******

made sure something was returned,i.e. return(nhash) was added
=============================================================================

INV6.c
******

got rid of variable 'm' some casting added
=============================================================================

MKEY2.c
*******

variable *p was redefining the global version of it. Substituted it with *w.
=============================================================================

REFER3.c
********

defined status correctly. Some casting was added.
=============================================================================

*** /tmp/,RCSt1012559	Thu Dec 13 08:39:06 1984
--- addbib.c	Tue Nov 20 09:27:12 1984
***************
*** 5,10
  #include <stdio.h>
  #include <ctype.h>
  #include <signal.h>
  #define MAXENT 50
  
  struct skeleton {

--- 5,11 -----
  #include <stdio.h>
  #include <ctype.h>
  #include <signal.h>
+ #include <sys/wait.h>
  #define MAXENT 50
  
  struct skeleton {
***************
*** 90,96
  char *argv;
  {
  	char line[BUFSIZ];
! 	int i = 0, firstln, repeat = 0, escape = 0;
  
  	printf("Instructions? ");
  	fgets(line, BUFSIZ, stdin);

--- 91,97 -----
  char *argv;
  {
  	char line[BUFSIZ];
! 	int i = 0, firstln;
  
  	printf("Instructions? ");
  	(void)fgets(line, BUFSIZ, stdin);
***************
*** 93,99
  	int i = 0, firstln, repeat = 0, escape = 0;
  
  	printf("Instructions? ");
! 	fgets(line, BUFSIZ, stdin);
  	if (line[0] == 'y' || line[0] == 'Y')
  		instruct();
  	while (1)

--- 94,100 -----
  	int i = 0, firstln;
  
  	printf("Instructions? ");
! 	(void)fgets(line, BUFSIZ, stdin);
  	if (line[0] == 'y' || line[0] == 'Y')
  		instruct();
  	while (1)
***************
*** 103,109
  		for (i = 0; i < entries; i++)
  		{
  			printf("%s\t", bibskel[i].prompt);
! 			fgets(line, BUFSIZ, stdin);
  			if (line[0] == '-' && line[1] == '\n')
  			{
  				i -= 2;

--- 104,110 -----
  		for (i = 0; i < entries; i++)
  		{
  			printf("%s\t", bibskel[i].prompt);
! 			(void)fgets(line, BUFSIZ, stdin);
  			if (line[0] == '-' && line[1] == '\n')
  			{
  				i -= 2;
***************
*** 126,132
  				}
  				printf("> ");
  				again:
! 				fgets(line, BUFSIZ, stdin);
  				if (line[strlen(line)-2] == '\\')
  				{
  					line[strlen(line)-2] = '\n';

--- 127,133 -----
  				}
  				printf("> ");
  				again:
! 				(void)fgets(line, BUFSIZ, stdin);
  				if (line[strlen(line)-2] == '\\')
  				{
  					line[strlen(line)-2] = '\n';
***************
*** 158,163
  				}
  				fputs(line, fp);
  			}
  		}
  		fflush(fp);	/* write to file at end of each cycle */
  		if (ferror(fp))

--- 159,165 -----
  				}
  				fputs(line, fp);
  			}
+ 			clearerr(stdin);
  		}
  		(void)fflush(fp);	/* write to file at end of each cycle */
  		if (ferror(fp))
***************
*** 159,165
  				fputs(line, fp);
  			}
  		}
! 		fflush(fp);	/* write to file at end of each cycle */
  		if (ferror(fp))
  		{
  			perror(argv);

--- 161,167 -----
  			}
  			clearerr(stdin);
  		}
! 		(void)fflush(fp);	/* write to file at end of each cycle */
  		if (ferror(fp))
  		{
  			perror(argv);
***************
*** 167,173
  		}
  		editloop:
  		printf("\nContinue? ");
! 			fgets(line, BUFSIZ, stdin);
  		if (line[0] == 'e' || line[0] == 'v')
  		{
  			bibedit(fp, line, argv);

--- 169,175 -----
  		}
  		editloop:
  		printf("\nContinue? ");
! 			(void)fgets(line, BUFSIZ, stdin);
  		if (line[0] == 'e' || line[0] == 'v')
  		{
  			bibedit(fp, line, argv);
***************
*** 197,203
  FILE *fp;
  char *cmd, *arg;
  {
! 	int i = 0, status;
  
  	fclose(fp);
  	while (!isspace(cmd[i]))

--- 199,206 -----
  FILE *fp;
  char *cmd, *arg;
  {
! 	int i = 0; 
! 	union wait status;
  
  	(void)fclose(fp);
  	while (!isspace(cmd[i]))
***************
*** 199,205
  {
  	int i = 0, status;
  
! 	fclose(fp);
  	while (!isspace(cmd[i]))
  		i++;
  	cmd[i] = NULL;

--- 202,208 -----
  	int i = 0; 
  	union wait status;
  
! 	(void)fclose(fp);
  	while (!isspace(cmd[i]))
  		i++;
  	cmd[i] = NULL;
***************
*** 210,220
  		else /* either ed, ex, or edit */
  			execlp(cmd, cmd, arg, NULL);
  	}
! 	signal(SIGINT, SIG_IGN);
! 	signal(SIGQUIT, SIG_IGN);
! 	wait(&status);
! 	signal(SIGINT, SIG_DFL);
! 	signal(SIGQUIT, SIG_DFL);
  	if ((fp = fopen(arg, "a")) == NULL)
  	{
  		perror(arg);

--- 213,223 -----
  		else /* either ed, ex, or edit */
  			execlp(cmd, cmd, arg, NULL);
  	}
! 	(void)signal(SIGINT, SIG_IGN);
! 	(void)signal(SIGQUIT, SIG_IGN);
! 	(void)wait(&status);
! 	(void)signal(SIGINT, SIG_DFL);
! 	(void)signal(SIGQUIT, SIG_DFL);
  	if ((fp = fopen(arg, "a")) == NULL)
  	{
  		perror(arg);
***************
*** 274,278
  		}
  	}
  	entries = entry;
! 	fclose(pfp);
  }

--- 277,281 -----
  		}
  	}
  	entries = entry;
! 	(void)fclose(pfp);
  }

*** /tmp/,RCSt1012575	Thu Dec 13 08:40:12 1984
--- deliv2.c	Tue Nov 20 10:08:15 1984
***************
*** 9,15
  {
  	int c, n;
  	for(n=0; c= *s; s++)
! 		n += (c*n+ c << (n%4));
  	return(n>0 ? n : -n);
  }
  

--- 9,16 -----
  {
  	int c, n;
  	for(n=0; c= *s; s++)
! 		n += ( (c*n + c) << (n%4));
! 
  	return(n>0 ? n : -n);
  }
  
***************
*** 15,20
  
  err (s, a)
  char *s;
  {
  	fprintf(stderr, "Error: ");
  	fprintf(stderr, s, a);

--- 16,22 -----
  
  err (s, a)
  char *s;
+ char *a;
  {
  	fprintf(stderr, "Error: ");
  	fprintf(stderr, s, a);
***************
*** 41,58
  		if (*p ==c)
  			return(p);
  	return(0);
- }
- 
- zalloc(m,n)
- {
- 	char *calloc();
- 	int t;
- # if D1
- 	fprintf(stderr, "calling calloc for %d*%d bytes\n",m,n);
- # endif
- 	t = (int) calloc(m,n);
- # if D1
- 	fprintf(stderr, "calloc returned %o\n", t);
- # endif
- 	return(t);
  }

--- 43,46 -----
  		if (*p ==c)
  			return(p);
  	return(0);
  }

*** /tmp/,RCSt1012586	Thu Dec 13 08:40:58 1984
--- glue1.c	Tue Nov 20 09:29:26 1984
***************
*** 6,11
  #define unopen(fil) {if (fil!=NULL) {fclose(fil); fil=NULL;}}
  
  extern char refdir[];
  int lmaster = 1000;
  int reached = 0;
  FILE *fd = 0;

--- 6,12 -----
  #define unopen(fil) {if (fil!=NULL) {fclose(fil); fil=NULL;}}
  
  extern char refdir[];
+ extern char *calloc();
  int lmaster = 1000;
  int reached = 0;
  FILE *fd = 0;
***************
*** 18,23
  int iflong;
  extern char *fgnames[], **fgnamp;
  extern FILE *iopen();
  char *todir();
  int prfreqs = 0;
  int typeindex = 0;

--- 19,25 -----
  int iflong;
  extern char *fgnames[], **fgnamp;
  extern FILE *iopen();
+ extern int atoi();
  char *todir();
  int prfreqs = 0;
  int typeindex = 0;
***************
*** 76,82
  			argc--; 
  			argv++;
  			soutput = argv[1];
! 			if (argv[2]<16000)
  			{
  				soutlen = argv[2];
  				argc--; 

--- 78,84 -----
  			argc--; 
  			argv++;
  			soutput = argv[1];
! 			if ((int)argv[2] < 16000)
  			{
  				soutlen = (int)argv[2];
  				argc--; 
***************
*** 78,84
  			soutput = argv[1];
  			if (argv[2]<16000)
  			{
! 				soutlen = argv[2];
  				argc--; 
  				argv++;
  			}

--- 80,86 -----
  			soutput = argv[1];
  			if ((int)argv[2] < 16000)
  			{
! 				soutlen = (int)argv[2];
  				argc--; 
  				argv++;
  			}
***************
*** 87,93
  			argc--; 
  			argv++;
  			tagout = argv[1];
! 			if (argv[2]<16000)
  			{
  				taglen = argv[2];
  				argc--; 

--- 89,95 -----
  			argc--; 
  			argv++;
  			tagout = argv[1];
! 			if ((int)argv[2] < 16000)
  			{
  				taglen = (int)argv[2];
  				argc--; 
***************
*** 89,95
  			tagout = argv[1];
  			if (argv[2]<16000)
  			{
! 				taglen = argv[2];
  				argc--; 
  				argv++;
  			}

--- 91,97 -----
  			tagout = argv[1];
  			if ((int)argv[2] < 16000)
  			{
! 				taglen = (int)argv[2];
  				argc--; 
  				argv++;
  			}
***************
*** 140,146
  			if (nhash > maxhash)
  			{
  				if (hpt)
! 					free (hpt, maxhash, sizeof(*hpt));
  				hpt=0;
  				if (hfreq)
  					free(hfreq, maxhash, sizeof(*hfreq));

--- 142,148 -----
  			if (nhash > maxhash)
  			{
  				if (hpt)
! 					free (hpt);
  				hpt=0;
  				if (hfreq)
  					free(hfreq);
***************
*** 143,149
  					free (hpt, maxhash, sizeof(*hpt));
  				hpt=0;
  				if (hfreq)
! 					free(hfreq, maxhash, sizeof(*hfreq));
  				hfreq=0;
  				maxhash=nhash;
  # if D1

--- 145,151 -----
  					free (hpt);
  				hpt=0;
  				if (hfreq)
! 					free(hfreq);
  				hfreq=0;
  				maxhash=nhash;
  # if D1
***************
*** 151,157
  # endif
  			}
  			if (hpt==0)
! 				hpt = zalloc(nhash, sizeof(*hpt));
  # if D1
  			fprintf(stderr, "hpt now %o\n",hpt);
  # endif

--- 153,159 -----
  # endif
  			}
  			if (hpt==0)
! 				hpt = ( long *)calloc(nhash, sizeof(*hpt));
  # if D1
  			fprintf(stderr, "hpt now %o\n",hpt);
  # endif
***************
*** 159,165
  				err ("No space for hash list (%d)", nhash);
  			fread( hpt, sizeof(*hpt), nhash, fa);
  			if (hfreq==0)
! 				hfreq=zalloc(nhash, sizeof(*hfreq));
  			if (hfreq==NULL)
  				err ("No space for hash frequencies (%d)", nhash);
  			frtbl = fread(hfreq, sizeof(*hfreq), nhash, fa);

--- 161,167 -----
  				err ("No space for hash list (%d)", nhash);
  			fread( hpt, sizeof(*hpt), nhash, fa);
  			if (hfreq==0)
! 				hfreq=( int *)calloc(nhash, sizeof(*hfreq));
  			if (hfreq==NULL)
  				err ("No space for hash frequencies (%d)", nhash);
  			frtbl = fread(hfreq, sizeof(*hfreq), nhash, fa);
***************
*** 169,175
  # endif
  			if (master.a == NULL)
  				if (iflong)
! 					master.b = zalloc(lmaster, sizeof(long));
  				else
  					master.a = zalloc(lmaster, sizeof(int));
  			if (master.a == NULL)

--- 171,177 -----
  # endif
  			if (master.a == NULL)
  				if (iflong)
! 					master.b = ( long *)calloc(lmaster, sizeof(long));
  				else
  					master.a = ( unsigned *)calloc(lmaster, sizeof(int));
  			if (master.a == NULL)
***************
*** 171,177
  				if (iflong)
  					master.b = zalloc(lmaster, sizeof(long));
  				else
! 					master.a = zalloc(lmaster, sizeof(int));
  			if (master.a == NULL)
  				err ("no space for answer list",0);
  		}

--- 173,179 -----
  				if (iflong)
  					master.b = ( long *)calloc(lmaster, sizeof(long));
  				else
! 					master.a = ( unsigned *)calloc(lmaster, sizeof(int));
  			if (master.a == NULL)
  				err ("no space for answer list",0);
  		}
***************
*** 252,257
  char *t;
  {
  	char *s;
  	s=t;
  	while (*s) s++;
  	while (s>=t && *s != '/') s--;

--- 254,262 -----
  char *t;
  {
  	char *s;
+ 
+ 	usedir[0] = 0;	/*	Patch from CATT -- jbb	*/
+ 
  	s=t;
  	while (*s) s++;
  	while (s>=t && *s != '/') s--;

*** /tmp/,RCSt1012613	Thu Dec 13 08:41:59 1984
--- glue3.c	Tue Nov 20 09:53:12 1984
***************
*** 3,8
  #endif
  
  #include "refer..c"
  #define move(x, y) close(y); dup(x); close(x);
  
  corout(in, out, rprog, arg, outlen)

--- 3,10 -----
  #endif
  
  #include "refer..c"
+ #include <sys/wait.h>
+ 
  #define move(x, y) close(y); dup(x); close(x);
  
  corout(in, out, rprog, arg, outlen)
***************
*** 6,12
  #define move(x, y) close(y); dup(x); close(x);
  
  corout(in, out, rprog, arg, outlen)
! char *in, *out, *rprog;
  {
  	int pipev[2], fr1, fr2, fw1, fw2, n;
  

--- 8,15 -----
  #define move(x, y) close(y); dup(x); close(x);
  
  corout(in, out, rprog, arg, outlen)
! char *in, *out, *rprog, *arg;
! int outlen;
  {
  	int pipev[2], fr1, fr2, fw1, fw2, n;
  
***************
*** 14,20
  		return(callhunt(in, out, arg, outlen));
  	if (strcmp (rprog, "deliv")==0)
  		return(dodeliv(in, out, arg, outlen));
! 	pipe (pipev); 
  	fr1= pipev[0]; 
  	fw1 = pipev[1];
  	pipe (pipev); 

--- 17,23 -----
  		return(callhunt(in, out, arg, outlen));
  	if (strcmp (rprog, "deliv")==0)
  		return(dodeliv(in, out, arg, outlen));
! 	(void)pipe (pipev); 
  	fr1= pipev[0]; 
  	fw1 = pipev[1];
  	pipe (pipev); 
***************
*** 22,29
  	fw2 = pipev[1];
  	if (fork()==0)
  	{
! 		close (fw1); 
! 		close (fr2);
  		move (fr1, 0);
  		move (fw2, 1);
  		if (rprog[0]!= '/')

--- 25,32 -----
  	fw2 = pipev[1];
  	if (fork()==0)
  	{
! 		(void)close (fw1); 
! 		(void)close (fr2);
  		move (fr1, 0);
  		move (fw2, 1);
  		if (rprog[0]!= '/')
***************
*** 27,33
  		move (fr1, 0);
  		move (fw2, 1);
  		if (rprog[0]!= '/')
! 			chdir("/usr/lib/refer");
  		execl(rprog, "deliv", arg, 0);
  		err ("Can't run %s", rprog);
  	}

--- 30,36 -----
  		move (fr1, 0);
  		move (fw2, 1);
  		if (rprog[0]!= '/')
! 			(void)chdir("/usr/lib/refer");
  		execl(rprog, "deliv", arg, 0);
  		err ("Can't run %s", rprog);
  	}
***************
*** 31,41
  		execl(rprog, "deliv", arg, 0);
  		err ("Can't run %s", rprog);
  	}
! 	close(fw2); 
! 	close(fr1);
! 	write (fw1, in , strlen(in));
! 	close(fw1);
! 	wait(0);
  	n = read (fr2, out, outlen);
  	out[n]=0;
  	close(fr2);

--- 34,44 -----
  		execl(rprog, "deliv", arg, 0);
  		err ("Can't run %s", rprog);
  	}
! 	(void)close(fw2); 
! 	(void)close(fr1);
! 	(void)write (fw1, in , strlen(in));
! 	(void)close(fw1);
! 	(void)wait(( union wait *)0);
  	n = read (fr2, out, outlen);
  	out[n]=0;
  	(void)close(fr2);
***************
*** 38,44
  	wait(0);
  	n = read (fr2, out, outlen);
  	out[n]=0;
! 	close(fr2);
  }
  
  # define ALEN 50

--- 41,47 -----
  	(void)wait(( union wait *)0);
  	n = read (fr2, out, outlen);
  	out[n]=0;
! 	(void)close(fr2);
  }
  
  # define ALEN 50
***************
*** 45,50
  
  callhunt(in, out, arg, outlen)
  char *in, *out, *arg;
  {
  	char *argv[20], abuff[ALEN];
  	extern int typeindex;

--- 48,54 -----
  
  callhunt(in, out, arg, outlen)
  char *in, *out, *arg;
+ int outlen;
  {
  	char *argv[20], abuff[ALEN];
  	extern int typeindex;
***************
*** 49,54
  	char *argv[20], abuff[ALEN];
  	extern int typeindex;
  	int argc;
  	extern char one[];
  	extern int onelen;
  	argv[0] = "hunt";

--- 53,59 -----
  	char *argv[20], abuff[ALEN];
  	extern int typeindex;
  	int argc;
+ 	extern char *strcpy();
  	extern char one[];
  	extern int onelen;
  
***************
*** 51,56
  	int argc;
  	extern char one[];
  	extern int onelen;
  	argv[0] = "hunt";
  	argv[1] = "-i";
  	argv[2] = in;

--- 56,62 -----
  	extern char *strcpy();
  	extern char one[];
  	extern int onelen;
+ 
  	argv[0] = "hunt";
  	argv[1] = "-i";
  	argv[2] = in;
***************
*** 63,69
  	argv[9] = one;
  	argv[10] = onelen;
  	argv[11] = abuff; 
! 	strcpy (abuff,arg);
  	if (strlen(abuff) > ALEN)
  		err("abuff not big enough %d", strlen(abuff));
  	argc = 6;

--- 69,75 -----
  	argv[9] = one;
  	argv[10] = onelen;
  	argv[11] = abuff; 
! 	(void)strcpy (abuff,arg);
  	if (strlen(abuff) > ALEN)
  		err("abuff not big enough %d", strlen(abuff));
  	argc = 6;
***************
*** 73,78
  
  dodeliv(in, out, arg, outlen)
  char *in, *out, *arg;
  {
  # if D1
  	fprintf(stderr, "in dodeliv, arg /%s/\n", arg?arg:"");

--- 79,85 -----
  
  dodeliv(in, out, arg, outlen)
  char *in, *out, *arg;
+ int outlen;
  {
  # if D1
  	fprintf(stderr, "in dodeliv, arg /%s/\n", arg?arg:"");
***************
*** 78,84
  	fprintf(stderr, "in dodeliv, arg /%s/\n", arg?arg:"");
  # endif
  	if (arg && arg[0])
! 		chdir(arg);
  	findline(in, out, outlen, 0L);
  	restodir();
  }

--- 85,91 -----
  	fprintf(stderr, "in dodeliv, arg /%s/\n", arg?arg:"");
  # endif
  	if (arg && arg[0])
! 		(void)chdir(arg);
  	findline(in, out, outlen, 0L);
  	restodir();
  	return(0);
***************
*** 81,84
  		chdir(arg);
  	findline(in, out, outlen, 0L);
  	restodir();
  }

--- 88,92 -----
  		(void)chdir(arg);
  	findline(in, out, outlen, 0L);
  	restodir();
+ 	return(0);
  }

*** /tmp/,RCSt1012624	Thu Dec 13 08:42:47 1984
--- glue4.c	Tue Nov 20 09:54:17 1984
***************
*** 11,18
  	char line[200], *s, argig[100], *cv[50];
  	char *inp, inb[500];
  	extern char gfile[];
! 	FILE *qf, *gf;
! 	int c, oldc = 0, alph = 0, nv = 0;
  	int sv0, sv1;
  	strcpy (argig, arg); 
  	strcat(argig, ".ig");

--- 11,19 -----
  	char line[200], *s, argig[100], *cv[50];
  	char *inp, inb[500];
  	extern char gfile[];
! 	extern char *strcpy();
! 	FILE *gf;
! 	int c, alph = 0, nv = 0;
  	int sv0, sv1;
  
  	(void)strcpy (argig, arg); 
***************
*** 14,22
  	FILE *qf, *gf;
  	int c, oldc = 0, alph = 0, nv = 0;
  	int sv0, sv1;
! 	strcpy (argig, arg); 
! 	strcat(argig, ".ig");
! 	strcpy (inp=inb, in);
  	if (gfile[0]==0)
  		sprintf(gfile, "/tmp/rj%dg", getpid());
  # if D1

--- 15,24 -----
  	FILE *gf;
  	int c, alph = 0, nv = 0;
  	int sv0, sv1;
! 
! 	(void)strcpy (argig, arg); 
! 	(void)strcat(argig, ".ig");
! 	(void)strcpy (inp=inb, in);
  	if (gfile[0]==0)
  		(void)sprintf(gfile, "/tmp/rj%dg", getpid());
  # if D1
***************
*** 18,24
  	strcat(argig, ".ig");
  	strcpy (inp=inb, in);
  	if (gfile[0]==0)
! 		sprintf(gfile, "/tmp/rj%dg", getpid());
  # if D1
  	fprintf(stderr, "in grepcall, gfile %s in %o out %o\n", gfile,in,out);
  # endif

--- 20,26 -----
  	(void)strcat(argig, ".ig");
  	(void)strcpy (inp=inb, in);
  	if (gfile[0]==0)
! 		(void)sprintf(gfile, "/tmp/rj%dg", getpid());
  # if D1
  	fprintf(stderr, "in grepcall, gfile %s in %o out %o\n", gfile,in,out);
  # endif
***************
*** 33,39
  			cv[nv++] = inp;
  		if (alph > 6)
  			*inp = 0;
- 		oldc=c;
  	}
  # if D1
  	fprintf(stderr, "%d args set up\n", nv);

--- 35,40 -----
  			cv[nv++] = inp;
  		if (alph > 6)
  			*inp = 0;
  	}
  # if D1
  	fprintf(stderr, "%d args set up\n", nv);
***************
*** 40,46
  # endif
  	{
  		sv0 = dup(0);
! 		close(0);
  		if (open (argig, 0) != 0)
  			err("Can't read fgrep index %s", argig);
  		sv1 = dup(1);

--- 41,47 -----
  # endif
  	{
  		sv0 = dup(0);
! 		(void)close(0);
  		if (open (argig, 0) != 0)
  			err("Can't read fgrep index %s", argig);
  		sv1 = dup(1);
***************
*** 44,50
  		if (open (argig, 0) != 0)
  			err("Can't read fgrep index %s", argig);
  		sv1 = dup(1);
! 		close(1);
  		if (creat(gfile, 0666) != 1)
  			err("Can't write fgrep output %s", gfile);
  		fgrep(nv, cv);

--- 45,51 -----
  		if (open (argig, 0) != 0)
  			err("Can't read fgrep index %s", argig);
  		sv1 = dup(1);
! 		(void)close(1);
  		if (creat(gfile, 0666) != 1)
  			err("Can't write fgrep output %s", gfile);
  		fgrep(nv, cv);
***************
*** 51,62
  # if D1
  		fprintf(stderr, "fgrep returned, output is..\n");
  # endif
! 		close (0); 
! 		dup(sv0); 
! 		close(sv0);
! 		close (1); 
! 		dup(sv1); 
! 		close(sv1);
  	}
  
  # if D1

--- 52,63 -----
  # if D1
  		fprintf(stderr, "fgrep returned, output is..\n");
  # endif
! 		(void)close (0); 
! 		(void)dup(sv0); 
! 		(void)close(sv0);
! 		(void)close (1); 
! 		(void)dup(sv1); 
! 		(void)close(sv1);
  	}
  
  # if D1
***************
*** 78,84
  			*s++ = 0;
  		}
  		if (line[0])
! 			strcat(out, line);
  # if D1
  		fprintf(stderr, "out now /%s/\n",out);
  # endif

--- 79,85 -----
  			*s++ = 0;
  		}
  		if (line[0])
! 			(void)strcat(out, line);
  # if D1
  		fprintf(stderr, "out now /%s/\n",out);
  # endif
***************
*** 89,95
  		if (s[-1]!= '\n')
  			while (!feof(gf) && getc(gf)!= '\n') ;
  	}
! 	fclose(gf);
  # if D1
  	fprintf(stderr, "back from reading %, out %s\n",out);
  # else

--- 90,96 -----
  		if (s[-1]!= '\n')
  			while (!feof(gf) && getc(gf)!= '\n') ;
  	}
! 	(void)fclose(gf);
  # if D1
  	fprintf(stderr, "back from reading %, out %s\n",out);
  # else
***************
*** 93,99
  # if D1
  	fprintf(stderr, "back from reading %, out %s\n",out);
  # else
! 	unlink (gfile);
  # endif
  	return(0);
  }

--- 94,100 -----
  # if D1
  	fprintf(stderr, "back from reading %, out %s\n",out);
  # else
! 	(void)unlink (gfile);
  # endif
  	return(0);
  }
***************
*** 101,105
  clfgrep()
  {
  	if (gfile[0])
! 		unlink(gfile);
  }

--- 102,106 -----
  clfgrep()
  {
  	if (gfile[0])
! 		(void)unlink(gfile);
  }

*** /tmp/,RCSt1012647	Thu Dec 13 08:43:19 1984
--- glue5.c	Tue Nov 20 09:55:23 1984
***************
*** 34,39
  int	numwords;
  int	nfound;
  static int flag = 0;
  
  fgrep(argc, argv)
  char **argv;

--- 34,40 -----
  int	numwords;
  int	nfound;
  static int flag = 0;
+ extern char *calloc();
  
  fgrep(argc, argv)
  char **argv;
***************
*** 41,47
  	instr = nsucc = need = inct = rflag = numwords = nfound = 0;
  	flag = 0;
  	if (www==0)
! 		www = zalloc(MAXSIZ, sizeof (*www));
  	if (www==NULL)
  		err("Can't get space for machines", 0);
  	for (q=www; q<www+MAXSIZ; q++) {

--- 42,48 -----
  	instr = nsucc = need = inct = rflag = numwords = nfound = 0;
  	flag = 0;
  	if (www==0)
! 		www = (struct words *)calloc(MAXSIZ, sizeof (struct words));
  	if (www==NULL)
  		err("Can't get space for machines", 0);
  	for (q=www; q<www+MAXSIZ; q++) {
***************
*** 73,79
  		}
  	if (xargc<=0)
  		{
! 		write (2, "bad fgrep call\n", 15);
  		exit(2);
  		}
  # if D1

--- 74,80 -----
  		}
  	if (xargc<=0)
  		{
! 		(void)write (2, "bad fgrep call\n", 15);
  		exit(2);
  		}
  # if D1
***************
*** 142,148
  fprintf(stderr, "roaming along in ex ch %c c %o\n",ch,c);
  # endif
  		if (isupper(ch)) ch |= 040;
! 		if (c->inp == ch) {
  			c = c->nst;
  		}
  		else if (c->link != 0) {

--- 143,149 -----
  fprintf(stderr, "roaming along in ex ch %c c %o\n",ch,c);
  # endif
  		if (isupper(ch)) ch |= 040;
! 		if (c->inp == ch) 
  			c = c->nst;
  
  		else if (c->link != 0) 
***************
*** 144,151
  		if (isupper(ch)) ch |= 040;
  		if (c->inp == ch) {
  			c = c->nst;
! 		}
! 		else if (c->link != 0) {
  			c = c->link;
  			goto nstate;
  		}

--- 145,153 -----
  		if (isupper(ch)) ch |= 040;
  		if (c->inp == ch) 
  			c = c->nst;
! 
! 		else if (c->link != 0) 
! 		{
  			c = c->link;
  			goto nstate;
  		}
***************
*** 198,204
  # if D2
  fprintf(stderr, "p %o nlp %o buf %o\n",p,nlp,buf);
  if (p>nlp)
! {write (2, "XX\n", 3); write (2, nlp, p-nlp); write (2, "XX\n", 3);}
  # endif
  					if (p > nlp) write(1, nlp, p-nlp);
  					else {

--- 200,209 -----
  # if D2
  fprintf(stderr, "p %o nlp %o buf %o\n",p,nlp,buf);
  if (p>nlp)
! {
!   (void)write (2, "XX\n", 3); 
!   (void)write (2, nlp, p-nlp); 
!   (void)write (2, "XX\n", 3);}
  # endif
  					if (p > nlp) (void)write(1, nlp, p-nlp);
  					else {
***************
*** 200,206
  if (p>nlp)
  {write (2, "XX\n", 3); write (2, nlp, p-nlp); write (2, "XX\n", 3);}
  # endif
! 					if (p > nlp) write(1, nlp, p-nlp);
  					else {
  						write(1, nlp, &buf[2*BUFSIZ] - nlp);
  						write(1, buf, p-&buf[0]);

--- 205,211 -----
    (void)write (2, nlp, p-nlp); 
    (void)write (2, "XX\n", 3);}
  # endif
! 					if (p > nlp) (void)write(1, nlp, p-nlp);
  					else {
  						(void)write(1, nlp, &buf[2*BUFSIZ] - nlp);
  						(void)write(1, buf, p-&buf[0]);
***************
*** 202,209
  # endif
  					if (p > nlp) write(1, nlp, p-nlp);
  					else {
! 						write(1, nlp, &buf[2*BUFSIZ] - nlp);
! 						write(1, buf, p-&buf[0]);
  						}
  					if (p[-1]!= '\n') write (1, "\n", 1);
  					}

--- 207,214 -----
  # endif
  					if (p > nlp) (void)write(1, nlp, p-nlp);
  					else {
! 						(void)write(1, nlp, &buf[2*BUFSIZ] - nlp);
! 						(void)write(1, buf, p-&buf[0]);
  						}
  					if (p[-1]!= '\n') (void)write (1, "\n", 1);
  					}
***************
*** 205,211
  						write(1, nlp, &buf[2*BUFSIZ] - nlp);
  						write(1, buf, p-&buf[0]);
  						}
! 					if (p[-1]!= '\n') write (1, "\n", 1);
  					}
  				if (instr==0)
  					{

--- 210,216 -----
  						(void)write(1, nlp, &buf[2*BUFSIZ] - nlp);
  						(void)write(1, buf, p-&buf[0]);
  						}
! 					if (p[-1]!= '\n') (void)write (1, "\n", 1);
  					}
  				if (instr==0)
  					{
***************
*** 289,294
  	{
  		flag=1;
  		s = *xargv++;
  # if D1
  	fprintf(stderr, "next arg is %s xargc %d\n",s,xargc);
  # endif

--- 294,300 -----
  	{
  		flag=1;
  		s = *xargv++;
+ 		if (xargc-- <=0) return(0);
  # if D1
  	fprintf(stderr, "next arg is %s xargc %d\n",s,xargc);
  # endif
***************
*** 292,298
  # if D1
  	fprintf(stderr, "next arg is %s xargc %d\n",s,xargc);
  # endif
- 		if (xargc-- <=0) return(0);
  	}
  	if (*s) return(*s++);
  	for(flag=0; flag<2*BUFSIZ; flag++)

--- 298,303 -----
  # if D1
  	fprintf(stderr, "next arg is %s xargc %d\n",s,xargc);
  # endif
  	}
  	if (*s) return(*s++);
  	for(flag=0; flag<2*BUFSIZ; flag++)
***************
*** 302,308
  }
  
  overflo() {
! 	write(2,"wordlist too large\n", 19);
  	exit(2);
  }
  cfail() {

--- 307,313 -----
  }
  
  overflo() {
! 	(void)write(2,"wordlist too large\n", 19);
  	exit(2);
  }
  cfail() {

*** /tmp/,RCSt1012654	Thu Dec 13 08:43:51 1984
--- hunt1.c	Tue Nov 20 09:31:51 1984
***************
*** 4,10
  
  # include <stdio.h>
  # include <assert.h>
! extern char refdir[];
  extern int keepold;
  extern char *fgnames[];
  extern char **fgnamp;

--- 4,10 -----
  
  # include <stdio.h>
  # include <assert.h>
! 
  extern int keepold;
  extern char *fgnames[];
  extern char **fgnamp;
***************
*** 8,13
  extern int keepold;
  extern char *fgnames[];
  extern char **fgnamp;
  FILE *fd =NULL;
  int lmaster =500;
  int *hfreq, hfrflg;

--- 8,17 -----
  extern int keepold;
  extern char *fgnames[];
  extern char **fgnamp;
+ 
+ extern char *strcpy(),*strcat();
+ extern int  strlen();
+ 
  FILE *fd =NULL;
  int lmaster =500;
  int *hfreq, hfrflg;
***************
*** 12,17
  int lmaster =500;
  int *hfreq, hfrflg;
  int colevel =0;
  int measure=0;
  int soutlen =1000;
  int reached =0;

--- 16,23 -----
  int lmaster =500;
  int *hfreq, hfrflg;
  int colevel =0;
+ char gfile[50];
+ int reached = 0;
  int measure=0;
  int soutlen =1000;
  int iflong =0;
***************
*** 14,20
  int colevel =0;
  int measure=0;
  int soutlen =1000;
- int reached =0;
  int iflong =0;
  int prfreqs =0;
  char usedir[100];

--- 20,25 -----
  int reached = 0;
  int measure=0;
  int soutlen =1000;
  int iflong =0;
  int prfreqs =0;
  char usedir[100];
***************
*** 18,26
  int iflong =0;
  int prfreqs =0;
  char usedir[100];
! char * calloc(); 
! char * todir();
! char gfile[50];
  static int full =1000;
  static int tags =0;
  char *sinput, *soutput, *tagout;

--- 23,30 -----
  int iflong =0;
  int prfreqs =0;
  char usedir[100];
! char *calloc(); 
! char *todir();
  static int full =1000;
  static int tags =0;
  char *sinput, *soutput, *tagout;
***************
*** 36,41
  	static char oldname[30] ;
  	static int was =0;
  	/* these pointers are unions of pointer to int and pointer to long */
  	long *hpt;
  	unsigned *master =0;
  	int falseflg, nhash, nitem, nfound, frtbl, kk;

--- 40,46 -----
  	static char oldname[30] ;
  	static int was =0;
  	/* these pointers are unions of pointer to int and pointer to long */
+ 
  	long *hpt;
  
  	/*
***************
*** 37,44
  	static int was =0;
  	/* these pointers are unions of pointer to int and pointer to long */
  	long *hpt;
- 	unsigned *master =0;
- 	int falseflg, nhash, nitem, nfound, frtbl, kk;
  
  	/* special wart for refpart: default is tags only */
  

--- 42,47 -----
  	/* these pointers are unions of pointer to int and pointer to long */
  
  	long *hpt;
  
  	/*
  	 * redefined master so as to match the way it is declared in the
***************
*** 40,45
  	unsigned *master =0;
  	int falseflg, nhash, nitem, nfound, frtbl, kk;
  
  	/* special wart for refpart: default is tags only */
  
  	while (argv[1][0] == '-')

--- 43,64 -----
  
  	long *hpt;
  
+ 	/*
+ 	 * redefined master so as to match the way it is declared in the
+ 	 * functions to which it is passed as param.
+ 	 * Introduced a flag to check for initialization.
+ 	 * unsigned *master = 0   could not be used anymore
+ 	 */
+ 
+ 	union ptr {
+ 		unsigned *a;
+ 		long     *b;
+ 	} master ;
+ 	int master_flag = 0 ;
+ 
+ 	int falseflg = 0 ;
+ 	int nhash, nitem, nfound, frtbl, kk;
+ 
  	/* special wart for refpart: default is tags only */
  
  	while (argv[1][0] == '-')
***************
*** 70,76
  			argc--; 
  			argv++;
  			soutput = argv[1];
! 			if (argv[2]<16000)
  			{
  				soutlen = (int)argv[2];
  				argc--; 

--- 89,95 -----
  			argc--; 
  			argv++;
  			soutput = argv[1];
! 			if ( (int)argv[2] < 16000)
  			{
  				soutlen = (int)argv[2];
  				argc--; 
***************
*** 106,112
  		argc--; 
  		argv++;
  	}
! 	strcpy (nma, todir(argv[1]));
  	if (was == 0 || strcmp (oldname, nma) !=0)
  	{
  		strcpy (oldname,nma);

--- 125,131 -----
  		argc--; 
  		argv++;
  	}
! 	(void)strcpy (nma, todir(argv[1]));
  	if (was == 0 || strcmp (oldname, nma) !=0)
  	{
  		(void)strcpy (oldname,nma);
***************
*** 109,122
  	strcpy (nma, todir(argv[1]));
  	if (was == 0 || strcmp (oldname, nma) !=0)
  	{
! 		strcpy (oldname,nma);
! 		strcpy (nmb, nma); 
! 		strcpy (nmc, nmb); 
! 		strcpy(nmd,nma);
! 		strcat (nma, ".ia");
! 		strcat (nmb, ".ib");
! 		strcat (nmc, ".ic");
! 		strcat (nmd, ".id");
  		if (was)
  		{
  			fclose(fa); 

--- 128,141 -----
  	(void)strcpy (nma, todir(argv[1]));
  	if (was == 0 || strcmp (oldname, nma) !=0)
  	{
! 		(void)strcpy (oldname,nma);
! 		(void)strcpy (nmb, nma); 
! 		(void)strcpy (nmc, nmb); 
! 		(void)strcpy(nmd,nma);
! 		(void)strcat (nma, ".ia");
! 		(void)strcat (nmb, ".ib");
! 		(void)strcat (nmc, ".ic");
! 		(void)strcat (nmd, ".id");
  		if (was)
  		{
  			(void)fclose(fa); 
***************
*** 119,127
  		strcat (nmd, ".id");
  		if (was)
  		{
! 			fclose(fa); 
! 			fclose(fb); 
! 			fclose(fc);
  		}
  
  		fa = fopen(nma, "r");

--- 138,146 -----
  		(void)strcat (nmd, ".id");
  		if (was)
  		{
! 			(void)fclose(fa); 
! 			(void)fclose(fb); 
! 			(void)fclose(fc);
  		}
  
  		fa = fopen(nma, "r");
***************
*** 127,133
  		fa = fopen(nma, "r");
  		if (fa==NULL)
  		{
! 			strcpy(*fgnamp++ = calloc(strlen(oldname)+2,1), oldname);
  			fb=NULL;
  			goto search;
  		}

--- 146,152 -----
  		fa = fopen(nma, "r");
  		if (fa==NULL)
  		{
! 			(void)strcpy(*fgnamp++ = calloc((unsigned)strlen(oldname)+2,1), oldname);
  			fb=NULL;
  			goto search;
  		}
***************
*** 142,153
  		indexdate = gdate(fb);
  		fd = fopen(nmd, "r");
  	}
! 	fseek (fa, 0L, 0);
! 	fread (&nhash, sizeof(nhash), 1, fa);
! 	fread (&iflong, sizeof(iflong), 1, fa);
! 	if(master==0)
! 		master = calloc (lmaster, iflong? 4: 2);
! 	hpt = calloc(nhash, sizeof(*hpt));
  	kk=fread( hpt, sizeof(*hpt), nhash, fa);
  # if D1
  	fprintf(stderr,"read %d hashes, iflong %d, nhash %d\n", kk, iflong, nhash);

--- 161,184 -----
  		indexdate = gdate(fb);
  		fd = fopen(nmd, "r");
  	}
! 	(void)fseek (fa, 0L, 0);
! 	(void)fread (&nhash, sizeof(nhash), 1, fa);
! 	(void)fread (&iflong, sizeof(iflong), 1, fa);
! 
! 	/*
! 	 * check for initialization of master
! 	 */
! 
! 	if(master_flag == 0 )
! 	{
! 		if ( iflong )
! 			master.b = (long *) calloc((unsigned)lmaster,sizeof(long));
! 		else
! 			master.a = ( unsigned *) calloc((unsigned)lmaster,sizeof(unsigned));
! 
! 		master_flag = 1 ;
! 	}
! 	hpt = ( long *)calloc((unsigned)nhash, sizeof(*hpt));
  	kk=fread( hpt, sizeof(*hpt), nhash, fa);
  # if D1
  	fprintf(stderr,"read %d hashes, iflong %d, nhash %d\n", kk, iflong, nhash);
***************
*** 153,159
  	fprintf(stderr,"read %d hashes, iflong %d, nhash %d\n", kk, iflong, nhash);
  # endif
  	_assert (kk==nhash);
! 	hfreq = calloc(nhash, sizeof(*hfreq));
  	_assert (hfreq != NULL);
  	frtbl = fread(hfreq, sizeof(*hfreq), nhash, fa);
  	hfrflg = (frtbl == nhash);

--- 184,190 -----
  	fprintf(stderr,"read %d hashes, iflong %d, nhash %d\n", kk, iflong, nhash);
  # endif
  	_assert (kk==nhash);
! 	hfreq = (int *)calloc((unsigned)nhash, sizeof(*hfreq));
  	_assert (hfreq != NULL);
  	frtbl = fread(hfreq, sizeof(*hfreq), nhash, fa);
  	hfrflg = (frtbl == nhash);
***************
*** 192,199
  			grepquery[0]=0;
  			for(k=0; k<nitem; k++)
  			{
! 				strcat(grepquery, " ");
! 				strcat(grepquery, qitem[k]);
  			}
  # if D1
  			fprintf(stderr, "grepquery %s\n",grepquery);

--- 223,230 -----
  			grepquery[0]=0;
  			for(k=0; k<nitem; k++)
  			{
! 				(void)strcat(grepquery, " ");
! 				(void)strcat(grepquery, qitem[k]);
  			}
  # if D1
  			fprintf(stderr, "grepquery %s\n",grepquery);
***************
*** 225,231
  							tagp++;
  						if (*tagp)
  							tagp++;
! 						findline(oldtagp, bout, 1000);
  						fputs(bout,stdout);
  					}
  				}

--- 256,262 -----
  							tagp++;
  						if (*tagp)
  							tagp++;
! 						findline(oldtagp, bout, 1000,indexdate);
  						fputs(bout,stdout);
  					}
  				}
***************
*** 242,247
  char *t;
  {
  	char *s;
  	s=t;
  	while (*s) s++;
  	while (s>=t && *s != '/') s--;

--- 273,281 -----
  char *t;
  {
  	char *s;
+ 
+ 	usedir[0] = 0;	/*	Patch from CATT -- jbb	*/
+ 
  	s=t;
  	while (*s) s++;
  	while (s>=t && *s != '/') s--;
***************
*** 248,255
  	if (s<t) return(t);
  	*s++ = 0;
  	t = (*t ? t : "/");
! 	chdir (t);
! 	strcpy (usedir,t);
  	return(s);
  }
  setfrom(c)

--- 282,289 -----
  	if (s<t) return(t);
  	*s++ = 0;
  	t = (*t ? t : "/");
! 	(void)chdir (t);
! 	(void)strcpy (usedir,t);
  	return(s);
  }
  setfrom(c)

*** /tmp/,RCSt1012673	Thu Dec 13 08:45:25 1984
--- hunt2.c	Tue Nov 20 09:57:18 1984
***************
*** 7,12
  static int *coord = 0;
  int hh[50]; 
  extern int *hfreq, hfrflg, hcomp(), hexch();
  extern int prfreqs;
  
  doquery(hpt, nhash, fb, nitem, qitem, master)

--- 7,13 -----
  static int *coord = 0;
  int hh[50]; 
  extern int *hfreq, hfrflg, hcomp(), hexch();
+ extern char *calloc();
  extern int prfreqs;
  
  doquery(hpt, nhash, fb, nitem, qitem, master)
***************
*** 11,16
  
  doquery(hpt, nhash, fb, nitem, qitem, master)
  long *hpt;
  FILE *fb;
  char *qitem[];
  union ptr {

--- 12,18 -----
  
  doquery(hpt, nhash, fb, nitem, qitem, master)
  long *hpt;
+ int nhash;
  FILE *fb;
  int nitem;
  char *qitem[];
***************
*** 12,17
  doquery(hpt, nhash, fb, nitem, qitem, master)
  long *hpt;
  FILE *fb;
  char *qitem[];
  union ptr {
  	unsigned *a; 

--- 14,20 -----
  long *hpt;
  int nhash;
  FILE *fb;
+ int nitem;
  char *qitem[];
  union ptr {
  	unsigned *a; 
***************
*** 35,41
  # endif
  	_assert (lmaster>0);
  	if (coord==0)
! 		coord = zalloc(lmaster, sizeof(lmaster));
  	if (colevel>0)
  	{
  		prevdrop.a=zalloc(lmaster,iflong?sizeof(long): sizeof(int));

--- 38,44 -----
  # endif
  	_assert (lmaster>0);
  	if (coord==0)
! 		coord = (int *)calloc((unsigned)lmaster, (unsigned)sizeof(lmaster));
  	if (colevel>0)
  	{
  		prevdrop.a= (unsigned *)calloc((unsigned)lmaster,iflong?(unsigned)sizeof(long): (unsigned)sizeof(int));
***************
*** 38,45
  		coord = zalloc(lmaster, sizeof(lmaster));
  	if (colevel>0)
  	{
! 		prevdrop.a=zalloc(lmaster,iflong?sizeof(long): sizeof(int));
! 		prevcoord = zalloc(lmaster, sizeof(lmaster));
  	}
  	else
  	{

--- 41,48 -----
  		coord = (int *)calloc((unsigned)lmaster, (unsigned)sizeof(lmaster));
  	if (colevel>0)
  	{
! 		prevdrop.a= (unsigned *)calloc((unsigned)lmaster,iflong?(unsigned)sizeof(long): (unsigned)sizeof(int));
! 		prevcoord = ( int *)calloc((unsigned)lmaster, (unsigned)sizeof(lmaster));
  	}
  	else
  	{
***************
*** 77,82
  	_assert (fseek(fb,lp,0)==NULL);
  	for(i=0; i<lmaster; i++)
  	{
  		if (iflong)
  			master.b[i] = getl(fb);
  		else

--- 80,90 -----
  	_assert (fseek(fb,lp,0)==NULL);
  	for(i=0; i<lmaster; i++)
  	{
+ 		/*
+ 		 * this section was core-dumping on pyramids
+ 		 * the fixture in hunt1.c got rid of this problem
+ 		 */
+ 
  		if (iflong)
  			master.b[i] = getl(fb);
  		else
***************
*** 95,101
  		}
  		else
  		{
! 			if (master.a[i] == -1) break;
  		}
  	}
  	nf= i;

--- 103,109 -----
  		}
  		else
  		{
! 			if ((int)master.a[i] == -1) break;
  		}
  	}
  	nf= i;
***************
*** 126,132
  			if (iflong)
  				k = getl(fb);
  			else
! 				k = getw(fb);
  			if (k== -1) break;
  # if D2
  			fprintf(stderr,"next term finds %ld\n",k);

--- 134,140 -----
  			if (iflong)
  				k = getl(fb);
  			else
! 		        k = getw(fb);
  			if (k== -1) break;
  # if D2
  			fprintf(stderr,"next term finds %ld\n",k);
***************
*** 172,178
  				if (iflong)
  					master.b[g]=k;
  				else
! 					master.a[g]=k;
  				coord[g++] = prevcoord[j++]+1;
  # if D1
  				if (iflong)

--- 180,186 -----
  				if (iflong)
  					master.b[g]=k;
  				else
! 					master.a[g]=( unsigned )k;
  				coord[g++] = prevcoord[j++]+1;
  # if D1
  				if (iflong)
***************
*** 187,193
  					if (iflong)
  						master.b[g]=k;
  					else
! 						master.a[g]=k;
  					coord[g++] = 1;
  				}
  		}

--- 195,201 -----
  					if (iflong)
  						master.b[g]=k;
  					else
! 						master.a[g]=(unsigned)k;
  					coord[g++] = 1;
  				}
  		}
***************
*** 196,202
  # endif
  		if (colevel>0)
  			for ( ; j<nf; j++)
! 				if ((iflong?prevcoord.b[j]:prevcoord.a[j])+colevel > nterm)
  				{
  					_assert(g<lmaster);
  					if (iflong)

--- 204,210 -----
  # endif
  		if (colevel>0)
  			for ( ; j<nf; j++)
! 				if ((iflong?prevdrop.b[j]:prevdrop.a[j])+colevel > nterm)
  				{
  					_assert(g<lmaster);
  					if (iflong)
***************
*** 240,247
  # endif
  	if (colevel)
  	{
! 		free(prevdrop, lmaster, iflong?sizeof(long): sizeof(int));
! 		free(prevcoord, lmaster, sizeof (lmaster));
  	}
  # if D3
  	for(g=0;g<nf;g++)

--- 248,255 -----
  # endif
  	if (colevel)
  	{
! 		free(prevdrop);
! 		free(prevcoord);
  	}
  # if D3
  	for(g=0;g<nf;g++)
***************
*** 257,263
  getl(fb)
  FILE *fb;
  {
! 	return(getw(fb));
  }
  
  putl(ll, f)

--- 265,271 -----
  getl(fb)
  FILE *fb;
  {
! 	return((long)getw(fb));
  }
  
  putl(ll, f)
***************
*** 264,270
  long ll;
  FILE *f;
  {
! 	putw(ll, f);
  }
  
  hcomp( n1, n2)

--- 272,278 -----
  long ll;
  FILE *f;
  {
! 	(void)putw(ll, f);
  }
  
  hcomp( n1, n2)

*** /tmp/,RCSt1012726	Thu Dec 13 08:48:08 1984
--- hunt5.c	Mon Nov 19 17:41:44 1984
***************
*** 12,18
  union ptr {
  	unsigned *a; 
  	long *b;
! } *master;
  FILE *fc;
  {
  	int i, c;

--- 12,18 -----
  union ptr {
  	unsigned *a; 
  	long *b;
! } master;
  FILE *fc;
  {
  	int i, c;
***************
*** 21,26
  	extern int iflong;
  	char res[100];
  
  	for(i=0; i<nf; i++)
  	{
  		lp = iflong ? master.b[i] : master.a[i];

--- 21,29 -----
  	extern int iflong;
  	char res[100];
  
+ #ifdef EBUG
+ fprintf(stderr, "entering result\n");
+ #endif
  	for(i=0; i<nf; i++)
  	{
  #ifdef EBUG
***************
*** 23,28
  
  	for(i=0; i<nf; i++)
  	{
  		lp = iflong ? master.b[i] : master.a[i];
  		fseek(fc,lp, 0);
  		fgets(res, 100, fc);

--- 26,34 -----
  #endif
  	for(i=0; i<nf; i++)
  	{
+ #ifdef EBUG
+ fprintf(stderr, "i=%d, iflong=%d\n", i, iflong);
+ #endif
  		lp = iflong ? master.b[i] : master.a[i];
  #ifdef EBUG
  fprintf(stderr, "lp=%ld\n", lp);
***************
*** 24,29
  	for(i=0; i<nf; i++)
  	{
  		lp = iflong ? master.b[i] : master.a[i];
  		fseek(fc,lp, 0);
  		fgets(res, 100, fc);
  		for(s=res; c = *s; s++)

--- 30,38 -----
  fprintf(stderr, "i=%d, iflong=%d\n", i, iflong);
  #endif
  		lp = iflong ? master.b[i] : master.a[i];
+ #ifdef EBUG
+ fprintf(stderr, "lp=%ld\n", lp);
+ #endif
  		fseek(fc,lp, 0);
  		fgets(res, 100, fc);
  		for(s=res; c = *s; s++)
***************
*** 32,37
  				*s=0;
  				break;
  			}
  		if (tagout !=0)
  		{
  			if (res[0]=='/' || usedir[0]==0)

--- 41,49 -----
  				*s=0;
  				break;
  			}
+ #ifdef EBUG
+ fprintf(stderr, "result:%s\n", res);
+ #endif
  		if (tagout !=0)
  		{
  			if (res[0]=='/' || usedir[0]==0)

*** /tmp/,RCSt1012739	Thu Dec 13 08:48:49 1984
--- hunt6.c	Tue Nov 20 09:58:32 1984
***************
*** 8,13
  
  char *outbuf = 0;
  extern char *soutput;
  extern int soutlen, iflong;
  extern long indexdate;
  

--- 8,14 -----
  
  char *outbuf = 0;
  extern char *soutput;
+ extern char *strcpy();
  extern int soutlen, iflong;
  extern long indexdate;
  
***************
*** 21,27
  char *qitem[], *rprog;
  {
  	/* checks list of drops for real bad drops; finds items with "deliv" */
! 	int i, g, j, need, got, na, len;
  	long lp;
  	char res[100], *ar[50], output[TXTLEN];
  	extern int colevel, reached;

--- 22,28 -----
  char *qitem[], *rprog;
  {
  	/* checks list of drops for real bad drops; finds items with "deliv" */
! 	int i, g, j, need, na, len;
  	long lp;
  	char res[100], *ar[50], output[TXTLEN];
  	extern int colevel, reached;
***************
*** 44,51
  			fprintf(stderr, "i %d master %o lp %lo\n",
  				i, master.a[i], lp);
  # endif
! 		fseek (fc, lp, 0);
! 		fgets( res, 100, fc);
  # if D1
  		fprintf(stderr, "tag %s", res);
  # endif

--- 45,52 -----
  			fprintf(stderr, "i %d master %o lp %lo\n",
  				i, master.a[i], lp);
  # endif
! 		(void)fseek (fc, lp, 0);
! 		(void)fgets( res, 100, fc);
  # if D1
  		fprintf(stderr, "tag %s", res);
  # endif
***************
*** 64,70
  					break;
  				}
  			len = rprog ?
! 			corout (res, output, rprog, 0, TXTLEN) :
  			findline (res, output, TXTLEN, indexdate);
  		}
  # if D1

--- 65,71 -----
  					break;
  				}
  			len = rprog ?
! 			corout (res, output, rprog, (char *)0, TXTLEN) :
  			findline (res, output, TXTLEN, indexdate);
  		}
  # if D1
***************
*** 100,106
  				master.a[g++] = master.a[i];
  			if (full >= g)
  				if (soutput==0)
! 					fputs(output, stdout);
  				else
  					strcpy (soutput, output);
  		}

--- 101,107 -----
  				master.a[g++] = master.a[i];
  			if (full >= g)
  				if (soutput==0)
! 					(void)fputs(output, stdout);
  				else
  					(void)strcpy (soutput, output);
  		}
***************
*** 102,108
  				if (soutput==0)
  					fputs(output, stdout);
  				else
! 					strcpy (soutput, output);
  		}
  # ifdef D1
  		fprintf(stderr, "after fgrep\n");

--- 103,109 -----
  				if (soutput==0)
  					(void)fputs(output, stdout);
  				else
! 					(void)strcpy (soutput, output);
  		}
  # ifdef D1
  		fprintf(stderr, "after fgrep\n");

*** /tmp/,RCSt1012801	Thu Dec 13 08:51:48 1984
--- inv1.c	Wed Nov 21 13:26:24 1984
***************
*** 4,9
  
  #include <stdio.h>
  #include <assert.h>
  
  main(argc, argv)
  char *argv[];

--- 4,10 -----
  
  #include <stdio.h>
  #include <assert.h>
+ #include <sys/wait.h>
  
  extern char *strcpy(),*strcat();
  
***************
*** 5,10
  #include <stdio.h>
  #include <assert.h>
  
  main(argc, argv)
  char *argv[];
  {

--- 6,13 -----
  #include <assert.h>
  #include <sys/wait.h>
  
+ extern char *strcpy(),*strcat();
+ 
  main(argc, argv)
  char *argv[];
  {
***************
*** 19,25
  	 *  If the files exist they are updated.
  	 */
  
! 	FILE *fa, *fb, *fc, *fta, *ftb, *ftc, *fd;
  	int nhash = 256;
  	int appflg = 1;
  	int keepkey = 0, pipein = 0;

--- 22,28 -----
  	 *  If the files exist they are updated.
  	 */
  
! 	FILE *fa, *fb, *fc, *fta, *ftb,*fd;
  	int nhash = 256;
  	int appflg = 1;
  	int keepkey = 0, pipein = 0;
***************
*** 26,33
  	char nma[100], nmb[100], nmc[100], com[100], nmd[100];
  	char tmpa[20], tmpb[20], tmpc[20];
  	char *remove = NULL;
! 	int chatty = 0, docs, hashes, fp[2], fr, fw, pfork, pwait, status;
! 	int i,j,k;
  	long keys;
  	int iflong =0;
  	char *sortdir;

--- 29,36 -----
  	char nma[100], nmb[100], nmc[100], com[100], nmd[100];
  	char tmpa[20], tmpb[20], tmpc[20];
  	char *remove = NULL;
! 	int chatty = 0, docs, hashes, fp[2], fr, fw, pfork, pwait;
! 	union wait status;
  	long keys;
  	int iflong =0;
  	char *sortdir;
***************
*** 56,62
  			pipein = 1; 
  			break;
  		case 'i': /* input is on file, not stdin */
! 			close(0);
  			if (open(argv[2], 0) != 0)
  				err("Can't read input %s", argv[2]);
  			if (argv[1][2]=='u') /* unlink */

--- 59,65 -----
  			pipein = 1; 
  			break;
  		case 'i': /* input is on file, not stdin */
! 			(void)close(0);
  			if (open(argv[2], 0) != 0)
  				err("Can't read input %s", argv[2]);
  			if (argv[1][2]=='u') /* unlink */
***************
*** 68,81
  		argc--;
  		argv++;
  	}
! 	strcpy (nma, argc >= 2 ? argv[1] : "Index");
! 	strcpy (nmb, nma);
! 	strcpy (nmc, nma);
! 	strcpy (nmd, nma);
! 	strcat (nma, ".ia");
! 	strcat (nmb, ".ib");
! 	strcat (nmc, ".ic");
! 	strcat (nmd, ".id");
  
  	sprintf(tmpa, "junk%di", getpid());
  	if (pipein)

--- 71,84 -----
  		argc--;
  		argv++;
  	}
! 	(void)strcpy (nma, argc >= 2 ? argv[1] : "Index");
! 	(void)strcpy (nmb, nma);
! 	(void)strcpy (nmc, nma);
! 	(void)strcpy (nmd, nma);
! 	(void)strcat (nma, ".ia");
! 	(void)strcat (nmb, ".ib");
! 	(void)strcat (nmc, ".ic");
! 	(void)strcat (nmd, ".id");
  
  	(void)sprintf(tmpa, "junk%di", getpid());
  	if (pipein)
***************
*** 77,83
  	strcat (nmc, ".ic");
  	strcat (nmd, ".id");
  
! 	sprintf(tmpa, "junk%di", getpid());
  	if (pipein)
  	{
  		pipe(fp); 

--- 80,86 -----
  	(void)strcat (nmc, ".ic");
  	(void)strcat (nmd, ".id");
  
! 	(void)sprintf(tmpa, "junk%di", getpid());
  	if (pipein)
  	{
  		(void)pipe(fp); 
***************
*** 80,86
  	sprintf(tmpa, "junk%di", getpid());
  	if (pipein)
  	{
! 		pipe(fp); 
  		fr=fp[0]; 
  		fw=fp[1];
  		if ( (pfork=fork()) == 0)

--- 83,89 -----
  	(void)sprintf(tmpa, "junk%di", getpid());
  	if (pipein)
  	{
! 		(void)pipe(fp); 
  		fr=fp[0]; 
  		fw=fp[1];
  		if ( (pfork=fork()) == 0)
***************
*** 85,92
  		fw=fp[1];
  		if ( (pfork=fork()) == 0)
  		{
! 			close(fw);
! 			close(0);
  			_assert(dup(fr)==0);
  			close(fr);
  			execl("/bin/sort", "sort", "-T", sortdir, "-o", tmpa, 0);

--- 88,95 -----
  		fw=fp[1];
  		if ( (pfork=fork()) == 0)
  		{
! 			(void)close(fw);
! 			(void)close(0);
  			_assert(dup(fr)==0);
  			(void)close(fr);
  			execl("/bin/sort", "sort", "-T", sortdir, "-o", tmpa, 0);
***************
*** 88,94
  			close(fw);
  			close(0);
  			_assert(dup(fr)==0);
! 			close(fr);
  			execl("/bin/sort", "sort", "-T", sortdir, "-o", tmpa, 0);
  			execl("/usr/bin/sort", "sort", "-T", sortdir, "-o", tmpa, 0);
  			_assert(0);

--- 91,97 -----
  			(void)close(fw);
  			(void)close(0);
  			_assert(dup(fr)==0);
! 			(void)close(fr);
  			execl("/bin/sort", "sort", "-T", sortdir, "-o", tmpa, 0);
  			execl("/usr/bin/sort", "sort", "-T", sortdir, "-o", tmpa, 0);
  			_assert(0);
***************
*** 94,100
  			_assert(0);
  		}
  		_assert(pfork!= -1);
! 		close(fr);
  		fta = fopen("/dev/null", "w");
  		close(fta->_file);
  		fta->_file = fw;

--- 97,103 -----
  			_assert(0);
  		}
  		_assert(pfork!= -1);
! 		(void)close(fr);
  		fta = fopen("/dev/null", "w");
  		(void)close(fta->_file);
  		fta->_file = fw;
***************
*** 96,102
  		_assert(pfork!= -1);
  		close(fr);
  		fta = fopen("/dev/null", "w");
! 		close(fta->_file);
  		fta->_file = fw;
  	}
  	else /* use tmp file */

--- 99,105 -----
  		_assert(pfork!= -1);
  		(void)close(fr);
  		fta = fopen("/dev/null", "w");
! 		(void)close(fta->_file);
  		fta->_file = fw;
  	}
  	else /* use tmp file */
***************
*** 109,115
  	{
  		if (fb = fopen(nmb, "r"))
  		{
! 			sprintf(tmpb, "junk%dj", getpid());
  			ftb = fopen(tmpb, "w");
  			if (ftb==NULL)
  				err("Can't get scratch file %s",tmpb);

--- 112,118 -----
  	{
  		if (fb = fopen(nmb, "r"))
  		{
! 			(void)sprintf(tmpb, "junk%dj", getpid());
  			ftb = fopen(tmpb, "w");
  			if (ftb==NULL)
  				err("Can't get scratch file %s",tmpb);
***************
*** 113,120
  			ftb = fopen(tmpb, "w");
  			if (ftb==NULL)
  				err("Can't get scratch file %s",tmpb);
! 			nhash = recopy(ftb, fb, fopen(nma, "r"));
! 			fclose(ftb);
  		}
  		else
  			appflg=0;

--- 116,123 -----
  			ftb = fopen(tmpb, "w");
  			if (ftb==NULL)
  				err("Can't get scratch file %s",tmpb);
! 			nhash = recopy(ftb, fb, fopen(nma, "r"),nhash);
! 			(void)fclose(ftb);
  		}
  		else
  			appflg=0;
***************
*** 120,127
  			appflg=0;
  	}
  	fc = fopen(nmc,  appflg ? "a" : "w");
! 	if (keepkey)
! 		fd = keepkey ? fopen(nmd, "w") : 0;
  	docs = newkeys(fta, stdin, fc, nhash, fd, &iflong);
  	fclose(stdin);
  	if (remove != NULL)

--- 123,132 -----
  			appflg=0;
  	}
  	fc = fopen(nmc,  appflg ? "a" : "w");
! 	/*
! 	 * it was not initializing the variable *fd before
! 	 */
! 	fd = keepkey ? fopen(nmd, "w") : 0;
  	docs = newkeys(fta, stdin, fc, nhash, fd, &iflong);
  	(void)fclose(stdin);
  	if (remove != NULL)
***************
*** 123,129
  	if (keepkey)
  		fd = keepkey ? fopen(nmd, "w") : 0;
  	docs = newkeys(fta, stdin, fc, nhash, fd, &iflong);
! 	fclose(stdin);
  	if (remove != NULL)
  		unlink(remove);
  	fclose(fta);

--- 128,134 -----
  	 */
  	fd = keepkey ? fopen(nmd, "w") : 0;
  	docs = newkeys(fta, stdin, fc, nhash, fd, &iflong);
! 	(void)fclose(stdin);
  	if (remove != NULL)
  		(void)unlink(remove);
  	(void)fclose(fta);
***************
*** 125,132
  	docs = newkeys(fta, stdin, fc, nhash, fd, &iflong);
  	fclose(stdin);
  	if (remove != NULL)
! 		unlink(remove);
! 	fclose(fta);
  	if (pipein)
  	{
  		pwait = wait(&status);

--- 130,137 -----
  	docs = newkeys(fta, stdin, fc, nhash, fd, &iflong);
  	(void)fclose(stdin);
  	if (remove != NULL)
! 		(void)unlink(remove);
! 	(void)fclose(fta);
  	if (pipein)
  	{
  		pwait = wait(&status);
***************
*** 130,136
  	if (pipein)
  	{
  		pwait = wait(&status);
! 		printf("pfork %o pwait %o status %d\n",pfork,pwait,status);
  		_assert(pwait==pfork);
  		_assert(status==0);
  	}

--- 135,141 -----
  	if (pipein)
  	{
  		pwait = wait(&status);
! 		printf("pfork %o pwait %o status %d\n",pfork,pwait,status.w_status);
  		_assert(pwait==pfork);
  		_assert(status.w_status==0);
  	}
***************
*** 132,138
  		pwait = wait(&status);
  		printf("pfork %o pwait %o status %d\n",pfork,pwait,status);
  		_assert(pwait==pfork);
! 		_assert(status==0);
  	}
  	else
  	{

--- 137,143 -----
  		pwait = wait(&status);
  		printf("pfork %o pwait %o status %d\n",pfork,pwait,status.w_status);
  		_assert(pwait==pfork);
! 		_assert(status.w_status==0);
  	}
  	else
  	{
***************
*** 136,143
  	}
  	else
  	{
! 		sprintf(com, "sort -T %s %s -o %s", sortdir, tmpa, tmpa);
! 		system(com);
  	}
  	if (appflg)
  	{

--- 141,148 -----
  	}
  	else
  	{
! 		(void)sprintf(com, "sort -T %s %s -o %s", sortdir, tmpa, tmpa);
! 		(void)system(com);
  	}
  	if (appflg)
  	{
***************
*** 141,150
  	}
  	if (appflg)
  	{
! 		sprintf(tmpc, "junk%dk", getpid());
! 		sprintf(com, "mv %s %s", tmpa, tmpc);
! 		system(com);
! 		sprintf(com, "sort -T %s  -m %s %s -o %s", sortdir,
  		tmpb, tmpc, tmpa);
  		system(com);
  	}

--- 146,154 -----
  	}
  	if (appflg)
  	{
! 		(void)sprintf(tmpc, "junk%dk", getpid());
! 		(void)rename(tmpa,tmpc);
! 		(void)sprintf(com, "sort -T %s  -m %s %s -o %s", sortdir,
  		tmpb, tmpc, tmpa);
  		(void)system(com);
  		(void)unlink(tmpc);
***************
*** 146,152
  		system(com);
  		sprintf(com, "sort -T %s  -m %s %s -o %s", sortdir,
  		tmpb, tmpc, tmpa);
! 		system(com);
  	}
  	fta = fopen(tmpa, "r");
  	fa = fopen(nma, "w");

--- 150,157 -----
  		(void)rename(tmpa,tmpc);
  		(void)sprintf(com, "sort -T %s  -m %s %s -o %s", sortdir,
  		tmpb, tmpc, tmpa);
! 		(void)system(com);
! 		(void)unlink(tmpc);
  	}
  	fta = fopen(tmpa, "r");
  	fa = fopen(nma, "w");
***************
*** 152,158
  	fa = fopen(nma, "w");
  	fb = fopen(nmb, "w");
  	whash(fta, fa, fb, nhash, iflong, &keys, &hashes);
! 	fclose(fta);
  # ifndef D1
  	unlink(tmpa);
  # endif

--- 157,163 -----
  	fa = fopen(nma, "w");
  	fb = fopen(nmb, "w");
  	whash(fta, fa, fb, nhash, iflong, &keys, &hashes);
! 	(void)fclose(fta);
  # ifndef D1
  	(void)unlink(tmpa);
  # endif
***************
*** 154,160
  	whash(fta, fa, fb, nhash, iflong, &keys, &hashes);
  	fclose(fta);
  # ifndef D1
! 	unlink(tmpa);
  # endif
  	if (appflg)
  	{

--- 159,165 -----
  	whash(fta, fa, fb, nhash, iflong, &keys, &hashes);
  	(void)fclose(fta);
  # ifndef D1
! 	(void)unlink(tmpa);
  # endif
  	if (appflg)
  	{
***************
*** 158,165
  # endif
  	if (appflg)
  	{
! 		unlink(tmpb);
! 		unlink(tmpc);
  	}
  	if (chatty)
  

--- 163,170 -----
  # endif
  	if (appflg)
  	{
! 		(void)unlink(tmpb);
! 		(void)unlink(tmpc);
  	}
  	if (chatty)
  

*** /tmp/,RCSt1012823	Thu Dec 13 08:52:33 1984
--- inv5.c	Tue Nov 20 10:02:13 1984
***************
*** 6,11
  
  recopy (ft, fb, fa, nhash)
  FILE *ft, *fb, *fa;
  {
  	/* copy fb (old hash items/pointers) to ft (new ones) */
  	int n, i, iflong;

--- 6,12 -----
  
  recopy (ft, fb, fa, nhash)
  FILE *ft, *fb, *fa;
+ int nhash;
  {
  	/* copy fb (old hash items/pointers) to ft (new ones) */
  	int n, i, iflong;
***************
*** 18,24
  	if (fa==NULL)
  	{
  		err("No old pointers",0);
! 		return;
  	}
  	fread(&n, sizeof(n), 1, fa);
  	fread(&iflong, sizeof(iflong), 1, fa);

--- 19,25 -----
  	if (fa==NULL)
  	{
  		err("No old pointers",0);
! 		return(nhash);
  	}
  	(void)fread(&n, sizeof(n), 1, fa);
  	(void)fread(&iflong, sizeof(iflong), 1, fa);
***************
*** 20,27
  		err("No old pointers",0);
  		return;
  	}
! 	fread(&n, sizeof(n), 1, fa);
! 	fread(&iflong, sizeof(iflong), 1, fa);
  	if (iflong)
  	{
  		hpt_l =  calloc(sizeof(*hpt_l), n+1);

--- 21,28 -----
  		err("No old pointers",0);
  		return(nhash);
  	}
! 	(void)fread(&n, sizeof(n), 1, fa);
! 	(void)fread(&iflong, sizeof(iflong), 1, fa);
  	if (iflong)
  	{
  		hpt_l =(long *)calloc((unsigned)sizeof(*hpt_l),(unsigned)(n+1));
***************
*** 24,30
  	fread(&iflong, sizeof(iflong), 1, fa);
  	if (iflong)
  	{
! 		hpt_l =  calloc(sizeof(*hpt_l), n+1);
  		n =fread(hpt_l, sizeof(*hpt_l), n, fa);
  	}
  	else

--- 25,31 -----
  	(void)fread(&iflong, sizeof(iflong), 1, fa);
  	if (iflong)
  	{
! 		hpt_l =(long *)calloc((unsigned)sizeof(*hpt_l),(unsigned)(n+1));
  		n =fread(hpt_l, sizeof(*hpt_l), n, fa);
  	}
  	else
***************
*** 29,35
  	}
  	else
  	{
! 		hpt_s =  calloc(sizeof(*hpt_s), n+1);
  		n =fread(hpt_s, sizeof(*hpt_s), n, fa);
  	}
  	if (n!= nhash)

--- 30,36 -----
  	}
  	else
  	{
! 		hpt_s = (int *)calloc((unsigned)sizeof(*hpt_s),(unsigned)(n+1));
  		n =fread(hpt_s, sizeof(*hpt_s), n, fa);
  	}
  	if (n!= nhash)
***************
*** 34,40
  	}
  	if (n!= nhash)
  		fprintf(stderr, "Changing hash value to old %d\n",n);
! 	fclose(fa);
  	if (iflong)
  		getfun = getl;
  	else

--- 35,41 -----
  	}
  	if (n!= nhash)
  		fprintf(stderr, "Changing hash value to old %d\n",n);
! 	(void)fclose(fa);
  	if (iflong)
  		getfun = getl;
  	else
***************
*** 45,51
  			lp = hpt_l[i];
  		else
  			lp = hpt_s[i];
! 		fseek(fb, lp, 0);
  		while ( (k= (*getfun)(fb) ) != -1)
  			fprintf(ft, "%04d %06ld\n",i,k);
  	}

--- 46,52 -----
  			lp = hpt_l[i];
  		else
  			lp = hpt_s[i];
! 		(void)fseek(fb, lp, 0);
  		while ( (k= (*getfun)(fb) ) != -1)
  			fprintf(ft, "%04d %06ld\n",i,k);
  	}
***************
*** 49,54
  		while ( (k= (*getfun)(fb) ) != -1)
  			fprintf(ft, "%04d %06ld\n",i,k);
  	}
! 	fclose(fb);
  	return(n);
  }

--- 50,55 -----
  		while ( (k= (*getfun)(fb) ) != -1)
  			fprintf(ft, "%04d %06ld\n",i,k);
  	}
! 	(void)fclose(fb);
  	return(n);
  }
*** /tmp/,RCSt1012832	Thu Dec 13 08:53:05 1984
--- inv6.c	Tue Nov 20 10:02:56 1984
***************
*** 16,22
  	int ct = 0;
  	long point;
  	long opoint = -1;
- 	int m;
  	int k; 
  	long lp;
  	long *hpt;

--- 16,21 -----
  	int ct = 0;
  	long point;
  	long opoint = -1;
  	int k; 
  	long lp;
  	long *hpt;
***************
*** 22,28
  	long *hpt;
  	int *hfreq = NULL;
  
! 	hpt = calloc (nhash+1, sizeof(*hpt));
  	_assert (hpt != NULL);
  	hfreq = calloc (nhash, sizeof(*hfreq));
  	_assert (hfreq !=NULL);

--- 21,27 -----
  	long *hpt;
  	int *hfreq = NULL;
  
! 	hpt = ( long *)calloc ((unsigned)(nhash+1),(unsigned)sizeof(*hpt));
  	_assert (hpt != NULL);
  	hfreq = (int *)calloc ((unsigned)nhash,(unsigned)sizeof(*hfreq));
  	_assert (hfreq !=NULL);
***************
*** 24,30
  
  	hpt = calloc (nhash+1, sizeof(*hpt));
  	_assert (hpt != NULL);
! 	hfreq = calloc (nhash, sizeof(*hfreq));
  	_assert (hfreq !=NULL);
  	hpt[0] = 0;
  	lp= 0;

--- 23,29 -----
  
  	hpt = ( long *)calloc ((unsigned)(nhash+1),(unsigned)sizeof(*hpt));
  	_assert (hpt != NULL);
! 	hfreq = (int *)calloc ((unsigned)nhash,(unsigned)sizeof(*hfreq));
  	_assert (hfreq !=NULL);
  	hpt[0] = 0;
  	lp= 0;
***************
*** 31,37
  	while (fgets(line, 100, ft))
  	{
  		totct++;
! 		sscanf(line, "%d %ld", &k, &point);
  		if (hash < k)
  		{
  			hused++;

--- 30,36 -----
  	while (fgets(line, 100, ft))
  	{
  		totct++;
! 		(void)sscanf(line, "%d %ld", &k, &point);
  		if (hash < k)
  		{
  			hused++;
***************
*** 36,42
  		{
  			hused++;
  			if (iflong) putl(-1L, fb); 
! 			else putw(-1, fb);
  			hfreq[hash]=ct;
  			while (hash<k)
  			{

--- 35,42 -----
  		{
  			hused++;
  			if (iflong) putl(-1L, fb); 
! 			else 
! 			   (void)putw(-1, fb);
  			hfreq[hash]=ct;
  			while (hash<k)
  			{
***************
*** 52,59
  			if (iflong)
  				putl(opoint=point, fb);
  			else
! 				putw( (int)(opoint=point), fb);
! 			lp += iflong? sizeof(long) : sizeof(int);
  			ct++;
  		}
  	}

--- 52,59 -----
  			if (iflong)
  				putl(opoint=point, fb);
  			else
! 				(void)putw( (int)(opoint=point), fb);
! 			lp += iflong? sizeof(long) : (int)sizeof(int);
  			ct++;
  		}
  	}
***************
*** 58,64
  		}
  	}
  	if (iflong) putl(-1L, fb); 
! 	else putw(-1,fb);
  	while (hash<nhash)
  		hpt[++hash]=lp;
  	fwrite(&nhash, sizeof(nhash), 1, fa);

--- 58,65 -----
  		}
  	}
  	if (iflong) putl(-1L, fb); 
! 	else 
! 	   (void)putw(-1,fb);
  	while (hash<nhash)
  		hpt[++hash]=lp;
  	(void)fwrite(&nhash, sizeof(nhash), 1, fa);
***************
*** 61,70
  	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;
  }

--- 62,71 -----
  	   (void)putw(-1,fb);
  	while (hash<nhash)
  		hpt[++hash]=lp;
! 	(void)fwrite(&nhash, sizeof(nhash), 1, fa);
! 	(void)fwrite(&iflong, sizeof(iflong), 1, fa);
! 	(void)fwrite(hpt, sizeof(*hpt), nhash, fa);
! 	(void)fwrite (hfreq, sizeof(*hfreq), nhash, fa);
  	*ptotct = totct;
  	*phused = hused;
  }
***************
*** 73,79
  long ll;
  FILE *f;
  {
! 	putw(ll, f);
  }
  
  long

--- 74,80 -----
  long ll;
  FILE *f;
  {
! 	(void)putw(ll, f);
  }
  
  long

*** /tmp/,RCSt1012841	Thu Dec 13 08:53:30 1984
--- mkey2.c	Tue Nov 20 10:03:45 1984
***************
*** 47,53
  			chkey (c, name);
  		if (used) putchar('\n');
  	}
! 	fclose(f);
  }
  
  outkey( ky, lead, trail)

--- 47,53 -----
  			chkey (c, name);
  		if (used) putchar('\n');
  	}
! 	(void)fclose(f);
  }
  
  outkey( ky, lead, trail)
***************
*** 85,91
  		if (tm[0] == '%' || tm[0] == '.')
  			curtype = tm[1];
  		if (tlen < MAXLINE && mindex(iglist,curtype)==0)
! 			strcat(s, tm);
  		len = tlen;
  		if (wholefile==0 && tm[0] == '\n')
  			return(len);

--- 85,91 -----
  		if (tm[0] == '%' || tm[0] == '.')
  			curtype = tm[1];
  		if (tlen < MAXLINE && mindex(iglist,curtype)==0)
! 			(void)strcat(s, tm);
  		len = tlen;
  		if (wholefile==0 && tm[0] == '\n')
  			return(len);
***************
*** 91,97
  			return(len);
  		if (wholefile>0 && len >= MAXLINE)
  		{
! 			fseek (f, 0L, 2);
  			return(ftell(f));
  		}
  	}

--- 91,97 -----
  			return(len);
  		if (wholefile>0 && len >= MAXLINE)
  		{
! 			(void)fseek (f, 0L, 2);
  			return(ftell(f));
  		}
  	}
***************
*** 103,112
  trimnl(ln)
  char *ln;
  {
! 	register char *p = ln;
! 	while (*p) p++;
! 	p--;
! 	if (*p == '\n') *p=0;
  	return(ln);
  }
  

--- 103,112 -----
  trimnl(ln)
  char *ln;
  {
! 	register char *w = ln;
! 	while (*w) w++;
! 	w--;
! 	if (*w == '\n') *w=0;
  	return(ln);
  }
  
*** /tmp/,RCSt1012872	Thu Dec 13 08:55:26 1984
--- refer3.c	Tue Nov 20 10:04:21 1984
***************
*** 3,8
  #endif
  
  #include "refer..c"
  #define move(x, y) close(y); dup(x); close(x);
  
  corout(in, out, rprog, arg, outlen)

--- 3,10 -----
  #endif
  
  #include "refer..c"
+ #include <sys/wait.h>
+ 
  #define move(x, y) close(y); dup(x); close(x);
  
  corout(in, out, rprog, arg, outlen)
***************
*** 6,12
  #define move(x, y) close(y); dup(x); close(x);
  
  corout(in, out, rprog, arg, outlen)
! char *in, *out, *rprog;
  {
  	int pipev[2], fr1, fr2, fw1, fw2, n;
  	int status;

--- 8,14 -----
  #define move(x, y) close(y); dup(x); close(x);
  
  corout(in, out, rprog, arg, outlen)
! char *in, *out, *rprog, *arg;
  {
  	int pipev[2], fr1, fr2, fw1, fw2, n;
  	union wait status;
***************
*** 9,15
  char *in, *out, *rprog;
  {
  	int pipev[2], fr1, fr2, fw1, fw2, n;
! 	int status;
  
  	pipe(pipev); 
  	fr1 = pipev[0]; 

--- 11,17 -----
  char *in, *out, *rprog, *arg;
  {
  	int pipev[2], fr1, fr2, fw1, fw2, n;
! 	union wait status;
  
  	(void)pipe(pipev); 
  	fr1 = pipev[0]; 
***************
*** 11,17
  	int pipev[2], fr1, fr2, fw1, fw2, n;
  	int status;
  
! 	pipe(pipev); 
  	fr1 = pipev[0]; 
  	fw1 = pipev[1];
  	pipe(pipev); 

--- 13,19 -----
  	int pipev[2], fr1, fr2, fw1, fw2, n;
  	union wait status;
  
! 	(void)pipe(pipev); 
  	fr1 = pipev[0]; 
  	fw1 = pipev[1];
  	(void)pipe(pipev); 
***************
*** 14,20
  	pipe(pipev); 
  	fr1 = pipev[0]; 
  	fw1 = pipev[1];
! 	pipe(pipev); 
  	fr2 = pipev[0]; 
  	fw2 = pipev[1];
  	if (fork() == 0)

--- 16,22 -----
  	(void)pipe(pipev); 
  	fr1 = pipev[0]; 
  	fw1 = pipev[1];
! 	(void)pipe(pipev); 
  	fr2 = pipev[0]; 
  	fw2 = pipev[1];
  	if (fork() == 0)
***************
*** 19,26
  	fw2 = pipev[1];
  	if (fork() == 0)
  	{
! 		close(fw1); 
! 		close(fr2);
  		move(fr1, 0);
  		move(fw2, 1);
  		execl(rprog, "deliv", arg, 0);

--- 21,28 -----
  	fw2 = pipev[1];
  	if (fork() == 0)
  	{
! 		(void)close(fw1); 
! 		(void)close(fr2);
  		move(fr1, 0);
  		move(fw2, 1);
  		execl(rprog, "deliv", arg, 0);
***************
*** 26,36
  		execl(rprog, "deliv", arg, 0);
  		err("Can't run %s", (void) rprog);
  	}
! 	close(fw2); 
! 	close(fr1);
! 	write(fw1, in , strlen(in));
! 	close(fw1);
! 	wait(&status);
  	n = read(fr2, out, outlen);
  	out[n] = 0;
  	close(fr2);

--- 28,38 -----
  		execl(rprog, "deliv", arg, 0);
  		err("Can't run %s", (void) rprog);
  	}
! 	(void)close(fw2); 
! 	(void)close(fr1);
! 	(void)write(fw1, in , strlen(in));
! 	(void)close(fw1);
! 	(void)wait(&status);
  	n = read(fr2, out, outlen);
  	out[n] = 0;
  	(void)close(fr2);
***************
*** 33,38
  	wait(&status);
  	n = read(fr2, out, outlen);
  	out[n] = 0;
! 	close(fr2);
  	return(n);
  }

--- 35,40 -----
  	(void)wait(&status);
  	n = read(fr2, out, outlen);
  	out[n] = 0;
! 	(void)close(fr2);
  	return(n);
  }



More information about the Comp.unix.wizards mailing list