Skip to content

Commit

Permalink
Merge branch 'gnucobol-3.x' into gcos4gnucobol-3.x
Browse files Browse the repository at this point in the history
  • Loading branch information
lefessan committed Jan 31, 2024
2 parents 824f2a6 + 47ffbd8 commit 2ff35a3
Show file tree
Hide file tree
Showing 6 changed files with 402 additions and 67 deletions.
97 changes: 51 additions & 46 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ NEWS - user visible changes -*- outline -*-
* Important Bugfixes

** #904: MOVE PACKED-DECIMAL unsigned to signed led to bad sign
** Padding bytes of BCD may store a non-truncated digit; while
this has no effect on calculations it can create problems on
later binary comparison of the field as well as on group MOVEs
** #918: COB_LS_VALIDATE (io status 09 and 71) partial broken

* Changes to the COBOL compiler (cobc) options:
Expand All @@ -31,9 +34,57 @@ NEWS - user visible changes -*- outline -*-
* More notable changes

** execution times were significantly reduced for the following:
comparison between a numeric DISPLAY variable to another or to a literal
comparison between numeric DISPLAY or BCD variable to zero
INSPECT CONVERTING (and "simple" INSPECT REPLACING), in general
and especially if both from and to are constants

* Known issues in 3.x

** testsuite:
* if built with vbisam, cisam or disam, depending on the version used, some
tests will lead to UNEXPECTED PASS, while others may fail
* possibly failing tests (false positives):
* temporary path invalid
* compiler outputs (assembler)
* compile from stdin
* NIST: OBNC1M.CBL false positive (the test runner uses a nonportable way of
emulating a program kill)
* if build with -fsanitize, then some tests will fail; while we accept patches
to improve that, we don't consider the failing tests as bug in GnuCOBOL

** the recent additions of ">> TURN" and "variable LIKE variable" may not work
as expected in all cases

** floating-point comparison for equality may return unexpected results as it
involves a necessary tolerance; you may adjust the default tolerance of
0.0000001 by compiling GnuCOBOL for example with
LIBCOB_CPPFLAGS="-DCOB_FLOAT_DELTA=0.0000000000001";
we seek input for a reasonable default for GnuCOBOL 4 (use the mailing list
or discussion board to share your comments on this topic, keeping in mind
that this has to take both mathematical and "C compiler portability" into
account)

** variables containing PICTURE symbol P may lead to wrong results in rare
cases (especially screenio) - please send a bug report if you catch a case;
since GC 3.2 rc3 all arithmetic operations and MOVE are believed to be
correct

** features that are known to not be portable to every environment yet
(especially when using a different compiler than GCC)
* function with variable-length RETURNING item
* USAGE POINTER, which may need to be manually aligned

** all versions of GnuCOBOL so far: EVALUATE evaluates all subjects on *each*
WHEN (the standard explicit requests a one-time evaluation of the subjects,
then comparing the value); to work around possible issues move more complex
subjects like variables with subscripts and reference-modification, as well
as calculated subjects and function calls to a temporary variable and use
this as subject for the EVALUATE

For more known issues see the bug tracker.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

GnuCOBOL 3.2 (20230728)
GnuCOBOL 3.2rc1 (20230118)
Expand Down Expand Up @@ -537,52 +588,6 @@ NEWS - user visible changes -*- outline -*-

** undocumented option -tsymbols, which was replaced by -ftsymbols in 3.0


* Known issues in 3.2 (and 3.1)

** testsuite:
* if built with vbisam, cisam or disam, depending on the version used, some
tests will lead to UNEXPECTED PASS, while others may fail
* possibly failing tests (false positives):
* temporary path invalid
* compiler outputs (assembler)
* compile from stdin
* NIST: OBNC1M.CBL false positive (the test runner uses a nonportable way of
emulating a program kill)
* if build with -fsanitize, then some tests will fail; while we accept patches
to improve that, we don't consider the failing tests as bug in GnuCOBOL

** the recent additions of ">> TURN" and "variable LIKE variable" may not work
as expected in all cases

** floating-point comparison for equality may return unexpected results as it
involves a necessary tolerance; you may adjust the default tolerance of
0.0000001 by compiling GnuCOBOL for example with
LIBCOB_CPPFLAGS="-DCOB_FLOAT_DELTA=0.0000000000001";
we seek input for a reasonable default for GnuCOBOL 4 (use the mailing list
or discussion board to share your comments on this topic, keeping in mind
that this has to take both mathematical and "C compiler portability" into
account)

