From: RHEA::DECWRL::"elsie!ado@seismo.ARPA" 30-MAR-1985 14:17 To: seismo!minow%rex.DEC@decwrl Subj: '#define a(b,c) "a"' messes up if STRING_FORMAL is defined (with fix) Received: from DECWRL by DEC-RHEA with SMTP; Sat, 30 Mar 85 11:16-PST Received: from seismo.ARPA (seismo.arpa.ARPA) by decwrl.ARPA (4.22.01/4.7.34) id AA01388; Sat, 30 Mar 85 11:17:32 pst Received: from elsie.UUCP by seismo.ARPA with UUCP; Sat, 30 Mar 85 14:17:17 EST Date: Sat, 30 Mar 85 14:17:17 EST Return-Path: Message-Id: <8503301917.AA08731@seismo.ARPA> If you've got STRING_FORMAL defined to be TRUE, do a define such as #define a(b,c) "a" and then invoke the macro a la a(y,z) you get output that's equivalent to "\035a" --that is, a DEF_MAGIC character gets written to the output. Things come out right if two changes are made to "cpp4.c". First, in the "STRING_FORMAL" version of "stparmscan": . . . /* * Warning -- this code hasn't been tested for a while. * It exists only to preserve compatibility with earlier * implementations of cpp. It is not part of the Draft * ANSI Standard C language. */ save(delim); instring = TRUE; while ((c = get()) != delim && c != '\n' && c != EOF_CHAR) { if (type[c] == LET) /* Maybe formal parm */ #ifdef OLDVERSION checkparm(c, dp); #else checkparm(c, NULL); #endif else { save(c); if (c == '\\') save(get()); } } . . . And second, in "mtokensave": . . . FILE_LOCAL mtokensave(dp) DEFBUF *dp; /* * Save the token in the macro buffer. A magic cookie is saved * if the token is identical to the macro name, so the expansion * doesn't recurse. */ { register char *cp; #ifdef OLDVERSION if (streq(dp->name, token)) /* Macro name in body? */ #else if (dp != NULL && streq(dp->name, token)) /* Name in body? */ #endif save(DEF_MAGIC); /* Save magic marker */ for (cp = token; *cp != EOS;) /* And save */ save(*cp++); /* The token itself */ } . . . --ado From: RHEA::DECWRL::"elsie!ado@seismo.ARPA" 30-MAR-1985 16:15 To: seismo!minow%rex.DEC@decwrl Subj: replacing an "#ifdef DEBUG" with an "#if DEBUG" in "cpp6.c" Received: from DECWRL by DEC-RHEA with SMTP; Sat, 30 Mar 85 13:14-PST Received: from seismo.ARPA (seismo.arpa.ARPA) by decwrl.ARPA (4.22.01/4.7.34) id AA02014; Sat, 30 Mar 85 13:15:30 pst Received: from elsie.UUCP by seismo.ARPA with UUCP; Sat, 30 Mar 85 16:15:17 EST Date: Sat, 30 Mar 85 16:15:17 EST Return-Path: Message-Id: <8503302115.AA10032@seismo.ARPA> The change is to the function "unget" in "cpp6.c": . . . unget() /* * Backup the pointer to reread the last character. Fatal error * (code bug) if we backup too far. unget() may be called, * without problems, at end of file. Only one character may * be ungotten. If you need to unget more, call ungetstring(). */ { register FILEINFO *file; if ((file = infile) == NULL) return; /* Unget after EOF */ if (--file->bptr < file->buffer) cfatal("Too much pushback", NULLST); if (*file->bptr == '\n') /* Ungetting a newline? */ --line; /* Unget the line number, too */ #ifdef OLDVERSION #ifdef DEBUG if (debug > 2) dumpunget("after unget"); #endif #else #if DEBUG if (debug > 2) dumpunget("after unget"); #endif #endif } . . . --ado