Bug 23269

Summary: cpp incorrectly stripping out spaces
Product: [Retired] Red Hat Linux Reporter: tbeckman
Component: cppAssignee: Jakub Jelinek <jakub>
Status: CLOSED NOTABUG QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 7.0   
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2001-01-04 04:22:02 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description tbeckman 2001-01-04 04:21:59 UTC
The version of cpp included with RH 7.0 and the updated
cpp-2.96-69.i386.rpm that was just released both exhibit this problem.  We
use the C preprocessor to process #includes for some fortran code.  cpp
version 2.96 incorrectly strips spaces out of the resulting file, resulting
in fortran code that can not be compiled.  This same process has worked
properly with cpp from egcs-2.91.66, gcc-2.95.1 and gcc-2.95.2 (not to
mention every C preprocessor that has been used for this code from the
early 80's).  Details are below:

The following file (let's call it "temp.c") is processed through cpp with
the command line "cpp  -DFORTRAN temp.c > temp.f". 

----------------------temp.c------------------------------

#ifndef FORTRAN
static int dummy;	/* prevent ranlib from whining */
#else

C
C       WRTSTD.  Write to standard output device if different from
terminal.
C
        SUBROUTINE  WRTSTD(MSG)

        CHARACTER*(*)   MSG                     

        INTEGER         LENGTH                  
        INTEGER         LUN                     
        LOGICAL         TERMNL                  
        
        CALL GETLUN(LUN)
        CALL GETSTD(TERMNL)
        LENGTH = LEN(MSG)
        
        IF (.NOT. TERMNL) THEN
            WRITE(LUN, 100) (MSG(I:I),I=1,LENGTH)
        ENDIF
100     FORMAT(1X, 131(:,A1))
        RETURN
        END
#endif

---------------end of temp.c-----------------------

The temp.f file created  has all the spaces, except one, removed between
the "100" and the "FORMAT" from the line 
100     FORMAT(1X, 131(:,A1))

This results in g77 choking on the temp.f file.

Comment 1 Jakub Jelinek 2001-01-04 09:58:26 UTC
cpp can do that, none of the C standards require it to leave the spaces in.
Use -traditional preprocessor for Fortran (g77 uses for its include directives
traditional preprocessor as well).