-
Notifications
You must be signed in to change notification settings - Fork 42
NATIONAL + UTF8 tests, ref-mod: fix byte offset/size with poor man's display conversion #280
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
base: gitside-gnucobol-3.x
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1260,6 +1260,9 @@ output_data (cb_tree x) | |
| /* Offset */ | ||
| if (r->offset) { | ||
| output (" + "); | ||
| if (CB_TREE_CLASS (x) == CB_CLASS_NATIONAL) { | ||
| output ("%d * ", COB_NATIONAL_SIZE); | ||
| } | ||
| output_index (r->offset); | ||
| } | ||
|
|
||
|
|
@@ -1317,6 +1320,9 @@ output_size (const cb_tree x) | |
| break; | ||
| } | ||
| if (r->length) { | ||
| if (CB_TREE_CLASS (x) == CB_CLASS_NATIONAL) { | ||
| output ("%d * ", COB_NATIONAL_SIZE); | ||
| } | ||
| output_integer (r->length); | ||
| } else if (r->offset && f->flag_any_length) { | ||
| output ("%s%d.size - ", CB_PREFIX_FIELD, f->id); | ||
|
|
@@ -1358,6 +1364,9 @@ output_size (const cb_tree x) | |
| } | ||
| if (r->offset) { | ||
| output (" - "); | ||
| if (CB_TREE_CLASS (x) == CB_CLASS_NATIONAL) { | ||
| output ("%d * ", COB_NATIONAL_SIZE); | ||
| } | ||
| output_index (r->offset); | ||
| } | ||
| } | ||
|
|
@@ -1600,7 +1609,11 @@ output_attr (const cb_tree x) | |
| struct cb_field *f = CB_FIELD (r->value); | ||
| flags = 0; | ||
| if (r->offset) { | ||
| id = lookup_attr (COB_TYPE_ALPHANUMERIC, 0, 0, 0, NULL, 0); | ||
| 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); | ||
| } | ||
|
Comment on lines
+1612
to
+1616
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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). |
||
| } else { | ||
| int type = cb_tree_type (x, f); | ||
| switch (type) { | ||
|
|
||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as this file had no 2025 changes and yours are the first in 2026: please add
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same for data_display.at |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -323,6 +323,16 @@ cob_display_common (const cob_field *f, FILE *fp) | |
| display_numeric ((cob_field *)f, fp); | ||
|
Comment on lines
330
to
334
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you also can have national numeric data:
Therefore those two functions will possibly need handling of the national attribute as well (all data would be expected to be 0x00 = ISO8859-1 in the first byte ... but in this case it would be best to do a conversion to an internal alphanumeric field by skipping the low-value in the lower nibble and display it afterwards [for numerics that's fine as we can use a small fixed buffer - in case of national "text" we may get 2 GB fields so definitely don't want to do a conversion with a temporary field on that), Can you please add a test of
(either fix the failing result with the approach above or mark it as expected fail) |
||
| return; | ||
| } | ||
| /* 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); | ||
|
||
| } | ||
|
|
||
|
|
||
GitMensch marked this conversation as resolved.
Show resolved
Hide resolved
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -54,6 +54,110 @@ d:d | |
| AT_CLEANUP | ||
|
|
||
|
|
||
| AT_SETUP([Static reference-modification national]) | ||
GitMensch marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| AT_KEYWORDS([refmod]) | ||
|
|
||
| AT_DATA([prog.cob], [ | ||
| IDENTIFICATION DIVISION. | ||
| PROGRAM-ID. prog. | ||
| DATA DIVISION. | ||
| WORKING-STORAGE SECTION. | ||
| 01 X PIC N(4) VALUE N"abcd". | ||
| PROCEDURE DIVISION. | ||
| DISPLAY X(1:1) ":" X(1:2) ":" X(1:3) ":" X(1:4) ":" X(1:) | ||
| END-DISPLAY. | ||
| DISPLAY X(2:1) ":" X(2:2) ":" X(2:3) ":" X(2:) | ||
| END-DISPLAY. | ||
| DISPLAY X(3:1) ":" X(3:2) ":" X(3:) | ||
| END-DISPLAY. | ||
| DISPLAY X(4:1) ":" X(4:) | ||
| END-DISPLAY. | ||
| STOP RUN. | ||
| ]) | ||
|
|
||
| AT_CHECK([$COMPILE -Wno-unfinished prog.cob], [0], [], []) | ||
| AT_CHECK([$COBCRUN_DIRECT ./prog], [0], | ||
| [a:ab:abc:abcd:abcd | ||
| b:bc:bcd:bcd | ||
| c:cd:cd | ||
| d:d | ||
| ]) | ||
|
|
||
| AT_CLEANUP | ||
|
|
||
|
|
||
| AT_SETUP([Static reference-modification UTF-8]) | ||
| AT_KEYWORDS([refmod]) | ||
|
|
||
| AT_DATA([prog.cob], [ | ||
| IDENTIFICATION DIVISION. | ||
| PROGRAM-ID. prog. | ||
| DATA DIVISION. | ||
| WORKING-STORAGE SECTION. | ||
| 01 X PIC U(4) VALUE U"aǭcde". | ||
|
||
| PROCEDURE DIVISION. | ||
| DISPLAY X(1:1) ":" X(1:2) ":" X(1:3) ":" X(1:4) ":" X(1:) | ||
| END-DISPLAY. | ||
| DISPLAY X(2:1) ":" X(2:2) ":" X(2:3) ":" X(2:) | ||
| END-DISPLAY. | ||
| DISPLAY X(3:1) ":" X(3:2) ":" X(3:) | ||
| END-DISPLAY. | ||
| DISPLAY X(4:1) ":" X(4:) | ||
| END-DISPLAY. | ||
| STOP RUN. | ||
| ]) | ||
|
|
||
| # FIXME: currently single byte instead of single character | ||
|
|
||
| AT_XFAIL_IF([true]) | ||
|
|
||
| AT_CHECK([$COMPILE -Wno-unfinished prog.cob], [0], [], []) | ||
| AT_CHECK([$COBCRUN_DIRECT ./prog], [0], | ||
| [a:aǭ:aǭc:aǭcd:aǭcd | ||
| ǭ:ǭc:ǭcd:ǭcd | ||
| c:cd:cd | ||
| d:d | ||
| ]) | ||
|
|
||
| AT_CLEANUP | ||
|
|
||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please use two empty lines before a new test |
||
|
|
||
| AT_SETUP([Static reference-modification UTF-8 mixed byte-widths]) | ||
| AT_KEYWORDS([refmod]) | ||
|
|
||
| AT_DATA([prog.cob], [ | ||
| IDENTIFICATION DIVISION. | ||
| PROGRAM-ID. prog. | ||
| DATA DIVISION. | ||
| WORKING-STORAGE SECTION. | ||
| 01 X PIC U(4) VALUE U"aé日𝄞". | ||
| PROCEDURE DIVISION. | ||
| DISPLAY X(1:1) ":" X(1:2) ":" X(1:3) ":" X(1:4) ":" X(1:) | ||
| END-DISPLAY. | ||
| DISPLAY X(2:1) ":" X(2:2) ":" X(2:3) ":" X(2:) | ||
| END-DISPLAY. | ||
| DISPLAY X(3:1) ":" X(3:2) ":" X(3:) | ||
| END-DISPLAY. | ||
| DISPLAY X(4:1) ":" X(4:) | ||
| END-DISPLAY. | ||
| STOP RUN. | ||
| ]) | ||
|
|
||
| # FIXME: currently uses byte offset/length instead of character offset/length | ||
|
|
||
| AT_XFAIL_IF([true]) | ||
|
|
||
| AT_CHECK([$COMPILE -Wno-unfinished prog.cob], [0], [], []) | ||
| AT_CHECK([$COBCRUN_DIRECT ./prog], [0], | ||
| [a:aé:aé日:aé日𝄞:aé日𝄞 | ||
| é:é日:é日𝄞:é日𝄞 | ||
| 日:日𝄞:日𝄞 | ||
| 𝄞:𝄞 | ||
| ]) | ||
|
|
||
| AT_CLEANUP | ||
|
|
||
|
|
||
| AT_SETUP([Dynamic reference-modification]) | ||
| AT_KEYWORDS([refmod]) | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.