Skip to content

Commit

Permalink
Merge SVN 5188
Browse files Browse the repository at this point in the history
  • Loading branch information
ddeclerck committed Jan 28, 2025
1 parent fb111a5 commit b304697
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
4 changes: 2 additions & 2 deletions libcob/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@

* numeric.c (cob_add_int): minor adjustment to scale handling
* numeric.c (packed_is_negative): optimized by memcmp instead of loop
* numeric.c (cob_decimal_get_display): fixed broken sign in diff calculation
and replaced it by an assert as it currently is never to be executed
* numeric.c (cob_decimal_get_display): fixed broken sign in
diff calculation

2023-08-30 Simon Sobisch <[email protected]>

Expand Down
14 changes: 3 additions & 11 deletions libcob/numeric.c
Original file line number Diff line number Diff line change
Expand Up @@ -1479,16 +1479,10 @@ cob_decimal_get_display (cob_decimal *d, cob_field *f, const int opt)
/* Build string, note: we can't check the decimal size with
mpz_sizeinbase, as its result is "either exact or one too big" */

/* huge data, only for internal operations like intrinsic functions */
/* LCOV_EXCL_START */
/* huge data, only for internal operations like intrinsic functions,
for example when directly called within intrinsic.c by
cob_alloc_field, cob_decimal_get_field -> cob_decimal_get_display */
if (fsize > COB_MAX_BINARY) {
#if 1 /* as these fields cannot be a _target_ to get the decimal value
as intrinisic.c (cob_alloc_field, cob_decimal_move_temp) _creates_
those from a decimal already, this branch should never be taken */
cob_runtime_error ("function '%s' with unexpected state (%s)",
"cob_decimal_get_display", "huge decimal for numeric DISPLAY field");
cob_hard_failure ();
#else
char *p = mpz_get_str (NULL, 10, d->value);
const size_t size = strlen (p);
const long long diff = fsize - size;
Expand Down Expand Up @@ -1516,9 +1510,7 @@ cob_decimal_get_display (cob_decimal *d, cob_field *f, const int opt)
cob_gmp_free (p);
COB_PUT_SIGN (f, sign);
return 0;
#endif
}
/* LCOV_EXCL_STOP */

/* get divisor that would overflow */
cob_pow_10 (cob_mexp, (unsigned int) fsize);
Expand Down

0 comments on commit b304697

Please sign in to comment.