Bug in C preprocessor and fix
utzoo!decvax!harpo!seismo!stewart
utzoo!decvax!harpo!seismo!stewart
Tue Dec 28 11:06:36 AEST 1982
The C Preprocessor has a bug which causes Lint to fail under certain
conditions. (This does not affect C compilations.) If the -C flag
is defined, comments are passed along with the source language (conditional
upon the #if... statements). The problem is that when the conditional
is false, and comments are being parsed, the logic which inserts
characters to split long comments still (unconditionally) outputs certain
characters. You should not change the putc calls which output
newlines; this will screw up the line numbers in diagnostic messages.
(The following changes were made to a heavily modified version of
cpp.c, which runs on the pdp11 but supports long names as on 4.1.)
John Stewart, Teledyne Geotech, (703)276-7900
................................................................
*** cpp.c Mon Dec 27 08:45:15 1982
--- cpp.c_ Mon Dec 20 13:25:48 1982
***************
*** 8,14
/* C command
/* written by John F. Reiser
/* July/August 1978
- * 27 Dec 82--added cputc macro to fix bug with -C flag--JCStewart
*/
#define STATIC
--- 8,13 -----
/* C command
/* written by John F. Reiser
/* July/August 1978
*/
#define STATIC
***************
*** 103,110
#define eob(a) ((a)>=pend)
#define bob(a) (pbeg>=(a))
- #define cputc(a,b) if(!flslvl) putc(a,b)
-
char buffer[NCPS+BUFSIZ+BUFSIZ+NCPS];
# define SBSIZE 25000 /* was 12000 -- JCStewart, 27 Oct 82 */
--- 102,107 -----
#define eob(a) ((a)>=pend)
#define bob(a) (pbeg>=(a))
char buffer[NCPS+BUFSIZ+BUFSIZ+NCPS];
# define SBSIZE 25000 /* was 12000 -- JCStewart, 27 Oct 82 */
***************
*** 383,389
if (!passcom) {inp=p; p=refill(p);}
else if ((p-inp)>=BUFSIZ) {/* split long comment */
inp=p; p=refill(p); /* last char written is '*' */
! cputc('/',fout); /* terminate first part */
/* and fake start of 2nd */
outp=inp=p-=3; *p++='/'; *p++='*'; *p++='*';
} else p=refill(p);
--- 380,386 -----
if (!passcom) {inp=p; p=refill(p);}
else if ((p-inp)>=BUFSIZ) {/* split long comment */
inp=p; p=refill(p); /* last char written is '*' */
! putc('/',fout); /* terminate first part */
/* and fake start of 2nd */
outp=inp=p-=3; *p++='/'; *p++='*'; *p++='*';
} else p=refill(p);
***************
*** 394,400
if (!passcom) {inp=p; p=refill(p);}
else if ((p-inp)>=BUFSIZ) {/* split long comment */
inp=p; p=refill(p);
! cputc('*',fout); cputc('/',fout);
outp=inp=p-=2; *p++='/'; *p++='*';
} else p=refill(p);
} else ++p; /* ignore null byte */
--- 391,397 -----
if (!passcom) {inp=p; p=refill(p);}
else if ((p-inp)>=BUFSIZ) {/* split long comment */
inp=p; p=refill(p);
! putc('*',fout); putc('/',fout);
outp=inp=p-=2; *p++='/'; *p++='*';
} else p=refill(p);
} else ++p; /* ignore null byte */
More information about the Net.bugs
mailing list