Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!princeton!caip!ut-sally!utah-cs!t-jacobs From: t-jacobs@utah-cs.UUCP (Tony Jacobs) Newsgroups: net.micro.mac Subject: LightspeedC bug Message-ID: <3834@utah-cs.UUCP> Date: Thu, 26-Jun-86 10:27:38 EDT Article-I.D.: utah-cs.3834 Posted: Thu Jun 26 10:27:38 1986 Date-Received: Sat, 28-Jun-86 08:38:10 EDT Organization: University of Utah CS Dept Lines: 47 Keywords: LightspeedC, C, bug Here is a bug my brother discovered. This bug still shows up after installing the recient list of patches (6-11-86?). #include #include /* 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); }