t-jacobs@utah-cs.UUCP (Tony Jacobs) (06/26/86)
Here is a bug my brother discovered. This bug still shows up after installing
the recient list of patches (6-11-86?).
#include <stdio.h>
#include <ctype.h>
/*
Author: Steven R. Jacobs
Computer Science Department
University of Utah
Salt Lake City, Utah 84112
(801) 581-8580
LightSpeed Libraries needed: stdio, unix, MacTraps
This program should print only the word "Works" when running correctly.
**MOVE THE FOLLOWING LINE OUTSIDE OF THE COMMENT TO DEMONSTRATE THE BUG** */
/* #define SHOWBUG */
#ifdef SHOWBUG
#define MIDSTRING(ch) ((isspace(ch) || 0) ? 0 : (ch))
#else
#define MIDSTRING(ch) (isspace(ch) ? 0 : (ch))
#endif
main()
{
char word[128], *readtoken();
printf("%s\n", readtoken("Works incorrectly!", word));
}
/*****************************************************************************/
/* returns first word from a string */
char *readtoken(t, str)
char *t, *str;
{
register int ch;
register char *s;
ch = *t++;
for (s = str; *t && (*s++ = MIDSTRING(ch)); ) /* NOT == */
ch = *t++;
*(++s) = '\0';
return (str);
}