-
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
Dialect option: normalize BCD "on-the-fly" when moving from ALPHANUMERIC to NUMERIC #200
base: gcos4gnucobol-3.x
Are you sure you want to change the base?
Conversation
2918afc
to
675824c
Compare
This seems to work. Should probably be improved. MSYS2 CI failure is caused by different output format for floats (eg. where we have '-1.2345679E+9' in most environments, in MSYS2 we have '-1.2345679E+09') - any idea where this could be adjusted ? |
We had a similar issue with COMP-2 printing before, the solution was to never "printf" but instead use snprintf and post-adjust, if necessary. Just FYI: That's the result with MF, after dropping the extension COMP-N (and the invalid index use):
... with explicit dropping the numeric checks: MF VC
MF VC
|
I see. So it seems BCD is also "normalized" in MF and IBM, except that the sign is mostly ignored (except in MF when mving to NUMERIC-EDITED). Also I don't get why the results for binary in MF have exactly the opposite sign compared to GCOS... And then there are also differences in the way the fields are displayed - but I think this is not related to normalization. I'm thinking maybe we should have two options, one to normalize the digits, and one for the sign (but then it would have to be more than a YES/NO flag, to account for MF keeping the sign only when moving to NUMEDIC-EDITED). |
If I don't miss something, the most visible thing is that this is NOT about BCD (COMP-3/COMP-6) normalization, but about normalization of I'll do the "review" after some meeting, to comment on the actual changes. (just FYI - added the ACU results which are different and took too long to get in the first place; I'd ignore that output for now) |
Well, I'd still say it's BCD-related, since we're trying to interpret DISPLAY data as unpacked BCD. BTW, it could be interesting to try with an ASCII sign ("p") instead of the EBCDIC sign ("}") in SRC-ALNUM. |
Note: I've added the ASCII p variant above as well. Concerning the PR: that's effectively a general issue. I've thought that I have broken something there, but this code goes back to at least OC 1.1, my changes only produces the same "intended" result with less instructions.
The question is how to go on. Using COB_D2I does work (is a bit more expensive, of course), so I tend to use it unconditionally in this function. Another approach would be to try following COBOL 202x MOVE statement, general rule 7 d 4, which may (I'm not sure) should only be done if the target is neither numeric-display nor numeric-edited (or its national variants if the source is national):
That possibly yields nearly the same result as this PR (nearly because the data will likely always be handled as unsigned). What do you think? |
Would that imply doing this unconditionally instead of using a flag ?
Would this be configurabled through a dialect flag ? Our customer expects the sign to be preserved, as it is the case on GCOS. |
For both options there would be an option to make this depending on a dialect (or optimization) flag. If you like the first and go down that route I think there's no option necessary, is it? It may be good to have that test include a performance check option, as in gnucobol/tests/testsuite.src/run_misc.at Lines 5609 to 5625 in 675824c
This allows to easily verify both correctness and speed if we change that later on. |
I do not have the same results with MF VC (ASCII):
The two differences I notice are:
Now, I barely know how MF works, so maybe I'm doing something wrong ? Or maybe it's something that behaves differently depending on the version... |
a58b6f1
to
9115c8c
Compare
@ddeclerck Given 44c96d2 - what is the current state of this PR (and is it still high-priority)? If it is high, please rebase after upstreaming #204. |
Also note that this change, together with a minimal test case, should be upstreamed as well, potentially with a comment /* skip leading zeroes + */. |
Well, that commit you mention (from PR #201) was about fixing stuff and adding a bit of normalization on moves to NUMERCI-EDITED. This PR is about normalizing when moving from ALPHANUMERIC to NUMERIC.
It's still kind of important, although not as critical as the other issues reported in the past few days (and a new one that just arrived tonight 😭). |
You'd want this in a separate PR ? |
As you want, either a separate one or directly upstream. |
I went through a PR just to ensure the CI passes on all platforms. |
This PR adds a new dialect option to allow on-the-fly "normalization" of BCD when moving from ALPHANUMERIC to NUMERIC. This is needed to properly mimic the GCOS COBOL behavior, for instance moving an ALPHANUMERIC containing "ABC456789}" to a NUMERIC yields "-1234567890" in this implementation (it tries to interpret the source as a PIC S9). See the new test at the end of
run_misc.at
.