Skip to content

Commit

Permalink
Fix binary size computation for binary-size=2-4-8
Browse files Browse the repository at this point in the history
  • Loading branch information
ddeclerck committed Oct 31, 2024
1 parent 480b5fd commit e766efe
Show file tree
Hide file tree
Showing 7 changed files with 393 additions and 314 deletions.
12 changes: 12 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,18 @@ NEWS - user visible changes -*- outline -*-
patterns where invalid numerical data (e.g, SPACES) encode "absent"
data

** #1000: dialects without support of single byte binary data
will now generate at least 2 bytes of storage for COMP-5 elements; this
applies to all non-standard dialects but GnuCOBOL (default) and Micro Focus;
that changes the group length of records containing elements with less than
3 digits and also passes different sizes via CALL, which may need program
adjustments.

** -std=acu / -std=acu-strict now generate BINARY and COMP-5 with at least
2 bytes of storage; the comment for #NNN above applies; if you want
to still use the sizes used since GnuCOBOL 2.2 with those dialects:
add -fbinary-size=1-2-4-8 to your compile options

* Important Bugfixes

** #904: MOVE PACKED-DECIMAL unsigned to signed led to bad sign
Expand Down
8 changes: 8 additions & 0 deletions cobc/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@

2024-10-29 Simon Sobisch <[email protected]>

BUG #1000: Wrong binary size computed for COMP-5 PIC 9
and PIC 99 when binary-size=2-4-8
* field.c (validate_elementary_item): only set flag_real_binary for
BINARY-CHAR/BINARY-SHORT/BINARY-LONG/BINARY-DOUBLE
* codegenc (output_attr): generate COB_FLAG_REAL_BINARY also for COMP-5

2024-10-02 Simon Sobisch <[email protected]>

* pplex.l (output_line_directive): extracted from other places and
Expand Down
27 changes: 14 additions & 13 deletions cobc/codegen.c
Original file line number Diff line number Diff line change
Expand Up @@ -1630,27 +1630,28 @@ output_attr (const cb_tree x)
if (f->flag_binary_swap) {
flags |= COB_FLAG_BINARY_SWAP;
}
if (f->flag_real_binary) {
if (f->flag_real_binary
|| f->usage == CB_USAGE_COMP_5) {
flags |= COB_FLAG_REAL_BINARY;
}
if (f->flag_is_pointer) {
flags |= COB_FLAG_IS_POINTER;
}
if (cb_binary_truncate &&
f->usage == CB_USAGE_BINARY &&
!f->flag_real_binary) {
if (cb_binary_truncate
&& f->usage == CB_USAGE_BINARY
&& !f->flag_real_binary) {
flags |= COB_FLAG_BINARY_TRUNC;
}

if (type == COB_TYPE_NUMERIC_BINARY
&& f->usage == CB_USAGE_INDEX) {
flags |= COB_FLAG_REAL_BINARY;
type = COB_TYPE_NUMERIC_COMP5;
} else
if (type == COB_TYPE_NUMERIC_BINARY
&& (f->flag_binary_swap || f->flag_real_binary)
&& (f->flag_indexed_by || f->index_type || f->flag_internal_register)) {
type = COB_TYPE_NUMERIC_COMP5;
if (type == COB_TYPE_NUMERIC_BINARY) {
if (f->usage == CB_USAGE_INDEX) {
flags |= COB_FLAG_REAL_BINARY;
type = COB_TYPE_NUMERIC_COMP5;
} else
if ((f->flag_binary_swap || f->flag_real_binary)
&& (f->flag_indexed_by || f->index_type || f->flag_internal_register)) {
type = COB_TYPE_NUMERIC_COMP5;
}
}
switch (f->usage) {
case CB_USAGE_COMP_6:
Expand Down
5 changes: 0 additions & 5 deletions cobc/field.c
Original file line number Diff line number Diff line change
Expand Up @@ -2269,9 +2269,6 @@ validate_elementary_item (struct cb_field *f)
f->pic = cb_build_binary_picture ("BINARY-DOUBLE", 18, 0);
f->flag_real_binary = 1;
break;
case CB_USAGE_COMP_5:
f->flag_real_binary = 1;
break;
default:
break;
}
Expand Down Expand Up @@ -2516,8 +2513,6 @@ setup_parameters (struct cb_field *f)
break;

case CB_USAGE_COMP_5:
f->flag_real_binary = 1;
/* Fall-through */
case CB_USAGE_COMP_X:
case CB_USAGE_COMP_N:
if (f->pic->category == CB_CATEGORY_ALPHANUMERIC) {
Expand Down
4 changes: 4 additions & 0 deletions config/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@

2024-10-31 Simon Sobisch <[email protected]>

* acu-strict.conf: change binary-size from 1-2-4-8 to 2-4-8

2024-08-17 Ammar Almoris <[email protected]>

FR #474: add runtime configuration to hide cursor for extended screenio
Expand Down
2 changes: 1 addition & 1 deletion config/acu-strict.conf
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ indirect-redefines: yes
# 15 - 16 15 - 16 7
# 17 - 18 17 - 18 8
#
binary-size: 1-2-4-8 # not verified yet
binary-size: 2-4-8 # TODO: add 2-4-8-12-16

# Numeric truncation according to ANSI
binary-truncate: yes
Expand Down
Loading

0 comments on commit e766efe

Please sign in to comment.