Skip to content
Open
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
2 changes: 1 addition & 1 deletion DEPENDENCIES
Comment thread
GBertholon marked this conversation as resolved.
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
2 changes: 1 addition & 1 deletion DEPENDENCIES.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ XML Support

Support for GENERATE XML is provided by:

* [libxml2](https://gitlab.gnome.org/GNOME/libxml2/-/wikis/home) 2.5.10 or later
* [libxml2](https://gitlab.gnome.org/GNOME/libxml2/-/wikis/home) 2.6.1 or later

libxml2 is distributed under MIT License (Expat variant).

Expand Down
28 changes: 23 additions & 5 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,29 @@ NEWS - user visible changes -*- outline -*-
customization can be done using COB_PROF_FILE, COB_PROF_MAX_DEPTH and
COB_PROF_FORMAT

** initial support for XML PARSE
while this feature is not implemented fully and some events are not
implemented yet, we'd like you to test this feature already;
note that for the XML-EVENT EXCEPTION, the stored exception-values in
XML-CODE and XML-TEXT registers differ from other implementations
** support for XML PARSE
Events sent to COBOL code try to follow as closely as possible what IBM
does with a few differences linked to internal XML engine differences:
- we cannot guarantee that incomplete CONTENT-CHARACTERS and
ATTRIBUTE-CHARACTERS XML-EVENTS will be sent at the same time,
and cut in the same place as with IBM's parser.
GnuCOBOL can merge short CONTENT-CHARACTERS events together across
END-OF-INPUT chunks boundary.
- For the EXCEPTION XML-EVENT, the reported XML-CODE will often only
correspond to generic error or warning instead of the full error code.
In COMPAT mode, generic warnings use code 99 and generic errors use 201.
In XMLNSS mode, the low order bits for generic errors and warnings are
set to zero.
Moreover, for those generic exceptions, XML-TEXT will contain the error
text as reported by libxml2.
We may map more of libxml2's errors on IBM's error codes in the future.
- The order between EXCEPTION events and other events is not guaranteed
to be the same as with an IBM parser.
For most codebases, we do not expect those differences to break existing
COBOL code.
Support for XML PARSE RETURNING NATIONAL and XML PARSE VALIDATING
is experimental, remain untested and will show a warning at compile time
when used.

** new runtime configuration COB_HIDE_CURSOR, allows to hide the cursor during
extended ScreenIO operations
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

2026-06-08 Nicolas Berthier <nicolas.berthier@ocamlpro.com>

* tree.h, parser.y: change type of cobc_cs_check flags to permit
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 @@ -18130,7 +18130,6 @@ xml_parse_statement:
xml PARSE
{
begin_statement (STMT_XML_PARSE, TERM_XML);
CB_PENDING ("XML PARSE");
__CS_ENTER (CB_CS_XML_PARSE);
cb_set_register_receiving (current_program->xml_code, 1);
cb_set_register_receiving (current_program->xml_event, 1);
Expand All @@ -18141,8 +18140,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 @@ -18182,14 +18179,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
14 changes: 3 additions & 11 deletions config/mf.words

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

the commit of this file is mostly wrong and need an undo: https://docs.rocketsoftware.com/bundle/visualcoboldevhub_ug_100/page/iug1743377692759.html - the move of those parts from "reserved" to "register" is definitely correct - and may need to be done for other .words files as well

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I don't understand what you want here...
Given the Rocket Software link, it seems like I should not only keep my changes but also uncomment XML-INFORMATION, XML-(N)NAMESPACE and XML-(N)NAMESPACE-PREFIX, no ?

Original file line number Diff line number Diff line change
Expand Up @@ -678,15 +678,7 @@ reserved: WRITE
reserved: WRITING
reserved: XML
reserved: XML-DECLARATION*
reserved: XML-EVENT # note: this is a register, move as soon as supported
#reserved: XML-INFORMATION # note: this is a register, move as soon as supported
#reserved: XML-NAMESPACE # note: this is a register, move as soon as supported
#reserved: XML-NAMESPACE-PREFIX # note: this is a register, move as soon as supported
#reserved: XML-NNAMESPACE # note: this is a register, move as soon as supported
#reserved: XML-NNAMESPACE-PREFIX # note: this is a register, move as soon as supported
reserved: XML-NTEXT # note: this is a register, move as soon as supported
reserved: XML-SCHEMA
reserved: XML-TEXT # note: this is a register, move as soon as supported
reserved: YYYYDDD*
reserved: YYYYMMDD*
reserved: ZERO
Expand Down Expand Up @@ -721,14 +713,14 @@ register: SORT-RETURN
# register: TIME-OF-DAY # only available in OS/VS mode
# register: WHEN-COMPILED # only available in OS/VS or VSC2 modes (note the format of the date differs with the mode!)
register: XML-CODE
# register: XML-EVENT
register: XML-EVENT
# register: XML-INFORMATION
# register: XML-NAMESPACE
# register: XML-NAMESPACE-PREFIX
# register: XML-NNAMESPACE
# register: XML-NNAMESPACE-PREFIX
# register: XML-NTEXT
# register: XML-TEXT
register: XML-NTEXT
register: XML-TEXT

# disable all functions
not-intrinsic-function: DIALECT-ALL
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
41 changes: 41 additions & 0 deletions libcob/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,4 +1,24 @@

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.

2026-03-02 Fabrice Le Fessant <fabrice.le_fessant@ocamlpro.com>

* coblocal.h, common.c, profiling.c: rename is_test to cob_is_test
Expand All @@ -13,6 +33,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 @@ -87,6 +112,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