wood@dg-rtp.dg.com (Tom Wood) (10/19/89)
A problem occurs with the 1.36 preprocessor when stringifying. Here's
the test case (minimal):
#ifdef __STDC__
#define Str(z)_Str(z)
#define _Str(z)#z
#else
#define Str(z)"z"
#endif
#define Indr
#define cast(t) *(t *)0
int pp_string()
{
return Str(cast(int Indr));
}
What happens is that macroexpand of _Str is given the sequence
"*(int \n *)0\n )\n". The erroneous output is "*(int *)0" (two spaces).
More importantly, this causes an internal abort in a larger case when the
character count exceeds what was allocated. Here's the fix:
*** cccp.c.orig Wed Oct 18 16:34:05 1989
--- cccp.c Wed Oct 18 15:52:20 1989
***************
*** 4244,4250 ****
/* Internal sequences of whitespace are replaced by one space. */
if (c == '\n' ? arg->raw[i+1] == '\n' : is_space[c]) {
while (1) {
! if (c == '\n' && arg->raw[i+1] == '\n')
i += 2;
else if (c != '\n' && is_space[c])
i++;
--- 4246,4253 ----
/* Internal sequences of whitespace are replaced by one space. */
if (c == '\n' ? arg->raw[i+1] == '\n' : is_space[c]) {
while (1) {
! /* The case this failed on is " \n " (Newline Space occurs and should be ignored). */
! if (c == '\n' && is_space[arg->raw[i+1]])
i += 2;
else if (c != '\n' && is_space[c])
i++;
---
Tom Wood (919) 248-6067
Data General, Research Triangle Park, NC
{the known world}!rti!xyzzy!wood