-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Recode cob_decimal_pow function - Fix for #924, #925, #989 - add test cases for power operator #182
base: gcos4gnucobol-3.x
Are you sure you want to change the base?
Conversation
- Fixe #924, #925, #989 - add tests case for power operator
Hello @denishug and thank you for your contribution. It is usually requested that contributors add an entry to Example in our PR #191 (merged) |
@@ -1,4 +1,13 @@ | |||
|
|||
2024-09-26 Denis Hugonnard-Roce <[email protected]> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo in the name
* intrinsic.c (cob_decimal_pow) Correct c++ comment style to C | ||
comment style | ||
|
||
2024-09-25 Denis Hugonnard-Roce <[email protected]> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo in the name
/* Fix #925 : Avoid GMPLIB CRASH */ | ||
|
||
mpf_set(cob_mpft3,cob_mpft) ; | ||
if ( sign_nbr == -1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove space before condition
|
||
Process_case_0: | ||
if (sign_nbr == 0) { | ||
if ( sign_exp == 1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove space before condition
if (sign == 0) { | ||
/* 0 ^ 0 */ | ||
cob_set_exception (COB_EC_SIZE_EXPONENTIATION); | ||
sign_nbr = mpz_sgn(pd1->value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In order to strictly follow GnuCOBOL's coding style, a space character should be inserted before function calls. And it shouldn't occur before the ;
character.
For reference, don't hesitate to look at how the code is written elsewhere in GnuCOBOL's source.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this nice piece of work. I think the Changelog entries could be improved and there are some code parts + formatting, but overall quite good!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As those changes are all below libcob, they don't belong here - just revert that file, moving the better text there.
Since quite some time we only Changlog the testsuite if there are "bigger" changes (moving tests around or adding new internal features), so you can drop that part.
* intrinsic.c (cob_decimal_pow) Correct c++ comment style to C | ||
comment style | ||
|
||
2024-09-25 Denis Hugonnard-Roce <[email protected]> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as this is an update to a not-yet-checked in change, just edit the date for the original change and drop the update
AT_CHECK([$COMPILE prog.cob], [0], [], []) | ||
AT_CHECK([$COBCRUN_DIRECT ./prog], [0], [], []) | ||
AT_CLEANUP | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor beautify: please separate test cases with a double empty line - also above
AT_CLEANUP | ||
|
||
AT_SETUP([Power size error and limits cases 2]) | ||
AT_KEYWORDS([POWER]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Words that are in AT_SETUP are automatically added to the keyword list. Replacing it with the main statement - here COMPUTE - would be useful (also applies above).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add an m4 comment about which tests are for which bug report - this provides more context and is also useful in the future
break; | ||
|
||
case 0: | ||
goto Process_case_0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is a single case for this - please inline instead of using goto
mpz_set_ui (pd1->value, 1UL); | ||
pd1->scale = 0; | ||
return; | ||
goto Compute_Power; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please reorder that case to have zero first, this can then return
while the fall-through of 1/-1 is easier to follow and we don't need the Compute_Power
label any more
sign_nbr = mpz_sgn(pd1->value); | ||
sign_exp = mpz_sgn(pd2->value); | ||
|
||
power_case = sign_nbr * sign_exp; | ||
|
||
cob_trim_decimal(pd2); | ||
cob_trim_decimal(pd1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please reformat to use a space before the parenthesis (also applies to other places)?
sign_nbr = mpz_sgn(pd1->value); | ||
sign_exp = mpz_sgn(pd2->value); | ||
|
||
power_case = sign_nbr * sign_exp; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those are all "cheap" and don't break for NAN scale - please const
those three variables directly at the start of the function.
if (mpz_sgn (pd2->value) == -1 | ||
&& mpz_fits_slong_p (pd2->value)) { | ||
|
||
if (mpz_sgn (pd2->value) == -1 ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't that sign_exp
now?
No description provided.