bug-gnucobol
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[open-cobol-list] BUG: "COPY REPLACING ..." and REQUEST for "mini-list


From: Thomas Biehler
Subject: [open-cobol-list] BUG: "COPY REPLACING ..." and REQUEST for "mini-listing"
Date: Thu Feb 12 08:30:03 2004
User-agent: KMail/1.4.3

Hi Keisuke,

The bug in the "COPY REPLACING" is 
the wrong order of the replacements.
(error: the created chain of replacment-texts is in 
 LIFO order instead of FIFO order!)

You can integrate the following test in autotest-format:
===================================================
AT_SETUP([COPY REPLACING : correct order of replacement])

AT_DATA([copy.inc], [
       01 TEST-VAR  PIC X(12) VALUE "REPLACING OK".
])

AT_DATA([prog.cob], [
       IDENTIFICATION   DIVISION.
       PROGRAM-ID.      prog.
       DATA             DIVISION.
       WORKING-STORAGE  SECTION.
       COPY "copy.inc"
          REPLACING ==TEST-VAR== BY ==FIRST-MATCH== ,
                    ==TEST-VAR== BY ==SECOND-MATCH== .
       PROCEDURE        DIVISION.
           DISPLAY  FIRST-MATCH  NO ADVANCING.
           STOP RUN.
])

AT_CHECK([${COMPILE} -save-temps -o prog prog.cob])
AT_CHECK([./prog], [0], [REPLACING OK])

AT_CLEANUP
=======================================================

I have integrated it with (misc.at) but i think a new "copy_replace.at" would
be the better decision for the future!  (much work / tests are necessary!)

================================================
REQUEST for "mini-listing":
================================================
with the MF-Cobol Compiler i have created the following mini-listing:
(command: "cob prog.cob -CRAWLIST -CCOPYLIST -C LIST=prog.list -C NORESEQ")
====================================================

       IDENTIFICATION   DIVISION.
       PROGRAM-ID.      prog.
       DATA             DIVISION.
       WORKING-STORAGE  SECTION.
*      COPY "copy.inc"
*         REPLACING ==TEST-VAR== BY ==FIRST-MATCH== ,
*                   ==TEST-VAR== BY ==SECOND-MATCH== .

       01  FIRST-MATCH PIC X(12) VALUE "REPLACING OK".
       PROCEDURE        DIVISION.
           DISPLAY  FIRST-MATCH  NO ADVANCING.
           STOP RUN.
====================================================
 
With this format of "mini-listing" you can easily diff the original 
cobol-program and the cobol text after the "text replacement" phase.

example:
#> diff prog.cob prog.list
6,8c6,10
<        COPY "copy.inc"
<           REPLACING ==TEST-VAR== BY ==FIRST-MATCH== ,
<                     ==TEST-VAR== BY ==SECOND-MATCH== .
---
> *      COPY "copy.inc"
> *         REPLACING ==TEST-VAR== BY ==FIRST-MATCH== ,
> *                   ==TEST-VAR== BY ==SECOND-MATCH== .
> 
>        01  FIRST-MATCH PIC X(12) VALUE "REPLACING OK".

The "mini-listing format" above is not far away from 
the "-save-temps prog.i"  / "cobc -E" format !

Here is the summary of the differences: 
- no line numbers:  # 1 "prog.cob"  etc. (added from cobc)
- Text evaluated as a  "Comment" is not converted to blank 
  (only a "pass through") 
- the COPY  REPLACING  ...  / REPLACE Statements are marked as a comment 
  (here  "*" in the first column, could be other marker!) 
     "cobc -E" blanks those lines!
  (annotation: 
      ==> if you diff with the cobc -E listing than this behavior
             will generate many differences in real world cases! 
              ==> useless diff output!
  )

The following is the normal behavior from "cobc -E": (nothing to change)
- the COPY "replaced" library-text is in the output
   (in the" mini-listing" after the  COPY / REPLACE statements.

If this request is implemented:
 -  every cobc user can better see what text replacement of cobc is doing
 -  every porter from mf-cobol can diff the listing to find bugs
    or unimplemented features                 
 -  if cobc make a error in replacement,  you can fix this in the listing
    and compiles this listing (for workaround) 
    ==> faster developement-cycles!
  
Shall i be patient ?    :-))

Thomas

P.S.
   - test 40 from cobol2002-run "MOVE with intermediate item" 
     fails after your latest changes!
 
  - you have wrote in another bug mail:
     I'll try to implement the complete text manipulation process before long.
  ==> I don't unterstand  the I'll try short form in this context 
         (with "before long"). 
    (Shall / Should  or  Will try -> Future  ???)
     Please, could you write it for me in a long form?
     Remember, i am a non native english speaker. ;-) 

  - the last topic for today: 
    in ANSI 1985 / 2002 standard is the period after the COPY / REPLACE 
    always mandatory!  the optional period is non-conforming behavior !
    described   in 1985 in Syntax-Rules,  2.3 (2) and 3.3 (2)
                     in 2002 in Syntax-Diagramm  and General-Rules 7.1.2.3 (6)  
 
    but the standards of the TEXT-Replacing are somehow "confusing"  ;-)
     


Attachment: copy.inc
Description: Text document

Attachment: prog.cob
Description: Text document

Attachment: prog.i
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]