bug-gnucobol
[Top][All Lists]
Advanced

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

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


From: Ehud Karni
Subject: Re: [open-cobol-list] Minor bug (with patch) - INITIALIZE <fld> with FILLER
Date: Sun, 14 Jun 2009 17:14:44 +0300

On Thu, 11 Jun 2009 17:57:53 Ehud Karni wrote:
>
> 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.

My patch was wrong and introduced a huge bug. This was caused by the
use of one flag_statement value for 2 different reasons (see my comment
in tree.h).

I changed the value that is used for "with filler" to 2. There should
be a define for that but I don't know where to put it or how to call it.

The patch bellow should fix the original bug without causing bigger
problems.  For an example program see:
http://sourceforge.net/mailarchive/message.php?msg_name=200906111457.n5BEvrZ9018646%40beta.mvs.co.il

Ehud.


diff -c ~/open-cobol-1.1/cobc/tree.h-sv ~/open-cobol-1.1/cobc/tree.h
*** ~/open-cobol-1.1/cobc/tree.h-sv     Wed Feb  4 18:56:27 2009
--- ~/open-cobol-1.1/cobc/tree.h        Sun Jun 14 16:24:14 2009
***************
*** 936,941 ****
--- 936,947 ----
        cb_tree                 rep;
        cb_tree                 def;
        int                     flag_statement;
+ /* Ehud Karni address@hidden
+    possible values:
+       0 - not a statement - Initialize at start of program
+       1 - user initialize statement - NO "with filler"
+       2 - user initialize statement - with filler
+ */
  };

  #define CB_INITIALIZE(x)      (CB_TREE_CAST (CB_TAG_INITIALIZE, struct 
cb_initialize, x))


diff -c ~/open-cobol-1.1/cobc/typeck.c-sv ~/open-cobol-1.1/cobc/typeck.c
*** ~/open-cobol-1.1/cobc/typeck.c-sv   Wed Jan 28 19:57:25 2009
--- ~/open-cobol-1.1/cobc/typeck.c      Sun Jun 14 16:33:38 2009
***************
*** 3708,3714 ****
                def = cb_true;
        }
        if (fillinit == cb_true) {
!               fill_init = 0;
        }
        for (l = vars; l; l = CB_CHAIN (l)) {
                cb_emit (cb_build_initialize (CB_VALUE (l), value, replacing, 
def, fill_init));
--- 3718,3724 ----
                def = cb_true;
        }
        if (fillinit == cb_true) {
!               fill_init = 2;
        }
        for (l = vars; l; l = CB_CHAIN (l)) {
                cb_emit (cb_build_initialize (CB_VALUE (l), value, replacing, 
def, fill_init));


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     Sun Jun 14 16:32:48 2009
***************
*** 1536,1542 ****
                return INITIALIZE_ONE;
        }

!       if (p->flag_statement && !f->children) {
                if (strlen (f->name) > 4 && f->name[4] == '$') {
                        return INITIALIZE_NONE;
                }
--- 1536,1542 ----
                return INITIALIZE_ONE;
        }

!       if ((p->flag_statement == 2) && !f->children) {
                if (strlen (f->name) > 4 && f->name[4] == '$') {
                        return INITIALIZE_NONE;
                }

--
 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]