🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Doug Gwyn Tue, 25 Nov 1986 20:45
SVR2 cpp bug
#446
Author: Doug Gwyn
Date: Tue, 25 Nov 1986 20:45
80 lines
2390 bytes
Here is a fix for Problem ID 722 in the UNIX System V Known Problem List.

The problem can be seen by running the following file through /lib/cpp -C:

/*xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
... [precisely enough text so that the following
  asterisk is exactly the BUFSIZth character] ...
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
data1;
/* comment */
data2;

Buggy cpp produces:

# 1 ""
/*xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
...
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx**//*/
data1;
/* comment */
data2;

which accidentally comments out "data1".  After
applying my fix, cpp produces:

# 1 ""
/*xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
...
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*//**/
data1;
/* comment */
data2;

which is much better.

FIX:  Somewhere around line 600 of cpp.c:

/*  @(#)cpp.c	1.11	*/
char	release[] = "@(#)C rel 6.0";
...
char *
cotoken( p )
    register char *p;
{
...
	case '/':
	    for ( ;; )
	    {
		if ( *p++ == '*' )  /* comment */
...
		    for ( ;; )
...
			if ( p[-1] == '*' )
			    for ( ;; )
			    {
...
				    /* split long comment */
				    else if ( ( p - inp ) >= BUFSIZ )
				    {
					/* DAG -- removed for bug fix: */
/*					*p++ = '*';	*/
					*p++ = '/';
					inp = p;
					p = refill( p );
					/* DAG -- changed 2 to 3 for bug fix: */
					outp = inp = p -= 3;
					*p++ = '/';
					*p++ = '*';
					/* DAG -- added for bug fix: */
					*p++ = '*';
				    }

WARNING:  There is a similar kludge about 50 lines later in the source
file; do NOT make this change to it.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads