[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[open-cobol-list] Re: Redefines question
From: |
Keisuke Nishida |
Subject: |
[open-cobol-list] Re: Redefines question |
Date: |
Fri Apr 15 08:00:25 2005 |
User-agent: |
Mozilla Thunderbird 1.0 (Windows/20041206) |
This is not that hard. Try the attached patch.
AFAIK, this change is not standard compliant. Don't
forget to make it optional (possibly with -std=mf),
and add a test for this change.
Cheers,
Keisuke
Roger While wrote:
I have had several requests to support redefines whereby
the redefining field is larger than the original field.
Most compilers accept this (with a warning) and it is
allowed in the standards.
Here is an example :
IDENTIFICATION DIVISION.
PROGRAM-ID. redef.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 rxwmain pic x(16).
01 rxwmain2 redefines rxwmain.
03 filler pic xxxx.
03 rxw03lev.
05 rxw051 pic xx.
05 rxw052 redefines rxw051 pic xxx.
03 filler pic xxxx.
03 filler pic xxxx.
03 filler pic xx.
Procedure division.
display "rxwmain " length of rxwmain.
display "rxwmain2 " length of rxwmain2.
display "rxw03lev " length of rxw03lev.
display "rxw051 " length of rxw051.
display "rxw052 " length of rxw052.
stop run.
MF produces 2 warnings for the redefines and executes :
rxwmain 16
rxwmain2 17
rxw03lev 3
rxw051 2
rxw052 3
Notice the sizes have bubbled up. (rxw03lev and rxwmain2)
Notice the main 01 level (rxwmain) has not changed in size BUT it's storage
allocation is now 17.
Any ideas how we can implement this?
Looking at field.c this does not appear to be that easy.
Roger
--- field.c.~1.15.~ 2005-04-13 01:09:37.000000000 +0900
+++ field.c 2005-04-15 23:52:53.000000000 +0900
@@ -518,6 +518,9 @@
{
c->offset = c->redefines->offset;
compute_size (c);
+ /* increase the size if redefinition is larger */
+ if (c->size > c->redefines->size)
+ size += c->size - c->redefines->size;
}
else
{
@@ -629,6 +632,7 @@
}
}
+#if 0
/* the size of redefining field should not be larger than
the size of redefined field unless the redefined filed
is level 01 and non-external */
@@ -638,6 +642,7 @@
> f->redefines->size * f->redefines->occurs_max))
cb_error_x (CB_TREE (f), _("size of '%s' larger than size of '%s'"),
f->name, f->redefines->name);
+#endif
return f->size;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [open-cobol-list] Re: Redefines question,
Keisuke Nishida <=