Skip to content
Open
2 changes: 1 addition & 1 deletion DEPENDENCIES
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ The following libraries ARE required WHEN :

BOTH runtime AND development components required.

libxml2 >= 2.5.10 - https://gitlab.gnome.org/GNOME/libxml2/-/wikis/home
libxml2 >= 2.6.1 - https://gitlab.gnome.org/GNOME/libxml2/-/wikis/home

libxml2 is distributed under MIT License (Expat variant).

Expand Down
9 changes: 9 additions & 0 deletions cobc/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@

2026-04-14 Guillaume Bertholon <guillaume.bertholon@ocamlpro.com>
Comment thread
GBertholon marked this conversation as resolved.

* parser.y: remove the CB_PENDING warning on XML PARSE but still warn for
untested XML PARSE RETURNING NATIONAL and XML PARSE VALIDATING.
* typeck.c: remove invalid call to cob_check_based for XML-* builtin variable
length registers (like XML-TEXT)
* codegen.c: remove the uninitialized and unused b_* field for XML-* builtin
variable length registers

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

* tree.c (finalize_file): if file is EXTFH enabled then don't warn for
Expand Down
8 changes: 6 additions & 2 deletions cobc/codegen.c
Original file line number Diff line number Diff line change
Expand Up @@ -1091,6 +1091,8 @@ output_base (struct cb_field *f, const cob_u32_t no_output)
} else {
output ("cob_local_ptr");
}
} else if (f01->storage == CB_STORAGE_LINKAGE && f01->flag_internal_register) {
output ("%s%d.data", CB_PREFIX_FIELD, f01->id);
} else {
output ("%s%d", CB_PREFIX_BASE, f01->id);
}
Expand Down Expand Up @@ -7274,7 +7276,7 @@ output_xml_parse (struct cb_xml_parse *p)
{
int flags = 0;
if (cb_xml_parse_xmlss) {
flags |= COB_XML_PARSE_XMLNSS;
flags |= COB_XML_PARSE_XMLSS;
}
if (p->returning_national && current_prog->xml_ntext) {
flags |= COB_XML_PARSE_NATIONAL;
Expand Down Expand Up @@ -11905,7 +11907,9 @@ output_internal_function (struct cb_program *prog, cb_tree parameter_list)
/* Dangling linkage section items */
seen = 0;
for (f = prog->linkage_storage; f; f = f->sister) {
if (f->redefines) {
if (f->redefines || f->flag_internal_register) {
/* XML-TEXT and other XML-* registers are in linkage_storage but do not use the
corresponding b_* field. */
continue;
}
for (l = parameter_list; l; l = CB_CHAIN (l)) {
Expand Down
25 changes: 18 additions & 7 deletions cobc/parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -17935,7 +17935,6 @@ xml_parse_statement:
xml PARSE
{
begin_statement (STMT_XML_PARSE, TERM_XML);
CB_PENDING ("XML PARSE");
cobc_cs_check = CB_CS_XML_PARSE;
cb_set_register_receiving (current_program->xml_code, 1);
cb_set_register_receiving (current_program->xml_event, 1);
Expand All @@ -17946,8 +17945,6 @@ xml_parse_statement:
cb_set_register_receiving (current_program->xml_namespace_prefix, 1);
cb_set_register_receiving (current_program->xml_nnamespace, 1);
cb_set_register_receiving (current_program->xml_nnamespace_prefix, 1);
}
if (cb_xml_parse_xmlss) {
cb_set_register_receiving (current_program->xml_information, 0);
}
}
Expand Down Expand Up @@ -17987,14 +17984,28 @@ _with_encoding:
;

_returning_national:
/* empty */ { $$ = NULL; }
| RETURNING NATIONAL { $$ = cb_true; }
/* empty */
{
$$ = NULL;
}
| RETURNING NATIONAL
{
CB_PENDING ("XML PARSE RETURNING NATIONAL");
$$ = cb_true;
}
;

_validating_with:
/* empty */ { $$ = NULL; }
/* empty */
{
$$ = NULL;
}
| VALIDATING _with
schema_file_or_record_name { $$ = $3; }
schema_file_or_record_name
{
CB_PENDING ("XML PARSE VALIDATING");
$$ = $3;
}
;

schema_file_or_record_name:
Expand Down
2 changes: 1 addition & 1 deletion cobc/typeck.c
Original file line number Diff line number Diff line change
Expand Up @@ -2544,7 +2544,7 @@ cb_build_identifier (cb_tree x, const int subchk)
&& !current_statement->flag_no_based) {
if (p->flag_item_based
|| (p->storage == CB_STORAGE_LINKAGE &&
!(p->flag_is_pdiv_parm || p->flag_is_returning))) {
!(p->flag_is_pdiv_parm || p->flag_is_returning || p->flag_internal_register))) {
current_statement->null_check = CB_BUILD_FUNCALL_2 (
"cob_check_based",
cb_build_address (cb_build_field_reference (p, NULL)),
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1132,7 +1132,7 @@ AS_IF([test "$with_xml2" = yes -o "$with_xml2" = check], [
LIBS="$LIBS $LIBCOB_LIBS_extern $XML2_LIBS"
# note: PKG_CONFIG and xml2-config set -I/path/to/libxml2 which contains a "libxml" folder where
# all the files we look for are included
for header in xmlwriter xmlversion uri parser tree; do
for header in xmlwriter xmlversion uri parser tree SAX2; do
AC_CHECK_HEADER([libxml/$header.h], [],
[if test "$with_xml2" = yes; then
AC_MSG_ERROR([headers for libxml2 are required for --with-xml2, you may adjust XML2_CFLAGS])
Expand Down
42 changes: 42 additions & 0 deletions libcob/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,4 +1,25 @@

2026-04-14 Guillaume Bertholon <guillaume.bertholon@ocamlpro.com>

* common.h: rename COB_XML_PARSE_XMLNSS into COB_XML_PARSE_XMLSS to match
the IBM option name
* mlio.c: Fix issues in XML PARSE handling most notably a use
after free error if the internal buffer needs to grow during the parsing.
This fix changes the definition of xml_event to store offsets in the
buffer instead of pointers
* mlio.c: Respect the high order half-word for exception XML-CODE,
but do not expose internal libxml2 error codes
* mlio.c: Reduce the number of parsing states by removing useless ones,
and encode eof in these states
* mlio.c: Handle XML chunks with more than one recoverable error
* mlio.c: Trigger ON EXCEPTION code after EXCEPTION XML events
* mlio.c: Remove spurious events when there is no <?xml?> declaration in the file
* mlio.c: Handle incomplete CONTENT-CHARACTERS events (with XML-INFORMATION = 2).
Note that, compared to IBM, we may merge short contiguous CONTENT-CHARACTERS
events across END-OF-INPUT boundaries.
This is due to libxml2 internal details.


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

* fileio.c (indexed_open) [WITH_DB]: if open was successful but checking
Expand All @@ -8,6 +29,11 @@
* fileio.c (cob_file_close): close file depending on internal state, not
depending on file organization

2025-11-19 Chuck Haatvedt <chuck.haatvedt+cobol@gmail.com>

* mlio.c (xml_startDocument, myStructuredErrorHandler, xml_parse):
compat for LIBXML_VERSION < 21400

2025-11-19 Oğuzcan Kırmemiş <oguzcan.kirmemis@gmail.com>

* common.c (cob_set_signal): add the enum COB_SIGNAL_REGIME to toggle
Expand Down Expand Up @@ -82,6 +108,22 @@
* intrinsic.c (cob_intr_char): raise COB_EC_ARGUMENT_FUNCTION
when calling CHAR with an argument outside the collation range

2025-08-15 Chuck Haatvedt <chuck.haatvedt+cobol@gmail.com>

* mlio.c: modified to support xml parse with xmlss.
eliminated the xml_event_data structure and moved that data
into the xml_event structure. Created a new enum cob_xml_registers
and added it to the add_xml_event_data function. This function was
modified to update the xml_event structure. All of the context parser
callback functions were modified to use the add_xml_event_data function.
the cob_xml_parse and xml_parse functions were modified to support
the new end_of_input event required by xmlss. a new eof variable
was added to the xml_state structure so that the endDocument callback
function could be triggered by the parser in the xml_parse funtction.

TODO ==> logic needs to be added to support returning NATIONAL data
this needs to support the RETURNING NATIONAL phrase.

2025-07-28 Simon Sobisch <simonsobisch@gnu.org>

* common.h, fileio.c: new externalized typedef EXTFH_FUNC used in
Expand Down
6 changes: 3 additions & 3 deletions libcob/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -1116,7 +1116,7 @@ enum cob_statement {
#define COB_JSON_CJSON 1
#define COB_JSON_JSON_C 2

#define COB_XML_PARSE_XMLNSS (1U << 0)
#define COB_XML_PARSE_XMLSS (1U << 0)
#define COB_XML_PARSE_NATIONAL (1U << 1)
#define COB_XML_PARSE_VALIDATE_FILE (1U << 2)

Expand Down Expand Up @@ -1327,11 +1327,11 @@ typedef struct __cob_module {
const char *gc_version; /* module version, until 3.1.2: set by cob_check_version */

unsigned char xml_mode; /* Mode to handle XML PARSE (may be extended) */
/* similar to XMLPARSE(XMLNSS) Micro Focus,
/* similar to XMLPARSE(XMLSS) Micro Focus,
IBM may be different (_very_ likely for error codes);
but the main difference is to "COMPAT" */
#define COB_XML_COMPAT 0
#define COB_XML_XMLNSS 1
#define COB_XML_XMLSS 1
struct cob_frame_ext *frame_ptr; /* current frame ptr, note: if set then cob_frame in this
module is of type "struct cob_frame_ext",
otherwise "struct cob_frame" */
Expand Down
Loading
Loading