[321] in Zephyr_Bugs
decmips 7.3M: zwgc
daemon@ATHENA.MIT.EDU (Marc Horowitz)
Sun Oct 6 20:38:42 1991
To: bugs@Athena.MIT.EDU
Cc: bug-zephyr@Athena.MIT.EDU, krishna@Athena.MIT.EDU, warlord@Athena.MIT.EDU
Date: Sun, 06 Oct 91 20:39:23 EDT
From: Marc Horowitz <marc@Athena.MIT.EDU>
What were you trying to do?
Compile zwgc. (Well, two other people were :-)
What's wrong:
in formatter.c, index() is used, but is never declared. So, the following line fails:
bracketnum=(int) (index(brackets,str[0])-brackets);
subtracting a (char *) from an (int) is not legal in C. This could
also be considered a bug report in every C compiler we have except for
the current pmax gcc, since it allows this construct without even a
warning.
What should have happened:
The compilers should have given a warning, which would have
told me to apply the following patch:
*** /afs/athena/astaff/project/zephyr/src/zwgc/formatter.c Wed Jan 9 02:38:00 1991
--- /tmp/formatter.c Sun Oct 6 20:29:27 1991
***************
*** 20,25 ****
--- 20,26 ----
#include <stdio.h>
#include <ctype.h>
+ #include <string.h>
#include "new_memory.h"
#include "char_stack.h"
#include "string_dictionary.h"
***************
*** 286,292 ****
temp=lbreak(&str,allmaskable_set);
while(*str) {
! bracketnum=(int) (index(brackets,str[0])-brackets);
temp=string_Concat2(temp,openbracket[bracketnum]);
temp=string_Concat2(temp,temp2=lany(&str," "));
free(temp2);
--- 287,293 ----
temp=lbreak(&str,allmaskable_set);
while(*str) {
! bracketnum=(int) (strchr(brackets,str[0])-brackets);
temp=string_Concat2(temp,openbracket[bracketnum]);
temp=string_Concat2(temp,temp2=lany(&str," "));
free(temp2);
In addition, all occurrences of index() and <strings.h> should be
replaced with strchr() and <string.h>. This should probably be done
throughout the entire Athena source tree, actually. But this patch is
sufficient to allow formatter.c to compile with gcc on the decmips.
Please describe any relevant documentation references:
ANSI X3.159-1981