** variables containing PICTURE symbol P may lead to wrong results in rare
cases (especially screenio) - please send a bug report if you catch a case;
since GC 3.2 rc3 all arithmetic operations and MOVE are believed to be
correct

** features that are known to not be portable to every environment yet
(especially when using a different compiler than GCC)
* function with variable-length RETURNING item
* USAGE POINTER, which may need to be manually aligned

** all versions of GnuCOBOL so far: EVALUATE evaluates all subjects on *each*
WHEN (the standard explicit requests a one-time evaluation of the subjects,
then comparing the value); to work around possible issues move more complex
subjects like variables with subscripts and reference-modification, as well
as calculated subjects and function calls to a temporary variable and use
this as subject for the EVALUATE

For more known issues see the bug tracker.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

GnuCOBOL 3.1.2 released (20201223)
Expand Down
8 changes: 8 additions & 0 deletions cobc/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@
do not move object files and preprocess files when they were
specified as an explicit target on the command line (-E, -c)

2023-09-20 Simon Sobisch <[email protected]>

* typeck.c (cb_build_optim_cond): generate calls to new functions
for numeric zero compare for USAGE DISPLAY and PACKED, as well
as comparison between two USAGE DISPLAY or USAGE DISPLAY to literal
* typeck.c (validate_move): internally change literals like 0.00
to zero constant allowing use of optimized MOVE code

2023-10-17 David Declerck <[email protected]>

BUG #923: generated modules init/clear unused decimal constants
Expand Down
85 changes: 69 additions & 16 deletions cobc/typeck.c
Original file line number Diff line number Diff line change
Expand Up @@ -6701,7 +6701,7 @@ cb_build_optim_cond (struct cb_binary_op *p)
const char *s;
size_t n;
const cb_tree left = p->x;
const cb_tree right = p->y;
cb_tree right = p->y;
struct cb_field *f = CB_REF_OR_FIELD_P (left)
? CB_FIELD_PTR (left) : NULL;

Expand All @@ -6723,10 +6723,19 @@ cb_build_optim_cond (struct cb_binary_op *p)
if (!cb_fits_long_long (right)) {
return NULL;
}
/* CHECKME: can we have a non-field left and field right? */
return CB_BUILD_FUNCALL_2 ("cob_cmp_llint", left,
cb_build_cast_llint (right));
}

/* test for numeric zero literal */
if (CB_LITERAL_P (right)) {
struct cb_literal *l = CB_LITERAL (right);
if (memcmp (l->data, COB_ZEROES_ALPHABETIC, l->size) == 0) {
right = cb_zero;
}
}

#if 0 /* TODO: if the right side is a literal: then build an ideal
memcmp as if it was a field of same attributes as left-side,
with the value of the literal */
Expand All @@ -6740,6 +6749,39 @@ cb_build_optim_cond (struct cb_binary_op *p)
}
}
#endif

/* if the field is DISPLAY and the right side either a literal, a constant (ZERO)
or also a DISPLAY field, then no need to convert the field(s) to an integer */
if (f->usage == CB_USAGE_DISPLAY) {
if (CB_REF_OR_FIELD_P (right)) {
if (CB_FIELD_PTR (right)->usage == CB_USAGE_DISPLAY) {
return CB_BUILD_FUNCALL_2 ("cob_numeric_display_cmp", left, right);
}
} else
if (CB_LITERAL_P (right)) {
if (f->pic->scale
|| f->pic->digits >= 19
|| ( CB_LITERAL_P (right)
&& ( CB_LITERAL (right)->scale
|| CB_LITERAL (right)->size > 19))) {
return CB_BUILD_FUNCALL_2 ("cob_numeric_display_cmp", left, right);
}
} else
if (right == cb_zero) {
if (!f->flag_sign_separate
&& !f->flag_any_numeric
&& !cb_ebcdic_sign) {
return CB_BUILD_FUNCALL_1 ("cob_numeric_display_cmp_zero", left);
}
/* for simple fields an integer-comparision is fast and inlined, so
we only use the DISPLAY compare if it is "complex" */
if (f->pic->scale
|| f->pic->digits >= 19) {
return CB_BUILD_FUNCALL_2 ("cob_numeric_display_cmp", left, right);
}
}
}

if (f->usage == CB_USAGE_PACKED
|| f->usage == CB_USAGE_COMP_6) {
if (CB_REF_OR_FIELD_P (right)) {
Expand All @@ -6757,6 +6799,9 @@ cb_build_optim_cond (struct cb_binary_op *p)
}
}
}
} else
if (right == cb_zero) {
return CB_BUILD_FUNCALL_1 ("cob_bcd_cmp_zero", left);
}
}

