Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!brl-adm!brl-smoke!gwyn From: gwyn@brl-smoke.ARPA (Doug Gwyn ) Newsgroups: comp.bugs.sys5 Subject: SVR2 cpp bug Message-ID: <5408@brl-smoke.ARPA> Date: Tue, 25-Nov-86 15:45:30 EST Article-I.D.: brl-smok.5408 Posted: Tue Nov 25 15:45:30 1986 Date-Received: Wed, 26-Nov-86 19:54:43 EST Distribution: net Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 80 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.