bug-gnucobol
[Top][All Lists]
Advanced

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

[open-cobol-list] Minor bug (with patch) - INITIALIZE <fld> with FILLER


From: Ehud Karni
Subject: [open-cobol-list] Minor bug (with patch) - INITIALIZE <fld> with FILLER
Date: Thu, 11 Jun 2009 17:57:53 +0300

There is a minor bug in open-cobol-1.1 (2009-02-06).

When doing INITIALIZE <fld> with FILLER, and <fld> is either 01 in the
file section or a redefinition, no code is emitted.

This is caused by a check in codgen.c which is wrong, because there is
NO connection of redefined fields and the "with filler" option.

An example program is listed after the patch that fixes the bug.

Ehud.


diff -c ~/open-cobol-1.1/cobc/codegen.c-sv ~/open-cobol-1.1/cobc/codegen.c
*** ~/open-cobol-1.1/cobc/codegen.c-sv  Wed Jan 28 20:18:21 2009
--- ~/open-cobol-1.1/cobc/codegen.c     Thu Jun 11 16:50:19 2009
***************
*** 1528,1534 ****
                return INITIALIZE_EXTERNAL;
        }

!       if (f->redefines && (!topfield || !p->flag_statement)) {
                return INITIALIZE_NONE;
        }

--- 1528,1534 ----
                return INITIALIZE_EXTERNAL;
        }

!       if (f->redefines && !topfield) {
                return INITIALIZE_NONE;
        }



Example program:

       identification division.
       program-id.     tst-init.
       environment     division.
       input-output    section.
       file-control.
           select  fsx  assign  to  "FSX"
                   organization is line sequential.
       data division.
       file section.
       fd  fsx.
       01  fs-rec.
           03  fs1.
               05  fs1-num1            pic 9(02).
               05  fs1-x1              pic x(01).
               05  fs1-num2            pic 9(02).
               05  filler              pic x(01).
           03  fs2                 pic 9(05).
       working-storage section.
       01  wrec-0          pic x(11).
       01  wrec  redefines  wrec-0.
           03  wr1.
               05  wr1-num1            pic 9(02).
               05  wr1-x1              pic x(01).
               05  wr1-num2            pic 9(02).
               05  filler              pic x(01).
           03  wr2                 pic 9(05).
       procedure division.
           move all "A" to wrec.
           initialize wrec with filler.
           display  wrec.
           move all "B" to wrec.
           initialize wrec.
           display  wrec.
           move all "C" to wrec.
           initialize wr1 wr2  with filler.
           display  wrec.
      * ------------------------------
           open output fsx.
           move all "D" to fs-rec.
           initialize fs-rec with filler.
           display  fs-rec.
           write fs-rec.
           move all "E" to fs-rec.
           initialize fs-rec.
           display  fs-rec.
           write fs-rec.
           move all "F" to fs-rec.
           initialize fs1 fs2 with filler.
           display  fs-rec.
           write fs-rec.
           close fsx.
      * ------------------------------
           move 0 to return-code.
           stop run.



--
 Ehud Karni           Tel: +972-3-7966-561  /"\
 Mivtach - Simon      Fax: +972-3-7966-667  \ /  ASCII Ribbon Campaign
 Insurance agencies   (USA) voice mail and   X   Against   HTML   Mail
 http://www.mvs.co.il  FAX:  1-815-5509341  / \
 GnuPG: 98EA398D <http://www.keyserver.net/>    Better Safe Than Sorry


reply via email to

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