Skip to content

NATIONAL + UTF8 tests, ref-mod: fix byte offset/size with poor man's display conversion#280

Draft
GitMensch wants to merge 2 commits intoOCamlPro:gitside-gnucobol-3.xfrom
hornepm:gitside-gnucobol-3.x
Draft

NATIONAL + UTF8 tests, ref-mod: fix byte offset/size with poor man's display conversion#280
GitMensch wants to merge 2 commits intoOCamlPro:gitside-gnucobol-3.xfrom
hornepm:gitside-gnucobol-3.x

Conversation

@GitMensch
Copy link
Collaborator

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

Copy link
Collaborator Author

@GitMensch GitMensch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +1612 to +1616
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);
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's correct. Something similar may be needed for the national literals (then to be added directly above).

libcob/termio.c Outdated
Comment on lines 326 to 336
/* 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);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a new display_national function and use an if/else to get the right one

Comment on lines 319 to 323
if (COB_MODULE_PTR->flag_pretty_display) {
pretty_display_numeric ((cob_field *)f, fp);
return;
}
display_numeric ((cob_field *)f, fp);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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])
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

PROGRAM-ID. prog.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 X PIC U(4) VALUE U"aǭcde".
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use a single-byte here - that should pass (we have the mixed-width test below)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants