Skip to content

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

Draft
GitMensch wants to merge 4 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 4 commits intoOCamlPro:gitside-gnucobol-3.xfrom
hornepm:gitside-gnucobol-3.x

Conversation

@GitMensch
Copy link
Copy Markdown
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
Copy Markdown
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 thread cobc/codegen.c
Comment thread cobc/codegen.c
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
Copy Markdown
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).

Comment thread 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
Copy Markdown
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 thread libcob/termio.c
Comment thread tests/testsuite.src/run_refmod.at
Comment thread tests/testsuite.src/run_refmod.at Outdated
PROGRAM-ID. prog.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 X PIC U(4) VALUE U"aǭcde".
Copy link
Copy Markdown
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)

Comment thread tests/testsuite.src/run_refmod.at
Copy link
Copy Markdown
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.

This is nearly ready for commit (with expected failures); do you want to go on with this PR handling (part of) the NATIONAL failures or should we upstream it before?

Comment thread libcob/termio.c
Comment thread libcob/termio.c Outdated
Comment thread libcob/termio.c Outdated
Comment thread tests/testsuite.src/run_refmod.at Outdated
Comment thread tests/testsuite.src/run_refmod.at
Comment thread tests/ChangeLog
Comment on lines +2 to +8
2026-03-23 Preston Horne <preston.m.horne@vanderbilt.edu>

* testsuite.src/run_refmod.at: add static and dynamic
reference-modification tests for NATIONAL and UTF-8 fields
* testsuite.src/data_display.at: add DISPLAY test for NATIONAL
fields and literals with HEX-OF

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

not obvious:
this file is actually only adjusted for testcases if we heavily refactor them, otherwise this is left to "infrastucture" changes

--> nice (but not enforeced) to be part of the log message

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Ok I will keep this and know this for next time

Comment thread tests/testsuite.src/data_display.at Outdated
Comment on lines +159 to +167
AT_CHECK([$COMPILE -Wno-unfinished prog.cob], [0], [], [])
AT_CHECK([$COBCRUN_DIRECT ./prog], [0],
[1234
0031003200330034
00001234
00300030003000300031003200330034
abcd
0061006200630064
])
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

that's well, as this is displaying numerics, you may compile and run it twice: (with -fpretty-display/-fno-pretty-display) as this will go into different functions

(either fix the failing result with the approach mentioned in termio.c or keep it marked as expected fail)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

You've added -fpretty-display - so a second couple of compile + run with -fno-pretty-display (and different expectation - see plain PIC 9 to get the different expected results) is missing.

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