Skip to content

Commit e766efe

Browse files
committed
Fix binary size computation for binary-size=2-4-8
1 parent 480b5fd commit e766efe

File tree

7 files changed

+393
-314
lines changed

7 files changed

+393
-314
lines changed

NEWS

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,18 @@ NEWS - user visible changes -*- outline -*-
3333
patterns where invalid numerical data (e.g, SPACES) encode "absent"
3434
data
3535

36+
** #1000: dialects without support of single byte binary data
37+
will now generate at least 2 bytes of storage for COMP-5 elements; this
38+
applies to all non-standard dialects but GnuCOBOL (default) and Micro Focus;
39+
that changes the group length of records containing elements with less than
40+
3 digits and also passes different sizes via CALL, which may need program
41+
adjustments.
42+
43+
** -std=acu / -std=acu-strict now generate BINARY and COMP-5 with at least
44+
2 bytes of storage; the comment for #NNN above applies; if you want
45+
to still use the sizes used since GnuCOBOL 2.2 with those dialects:
46+
add -fbinary-size=1-2-4-8 to your compile options
47+
3648
* Important Bugfixes
3749

3850
** #904: MOVE PACKED-DECIMAL unsigned to signed led to bad sign

cobc/ChangeLog

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11

2+
2024-10-29 Simon Sobisch <[email protected]>
3+
4+
BUG #1000: Wrong binary size computed for COMP-5 PIC 9
5+
and PIC 99 when binary-size=2-4-8
6+
* field.c (validate_elementary_item): only set flag_real_binary for
7+
BINARY-CHAR/BINARY-SHORT/BINARY-LONG/BINARY-DOUBLE
8+
* codegenc (output_attr): generate COB_FLAG_REAL_BINARY also for COMP-5
9+
210
2024-10-02 Simon Sobisch <[email protected]>
311

412
* pplex.l (output_line_directive): extracted from other places and

cobc/codegen.c

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1630,27 +1630,28 @@ output_attr (const cb_tree x)
16301630
if (f->flag_binary_swap) {
16311631
flags |= COB_FLAG_BINARY_SWAP;
16321632
}
1633-
if (f->flag_real_binary) {
1633+
if (f->flag_real_binary
1634+
|| f->usage == CB_USAGE_COMP_5) {
16341635
flags |= COB_FLAG_REAL_BINARY;
16351636
}
16361637
if (f->flag_is_pointer) {
16371638
flags |= COB_FLAG_IS_POINTER;
16381639
}
1639-
if (cb_binary_truncate &&
1640-
f->usage == CB_USAGE_BINARY &&
1641-
!f->flag_real_binary) {
1640+
if (cb_binary_truncate
1641+
&& f->usage == CB_USAGE_BINARY
1642+
&& !f->flag_real_binary) {
16421643
flags |= COB_FLAG_BINARY_TRUNC;
16431644
}
16441645

1645-
if (type == COB_TYPE_NUMERIC_BINARY
1646-
&& f->usage == CB_USAGE_INDEX) {
1647-
flags |= COB_FLAG_REAL_BINARY;
1648-
type = COB_TYPE_NUMERIC_COMP5;
1649-
} else
1650-
if (type == COB_TYPE_NUMERIC_BINARY
1651-
&& (f->flag_binary_swap || f->flag_real_binary)
1652-
&& (f->flag_indexed_by || f->index_type || f->flag_internal_register)) {
1653-
type = COB_TYPE_NUMERIC_COMP5;
1646+
if (type == COB_TYPE_NUMERIC_BINARY) {
1647+
if (f->usage == CB_USAGE_INDEX) {
1648+
flags |= COB_FLAG_REAL_BINARY;
1649+
type = COB_TYPE_NUMERIC_COMP5;
1650+
} else
1651+
if ((f->flag_binary_swap || f->flag_real_binary)
1652+
&& (f->flag_indexed_by || f->index_type || f->flag_internal_register)) {
1653+
type = COB_TYPE_NUMERIC_COMP5;
1654+
}
16541655
}
16551656
switch (f->usage) {
16561657
case CB_USAGE_COMP_6:

cobc/field.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2269,9 +2269,6 @@ validate_elementary_item (struct cb_field *f)
22692269
f->pic = cb_build_binary_picture ("BINARY-DOUBLE", 18, 0);
22702270
f->flag_real_binary = 1;
22712271
break;
2272-
case CB_USAGE_COMP_5:
2273-
f->flag_real_binary = 1;
2274-
break;
22752272
default:
22762273
break;
22772274
}
@@ -2516,8 +2513,6 @@ setup_parameters (struct cb_field *f)
25162513
break;
25172514

25182515
case CB_USAGE_COMP_5:
2519-
f->flag_real_binary = 1;
2520-
/* Fall-through */
25212516
case CB_USAGE_COMP_X:
25222517
case CB_USAGE_COMP_N:
25232518
if (f->pic->category == CB_CATEGORY_ALPHANUMERIC) {

config/ChangeLog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11

2+
2024-10-31 Simon Sobisch <[email protected]>
3+
4+
* acu-strict.conf: change binary-size from 1-2-4-8 to 2-4-8
5+
26
2024-08-17 Ammar Almoris <[email protected]>
37

48
FR #474: add runtime configuration to hide cursor for extended screenio

config/acu-strict.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ indirect-redefines: yes
8888
# 15 - 16 15 - 16 7
8989
# 17 - 18 17 - 18 8
9090
#
91-
binary-size: 1-2-4-8 # not verified yet
91+
binary-size: 2-4-8 # TODO: add 2-4-8-12-16
9292

9393
# Numeric truncation according to ANSI
9494
binary-truncate: yes

0 commit comments

Comments
 (0)