Bug 23269 - cpp incorrectly stripping out spaces
Summary: cpp incorrectly stripping out spaces
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: cpp
Version: 7.0
Hardware: i386
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2001-01-04 04:21 UTC by tbeckman
Modified: 2008-05-01 15:37 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2001-01-04 04:22:02 UTC
Embargoed:


Attachments (Terms of Use)

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).


Note You need to log in before you can comment on or make changes to this bug.