Menu

copy with replacing option in listing

Anonymous
2021-11-28
2021-12-10
  • Anonymous

    Anonymous - 2021-11-28

    In the source I have:
    COPY "GNU.CPY" REPLACING ==(GNU)== BY ==GNU==.
    This is the copybook:

           01 (GNU)-record.
              03 (GNU)-NAME PIC X(10).
              03 (GNU)-NR   PIC 9(03).
    

    The compilation goes fine, and the program does what it is supposed to do. But the listing says:

    000006         COPY "GNU.CPY" REPLACING ==(GNU)== BY ==GNU==.
    000001C       * copybook with (GNU) prefix
    000002C        01 GNU.
    000003C        03 GNU PIC X(10).
    000004C        03 GNU PIC 9(03).
    

    Is there an compilation option that would give GNU-record etc. ?

     
    • Simon Sobisch

      Simon Sobisch - 2021-12-04

      Cool, that's an error in the listing code (cobc.c only). Cool because that should be quite easy to find and fix.

       
  • Simon Sobisch

    Simon Sobisch - 2021-12-05

    Just an update - it is as I've thought, a general issue in the listings replace handling, so also seen here:

           IDENTIFICATION DIVISION.
           PROGRAM-ID. mymain.
           ENVIRONMENT DIVISION.
           DATA DIVISION.
           WORKING-STORAGE SECTION.
           REPLACE ==(GNU)== BY ==GNU==.
           01 (GNU)-record.
              03 (GNU)-NAME PIC X(10).
              03 (GNU)-NR   PIC 9(03).
           REPLACE ==(GNU)== BY ==YAY==.
           01 (GNU)-record.
              03 (GNU)-NAME PIC X(10).
              03 (GNU)-NR   PIC 9(03).
           PROCEDURE DIVISION.
               MOVE 4      TO GNU-NR
               MOVE 2      TO YAY-NR
               DISPLAY FUNCTION CONCATENATE(GNU-NR(3:), YAY-NR(3:))
               MOVE GNU-NR TO YAY-NR
               DISPLAY FUNCTION CONCATENATE(GNU-NR(3:), YAY-NR(3:))
               GOBACK.
    

    which compiles and executes fine (displaying 42, then 44), but has a bad listing:

    LINE    PG/LN  A...B............................................................
    
    000001         IDENTIFICATION DIVISION.
    000002         PROGRAM-ID. mymain.
    000003         ENVIRONMENT DIVISION.
    000004         DATA DIVISION.
    000005         WORKING-STORAGE SECTION.
    000006         REPLACE ==(GNU)== BY ==GNU==.
    000007         01 GNU.
    000008         03 GNU PIC X(10).
    000009         03 GNU PIC 9(03).
    000010         REPLACE ==(GNU)== BY ==YAY==.
    000011         01 GNU.
    000012         03 GNU PIC X(10).
    000013         03 GNU PIC 9(03).
    000014         PROCEDURE DIVISION.
    000015             MOVE 4      TO GNU-NR
    000016             MOVE 2      TO YAY-NR
    000017             DISPLAY FUNCTION CONCATENATE(GNU-NR(3:), YAY-NR(3:))
    000018             MOVE GNU-NR TO YAY-NR
    000019             DISPLAY FUNCTION CONCATENATE(GNU-NR(3:), YAY-NR(3:))
    000020             GOBACK.
    

    So next is inspecting the actual code in cobc.c.

     
  • Michael F Gleason

    This has been a pet peeve of mine. The copy messes up my indentations and formatting of working storage copies when you have a rename.
    I just quit looking at the copied parts of listings from my compiles. I know it is hard to do, but copy replacing is so VERY powerful it deserves ATTENTION. Considering what cobc is capable of digesting, I think copy replacing should be brought up to the same standard. (EXCELLENT).

    I'm still getting my monies worth out of GnuCobol.

     
    👍
    1

Anonymous
Anonymous

Add attachments
Cancel