NATIONAL + UTF8 tests, ref-mod: fix byte offset/size with poor man's display conversion#280
NATIONAL + UTF8 tests, ref-mod: fix byte offset/size with poor man's display conversion#280GitMensch wants to merge 2 commits intoOCamlPro:gitside-gnucobol-3.xfrom
Conversation
GitMensch
left a comment
There was a problem hiding this comment.
Thank you for this first iteration - looks good!
We definitely need a Changelog entry in cobc and libcob, so please add those in your next commit.
| if (CB_TREE_CLASS (x) == CB_CLASS_NATIONAL) { | ||
| id = lookup_attr (COB_TYPE_NATIONAL, 0, 0, 0, NULL, 0); | ||
| } else { | ||
| id = lookup_attr (COB_TYPE_ALPHANUMERIC, 0, 0, 0, NULL, 0); | ||
| } |
There was a problem hiding this comment.
That's correct. Something similar may be needed for the national literals (then to be added directly above).
libcob/termio.c
Outdated
| /* poor man's conversion */ | ||
| if (COB_FIELD_IS_NATIONAL (f)) { | ||
| size_t i; | ||
| for (i = 0; i < f->size; i += 2) { | ||
| if (f->data[i] == 0x00) { | ||
| putc (f->data[i + 1], fp); | ||
| } | ||
| } | ||
| return; | ||
| } | ||
| display_alnum (f, fp); |
There was a problem hiding this comment.
add a new display_national function and use an if/else to get the right one
| if (COB_MODULE_PTR->flag_pretty_display) { | ||
| pretty_display_numeric ((cob_field *)f, fp); | ||
| return; | ||
| } | ||
| display_numeric ((cob_field *)f, fp); |
There was a problem hiding this comment.
you also can have national numeric data:
01 SOME-NUM-NAT PIC 9(6)v99 USAGE NATIONAL VALUE 12.34.
Therefore those two functions will possibly need handling of the national attribute as well (all data would be expected to be 0x00 in the first byte)
DISPLAY SOME-NUM-NAT. (compiled with -fpretty-display/-fno-pretty-display)
| AT_CLEANUP | ||
|
|
||
|
|
||
| AT_SETUP([Static reference-modification national]) |
There was a problem hiding this comment.
I suggest to add a test up front "DISPLAY NATIONAL fields/literals" where you just display N"1234"``, SOME-NUM-NATand the fullXwithout ref-mod, along with the result ofFUNCTION HEX-OF (x)` for each of those.
tests/testsuite.src/run_refmod.at
Outdated
| PROGRAM-ID. prog. | ||
| DATA DIVISION. | ||
| WORKING-STORAGE SECTION. | ||
| 01 X PIC U(4) VALUE U"aǭcde". |
There was a problem hiding this comment.
use a single-byte here - that should pass (we have the mixed-width test below)
There was a problem hiding this comment.
Please duplicate all of these tests with a dynamic ref-mod - e.g. using a PIC 9 field with ADD between to ensure that the compiler may not optimize the variable out into a constant; some may pass (or do so with minor changes) while others may fail.
PR to review and discuss @hornepm's changes which serves also as a way to get a better picture what the GSoC proposal need to cover / the project will look like