walls@killer.DALLAS.TX.US (Monty Walls) (10/09/88)
-------------------------------------------------------------------------- Sorry this took so long to get sent out. I have been without a computer for 2 weeks. This sould fix the problem people have mentioned in tsort. -Monty Walls ---------------------------cut here--------------------------------------- *** tsort.c.orig --- tsort.c ************** *** 24,29 * change log: * possible bug in ungetc(), fixed readone() to avoid - 2/19/88 - mrw * massive design error, rewrote dump logic - 3/15/88 - mrw */ #include <stdio.h> --- 24,31 ----- * change log: * possible bug in ungetc(), fixed readone() to avoid - 2/19/88 - mrw * massive design error, rewrote dump logic - 3/15/88 - mrw + * stupid error causing overlay of s1 & s2 in readnode - 9/12/88 - mrw + * */ #include <stdio.h> ************** *** 89,95 struct node * readnode() { ! char *s1, *s2; register struct node *n1, *n2; struct dependents *pd; --- 91,97 ----- struct node * readnode() { ! static char s1[MAXNAMELEN], s2[MAXNAMELEN]; register struct node *n1, *n2; struct dependents *pd; ************** *** 93,99 register struct node *n1, *n2; struct dependents *pd; ! if ((s1 = readone()) != (char *)NULL) { if ((n1 = findnode(s1)) == (struct node *)NULL) { /* is a new node so build it */ n1 = (struct node *)xalloc(sizeof(struct node)); --- 95,101 ----- register struct node *n1, *n2; struct dependents *pd; ! if (readone(s1) != (char *)NULL) { if ((n1 = findnode(s1)) == (struct node *)NULL) { /* is a new node so build it */ n1 = (struct node *)xalloc(sizeof(struct node)); ************** *** 107,113 n1->visited = 0; linknode(n1); } ! if ((s2 = readone()) != (char *)NULL) { if ((n2 = findnode(s2)) == (struct node *)NULL) { /* is a new node so build it */ n2 = (struct node *)xalloc(sizeof(struct node)); --- 109,115 ----- n1->visited = 0; linknode(n1); } ! if (readone(s2) != (char *)NULL) { if ((n2 = findnode(s2)) == (struct node *)NULL) { /* is a new node so build it */ n2 = (struct node *)xalloc(sizeof(struct node)); ************** *** 223,229 fprintf(stderr,"Error: %s - member queue overflow\n",progname); exit(1); } ! else q[back] = t; } --- 225,231 ----- fprintf(stderr,"Error: %s - member queue overflow\n",progname); exit(1); } ! else { q[back] = t; } } ************** *** 225,230 } else q[back] = t; } char * --- 227,233 ----- } else { q[back] = t; + } } char * ************** *** 228,234 } char * ! readone() { register int c, n = 0; static char name[MAXNAMELEN]; --- 231,238 ----- } char * ! readone(str) ! char str[]; /* of MAXNAMELEN length */ { register int c, n = 0; ************** *** 231,237 readone() { register int c, n = 0; - static char name[MAXNAMELEN]; /* eat up leading spaces */ while ((c = getchar()) != EOF && isspace(c)) --- 235,240 ----- char str[]; /* of MAXNAMELEN length */ { register int c, n = 0; /* eat up leading spaces */ while ((c = getchar()) != EOF && isspace(c)) ************** *** 238,244 ; if (c != EOF) { ! name[n++] = c; /* save into name first non blank */ while ((c = getchar()) != EOF && !isspace(c)) { if (n < MAXNAMELEN) name[n++] = c; --- 241,247 ----- ; if (c != EOF) { ! str[n++] = c; /* save into name first non blank */ while ((c = getchar()) != EOF && !isspace(c)) { if (n < MAXNAMELEN) str[n++] = c; ************** *** 241,247 name[n++] = c; /* save into name first non blank */ while ((c = getchar()) != EOF && !isspace(c)) { if (n < MAXNAMELEN) ! name[n++] = c; } name[n] = '\0'; return (name); --- 244,250 ----- str[n++] = c; /* save into name first non blank */ while ((c = getchar()) != EOF && !isspace(c)) { if (n < MAXNAMELEN) ! str[n++] = c; } str[n] = '\0'; return (str); ************** *** 243,250 if (n < MAXNAMELEN) name[n++] = c; } ! name[n] = '\0'; ! return (name); } else return ((char *)NULL); --- 246,253 ----- if (n < MAXNAMELEN) str[n++] = c; } ! str[n] = '\0'; ! return (str); } else return ((char *)NULL); ---------------------------end here--------------------------------------- Monty Walls MIS Division, Tech. Support Oklahoma Tax Commission 2501 N. Lincoln OKC, OK, 73194