Article View: net.micro.mac
Article #6235LightspeedC bug
From: Tony Jacobs
Date: Thu, 26 Jun 1986 14:27
Date: Thu, 26 Jun 1986 14:27
47 lines
1620 bytes
1620 bytes
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);
}
Technical Details
Message-ID:
<3834@utah-cs.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!allegra!princeton!caip!ut-sally!utah-cs!t-jacobsShow Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: arc1-ca.pugleaf.net!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