Menu

#736 COPY REPLACING isn't working when replacing with a star

GC 3.1
open
nobody
5 - default
2021-06-21
2021-06-21
No

Hi GnuCOBOL team,

if you try to replace a statment beginning with a star we got several errors while compile.

F.e.:
COPY "tc2432A" REPLACING
==FD SCHL-DATEI== BY ==* SD SCHL-DATEI==.

From COBOL syntax view there is nothing, which should block this kind of replacing.

Please take a look in the attached testcase while using the script tc2432.sh:

cobc -x tc2432.cbl

./tc2432

Kind regards

Sebastian Steinweg
Easirun Europa GmbH

4 Attachments

Discussion

  • Simon Sobisch

    Simon Sobisch - 2021-06-21
    • labels: --> cobc, preprocessor
     
  • Simon Sobisch

    Simon Sobisch - 2021-06-21

    This is a nice edge case. The REPLACING statement actually wants to "uncomment" a line, as only uncommented lines get into that stage of the preprocessor this currently does not work.

    COBOL 2002 says (emphasis by me):

    6.5 Logical conversion

    Source text and library text in fixed-form reference format are logically converted to free-form reference format before the application of replacing and conditional compilation actions.

    This logical conversion also includes

    2) If the line is a comment line or a blank line, that line is logically discarded.
    3) If the line contains an inline comment, the inline comment is replaced by spaces and processing of that line continues.

    Further on from

    7.2 Text manipulation

    we see quite the same. Interestingly 7.2.1.3 Pseudo-text says:

    Pseudo-text may be any sequence of zero or more text-words, comments, and the separator space bounded by, but not including, pseudo-text delimiters.

    So it seems this is actually a bug (at least in GC 2.2 which I had at hand, but I think this is identical in newer versions.

     

Log in to post a comment.