Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions cobc/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@

2026-03-23 Preston Horne <preston.m.horne@vanderbilt.edu>

* codegen.c (output_data): offset calc for NATIONAL ref-mod
* codegen.c (output_size): size calc for NATIONAL ref-mod

2025-12-29 Roger Bowler <rbowler@snipix.net>

* tree.c (finalize_file): if file is EXTFH enabled then don't warn for
Expand Down
15 changes: 14 additions & 1 deletion cobc/codegen.c
Original file line number Diff line number Diff line change
Expand Up @@ -1260,6 +1260,9 @@ output_data (cb_tree x)
/* Offset */
if (r->offset) {
output (" + ");
if (CB_TREE_CLASS (x) == CB_CLASS_NATIONAL) {
output (CB_STRINGIFY (COB_NATIONAL_SIZE) " * ");
}
Comment thread
GitMensch marked this conversation as resolved.
output_index (r->offset);
}

Expand Down Expand Up @@ -1317,6 +1320,9 @@ output_size (const cb_tree x)
break;
}
if (r->length) {
if (CB_TREE_CLASS (x) == CB_CLASS_NATIONAL) {
output (CB_STRINGIFY (COB_NATIONAL_SIZE) " * ");
}
output_integer (r->length);
} else if (r->offset && f->flag_any_length) {
output ("%s%d.size - ", CB_PREFIX_FIELD, f->id);
Expand Down Expand Up @@ -1358,6 +1364,9 @@ output_size (const cb_tree x)
}
if (r->offset) {
output (" - ");
if (CB_TREE_CLASS (x) == CB_CLASS_NATIONAL) {
output (CB_STRINGIFY (COB_NATIONAL_SIZE) " * ");
}
output_index (r->offset);
}
}
Expand Down Expand Up @@ -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
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).

} else {
int type = cb_tree_type (x, f);
switch (type) {
Expand Down
7 changes: 7 additions & 0 deletions libcob/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@

2026-03-23 Preston Horne <preston.m.horne@vanderbilt.edu>

* termio.c (display_national): new function for poor man's
national display conversion
* termio.c (cob_display_common): use display_national for
NATIONAL fields

2025-12-04 Simon Sobisch <simonsobisch@gnu.org>

* fileio.c (indexed_open) [WITH_DB]: if open was successful but checking
Expand Down
28 changes: 26 additions & 2 deletions libcob/termio.c
Comment thread
GitMensch marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (C) 2001-2012, 2014-2024 Free Software Foundation, Inc.
Copyright (C) 2001-2012, 2014-2024, 2026 Free Software Foundation, Inc.
Written by Keisuke Nishida, Roger While, Simon Sobisch, Edward Hart

This file is part of GnuCOBOL.
Expand Down Expand Up @@ -215,6 +215,26 @@ display_alnum (const cob_field *f, FILE *fp)
}
}

static void
display_national (const cob_field *f, FILE *fp)
{
/* TODO: currently only display national data that
overlaps ISO8859-1 and will need an iconv approach later on */

const unsigned char *end = f->data + f->size;
unsigned char *p = f->data;

while (p < end) {
if (p[0] == 0x00) {
const int chr = p[1];
if (putc (chr, fp) != chr) {
break;
}
}
p += 2;
}
}

/* Check for alternate styles of Not A Number and convert to just NaN
and removes the leading zero from the Exponent
note: not all environments provide display of negative /quiet NaN,
Expand Down Expand Up @@ -323,7 +343,11 @@ cob_display_common (const cob_field *f, FILE *fp)
display_numeric ((cob_field *)f, fp);
return;
}
display_alnum (f, fp);
if (COB_FIELD_IS_NATIONAL (f)) {
display_national ((cob_field *)f, fp);
} else {
display_alnum (f, fp);
}
}

void
Expand Down
7 changes: 7 additions & 0 deletions tests/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@

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

Comment on lines +2 to +8
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

2025-12-04 Simon Sobisch <simonsobisch@gnu.org>

* atlocal.in: reordered to correctly use perf/valgrind definitions also
Expand Down
56 changes: 55 additions & 1 deletion tests/testsuite.src/data_display.at
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Copyright (C) 2003-2012, 2014-2015, 2023 Free Software Foundation, Inc.
## Copyright (C) 2003-2012, 2014-2015, 2023, 2026 Free Software Foundation, Inc.
## Written by Keisuke Nishida, Roger While, Simon Sobisch, Brian Tiffin,
## Chuck Haatveet
##
Expand Down Expand Up @@ -125,6 +125,60 @@ AT_CHECK([$COBCRUN_DIRECT ./prog], [0], [0123456789pqrstuvwxy])
AT_CLEANUP


AT_SETUP([DISPLAY: national fields/literals])
AT_KEYWORDS([display])

AT_DATA([prog.cob], [
IDENTIFICATION DIVISION.
PROGRAM-ID. prog.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 X PIC N(4) VALUE N"abcd".
01 NUM PIC 9(6)V99 USAGE NATIONAL
VALUE 12.34.
PROCEDURE DIVISION.
DISPLAY N"1234"
END-DISPLAY.
DISPLAY FUNCTION HEX-OF (N"1234")
END-DISPLAY.
DISPLAY NUM
END-DISPLAY.
DISPLAY FUNCTION HEX-OF (NUM)
END-DISPLAY.
DISPLAY X
END-DISPLAY.
DISPLAY FUNCTION HEX-OF (X)
END-DISPLAY.
STOP RUN.
])

# FIXME: DISPLAY of national literals and national numeric fields not yet handled

AT_XFAIL_IF([true])

AT_CHECK([$COMPILE -fpretty-display -Wno-unfinished prog.cob], [0], [], [])
AT_CHECK([$COBCRUN_DIRECT ./prog], [0],
[1234
0031003200330034
000012.34
00300030003000300031003200330034
abcd
0061006200630064
])

AT_CHECK([$COMPILE -fno-pretty-display -Wno-unfinished prog.cob], [0], [], [])
AT_CHECK([$COBCRUN_DIRECT ./prog], [0],
[1234
0031003200330034
00001234
00300030003000300031003200330034
abcd
0061006200630064
])

AT_CLEANUP


AT_SETUP([DISPLAY: Sign EBCDIC])
AT_KEYWORDS([display])

Expand Down
Loading
Loading