Expand Down Expand Up @@ -10210,8 +10255,8 @@ validate_inspect (cb_tree x, cb_tree y, const unsigned int replacing_or_converti
size2 = CB_LITERAL (y)->size;
break;
case CB_TAG_CONST:
/* note: in case of CONST (like SPACES or LOW-VALUES)
the original size is used in libcob */
/* note: in case of CONST (like SPACES or LOW-VALUES)
the original size is used in libcob */
/* Fall-through */
default:
size2 = 0;
Expand Down Expand Up @@ -11070,23 +11115,24 @@ validate_move (cb_tree src, cb_tree dst, const unsigned int is_value, int *move_
}
if (leftmost_significant == l->size) {
most_significant = -999;
least_significant = 999;
} else {
most_significant = l->size - l->scale - leftmost_significant;
if (most_significant < 1) most_significant--;
}

/* Compute the least significant figure place
in relatation to the decimal point (negative = decimal position) */
for (i = l->size - 1; i != 0; i--) {
if (l->data[i] != '0') {
break;
/* Compute the least significant figure place
in relatation to the decimal point (negative = decimal position) */
for (i = l->size - 1; i != 0; i--) {
if (l->data[i] != '0') {
break;
}
}
if (i == 0) {
least_significant = 999;
} else {
least_significant = l->size - l->scale - i;
if (least_significant < 1) least_significant--;
}
}
if (i == 0) {
least_significant = 999;
} else {
least_significant = (l->size - l->scale) - i;
if (least_significant < 1) least_significant--;
}

/* Value check */
Expand Down Expand Up @@ -11123,6 +11169,13 @@ validate_move (cb_tree src, cb_tree dst, const unsigned int is_value, int *move_
case CB_CATEGORY_NUMERIC:
{
const struct cb_picture *pic = fdst->pic;
if (most_significant == -999
&& l->sign == 0) {
/* replace assignments of unsigned 000.0000 to a numeric value
by optimized zero-move */
*move_zero = 1;
break;
}
if (pic->scale < 0) {
/* Check for PIC 9(n)P(m) */
if (least_significant <= -pic->scale) {
Expand Down Expand Up @@ -11168,7 +11221,7 @@ validate_move (cb_tree src, cb_tree dst, const unsigned int is_value, int *move_
/* Size check */
if (fdst->flag_real_binary
|| ( !cb_binary_truncate
&& fdst->pic->scale <= 0
&& fdst->pic->scale <= 0
&& ( fdst->usage == CB_USAGE_COMP_5
|| fdst->usage == CB_USAGE_COMP_X
|| fdst->usage == CB_USAGE_COMP_N
Expand Down
14 changes: 14 additions & 0 deletions libcob/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,20 @@
* fileio.c (lineseq_write, lineseq_rewrite): fix bug #918 partial broken
COB_LS_VALIDATE by incrementing pointer outside of macro IS_BAD_CHAR

2023-09-20 Simon Sobisch <[email protected]>

* numeric.c (cob_numdisp_cmp): adjusted
* numeric.c (cob_numeric_display_cmp_zero, cob_bcd_cmp_zero), common.h:
new functions for optimized check of common compare
* numeric.c (cob_set_packed_u64): restore cleanup code for padding byte,
but only execute it if we wrote to first data position

2023-09-19 Chuck Haatvedt <[email protected]>

* numeric.c (cob_numdisp_cmp): new version cob_numeric_display_cmp that
does NOT do any conversion to integer formats, also it does not use any
temporary buffers to do the compare which should improve its performance

2023-09-15 Simon Sobisch <[email protected]>

Fixing Bug #914 CLOSE LOCK abends program on OPEN
Expand Down
3 changes: 3 additions & 0 deletions libcob/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -1935,6 +1935,9 @@ COB_EXPIMP int cob_check_linkage_size (const char *,
/* Comparison functions */
COB_EXPIMP int cob_numeric_cmp (cob_field *, cob_field *);
COB_EXPIMP int cob_bcd_cmp (cob_field *, cob_field *);
COB_EXPIMP int cob_numeric_display_cmp (cob_field *, cob_field *);
COB_EXPIMP int cob_numeric_display_cmp_zero (cob_field *);
COB_EXPIMP int cob_bcd_cmp_zero (cob_field *);

/*******************************/
/* Functions in strings.c */
Expand Down
Loading

0 comments on commit 2ff35a3

Please sign in to comment.