-
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
Fix BLANK WHEN ZERO on signed NUMERIC-EDITED #201
Conversation
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 your work on this again.
Please recheck the leading sign issue by adjusting the test case.
libcob/move.c
Outdated
if (COB_FIELD_HAVE_SIGN (f1) && COB_FIELD_SIGN_SEPARATE (f1)) { | ||
for (; (src < src_end) ; src++) { | ||
if (*src != '0') break; | ||
} | ||
if (src >= src_end) { | ||
memset (dst, (int)' ', (size_t)f2->size); | ||
return; | ||
} | ||
} else { | ||
for (; (src <= src_end) ; src++) { | ||
if (*src != '0') break; | ||
} | ||
if (src > src_end) { | ||
memset (dst, (int)' ', (size_t)f2->size); | ||
return; | ||
} |
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 change it to use something like const unsigned char *check_end = !COB_FIELD_SIGN_SEPARATE (f1) ? src_end : src_end - 1;
instead to reduce the duplication.
Also: What about separate and leading sign?
And... where are the overpunched positions checked? As we just had that in the other PR: What about invalid data - should we check with COB_D2I() = 0
instead?
Note: I think there's no use in explicit casting a char to int, is it? The field->size is size_t already, so that should be dropped in any case.
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.
Also: What about separate and leading sign? And... where are the overpunched positions checked?
There is an invariant here that f1
either has no sign or has a trailing separate sign (as checked by the block between #ifndef NDEBUG
block at the top of the function, and also mentionned by Chuck in his message).
As we just had that in the other PR: What about invalid data - should we check with
COB_D2I() = 0
instead?
We could add that, though the other PR is about moving from an ALPHANUMERIC source, while optimized_move_display_to_edited
only moves from a NUMERIC-DISPLAY source (either a direct one, or a temporary one).
Note: I think there's no use in explicit casting a char to int, is it?
Absolutely, those character literals should already be of type int
anyways.
The field->size is size_t already, so that should be dropped in any case.
Done.
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 an invariant here that
f1
either has no sign or has a trailing separate sign (as checked by the block between#ifndef NDEBUG
block at the top of the function, and also mentioned by Chuck in his message).
Can you expand that to also the leading separate case (should be simple, and we now even have a testcase ready :-) and to the overpunched sign (a bit more complex)?
Of course we can postpone that to later (either both or one of those)...
As we just had that in the other PR: What about invalid data - should we check with
COB_D2I() = 0
instead?We could add that, though the other PR is about moving from an ALPHANUMERIC source, while
optimized_move_display_to_edited
only moves from a NUMERIC-DISPLAY source (either a direct one, or a temporary one).
Just checked with MF: After MOVE SPACES TO L(1:3)
before the W-X move, by default we get the abort for non-numeric data in numeric displays, when I disable that at run-time, then " 00000" is blanked to space and " 1234" results in " 12,34" while an additional MOVE "A" TO L (8:1)
results in
===> 0,01<===
===> 12,31<===
I guess this is the same for GCOS, in this case we may should at this at the end of that test (and use COB_D2I(c) == 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.
Can you expand that to also the leading separate case (should be simple, and we now even have a testcase ready :-) and to the overpunched sign (a bit more complex)? Of course we can postpone that to later (either both or one of those)...
Done for this part.
Just checked with MF: After
MOVE SPACES TO L(1:3)
before the W-X move, by default we get the abort for non-numeric data in numeric displays, when I disable that at run-time, then " 00000" is blanked to space and " 1234" results in " 12,34" while an additionalMOVE "A" TO L (8:1)
results in===> 0,01<=== ===> 12,31<===
Added this to the test case, though the result differs, i.e.:
MOVE 0 TO L.
MOVE SPACES TO L(1:3).
MOVE L TO W-X.
DISPLAY ' ===>' W-X '<==='.
MOVE "A" TO L(8:1).
DISPLAY ' ===>' W-X '<==='.
MOVE 1234 TO L.
MOVE SPACES TO L(1:3).
MOVE L TO W-X.
DISPLAY ' ===>' W-X '<==='.
MOVE "A" TO L(8:1).
DISPLAY ' ===>' W-X '<==='.
Yields:
===> <===
===> <===
===> 012,34<===
===> 012,34<===
Though this is not really related to the "BLANK WHEN ZERO not working anymore" issue.
e3e46f7
to
c2cd5f5
Compare
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.
I do question if GCOS would output 012,34...
please see some notes and add a Changelog (and yes, that part is a separate one from Chucks fixing something else - still fine for a single commit as that fixes two errors in the same function that are verified by a single test.
... it seems reasonable to check the CI generated coverage as well, to ensure that at least all parts of this function that is now fixed is actually tested (or at least: executed).
ef2def5
to
c57141f
Compare
I think I considered all requested changes. |
Sounds I do wait for the next push, right? |
Yes.
|
c57141f
to
e4c78b8
Compare
e4c78b8
to
bca3242
Compare
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.
seems good to me, apart from the Changelog entry we need to fix run_misc.at - the test "Figurative constants to numeric field" (which should get an additional keyword "MOVE") doers not only test what it says, but additional the possible pretty-printing - which it shouldn't.
please change is " NUM9 "."
to is " NUM9 (1:) "."
to fix that test
and yes, we have one additional issue which was seen by this: the pretty-printing of USAGE DISPLAY
is different in at least those compilers:
acu: no pretty-printing on those at all
mf: all signed fields are printed as if they'd have a "SIGN SEPARATE TRAILING"
gc: full pretty-printing (including decimals, normalization, ...)
but that's something to only create a FR on "provide different pretty-display for USAGE DISPLAY" (and I don't consider that a high priority)
bca3242
to
6d3e4fb
Compare
Here we go. I also sneaked into this the small testsuite adjustment mentionned in your last comment in #203. |
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.
Good as-is.
Merged in SVN @ 5403. |
Happens since this commit - so far only in NC105A
|
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.
haven't checked if the error was triggered by that test case (I'd assume so) - but as the test is already run, please add a check for the expected value in Y (`if Y(1:) NOT = ") as well, then commit.
I'd say it is a follow-up of a previous recent change, so no need for a Changelog entry - but please reference it as "follow-up commit to r...." to point to the other one and give a minimal change note in the svn log.
2cffeca
to
8d6312b
Compare
At least it was, locally on my machine - and was fixed with the patch. So, let's be confident ;)
Added.
Alright. |
Merged in SVN @ 5407. |
On behalf of Chuck.