Skip to content

Conversation

@ddeclerck
Copy link
Collaborator

Note: initial commit from Chuck, fixes to come

Copy link
Collaborator

@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.

just a quick note for the first iteration; note that Chucks changes are based on mlio from August 2025, so the "real" version may be easier to get by checking out a previous commit, then replace the file and commit locally, then fetch the newer commit with rebase-merging

])

AT_CHECK([$COMPILE -w prog.cob], [0], [], [])
AT_CHECK([$COMPILE -Wno-pending prog.cob], [0], [], [])
Copy link
Collaborator

Choose a reason for hiding this comment

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

the follow-up commit will drop the pending from cobc, of course, and therefore should drop the -Wno-pending for the XML code cases


#include <json-c/linkhash.h>
#include <json-c/json.h>
#elif defined (HAVE_JSON_H)
Copy link
Collaborator

Choose a reason for hiding this comment

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

you want to keep all that above (merge gone bad here), which will possibly solve the compile error as well

Chuck's new code may need some more headers but we want to go with the specific ones needed

@GitMensch
Copy link
Collaborator

GitMensch commented Dec 5, 2025

@chuck-haatvedt passed me the newest file (you may do a diff to add a changelog entry) which looks much better concerning libxml version compat. It is from November 14th: mlio.c with a note

that file was built / tested on
libcob (branches/gnucobol-3.x r5603M) 3.3-dev.5603

Copy link
Collaborator

@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.

Thanks for inspecting / working on necessary changes.
I think we can have those in at least a second commit :-)

Comment on lines 291 to 299
xml_event_initialized (struct xml_event *event) {
struct xml_event_data *data;
for (data = event->first; data; data = data->next) {
data->data_ptr = NULL;
}
event->last = event->first;
event->text_ptr = NULL;
event->text_len = 0;
event->namespace_ptr = NULL;
event->namespace_len = 0;
event->prefix_ptr = NULL;
event->prefix_len = 0;
return event;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

the old code did something useful, if we go with that then the structure should likely be memset(0) instead (and have the event assigned then); if we still want this function then its doc has to be adjusted

event = event->next;
}
switch (sreg) {
case SREG_XML_TEXT :
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does that mean that each event type has only one of the given buffers?
If this is the case then we should simplify it more and don't have three couples where only one is set.

if (state->eof == 0) {
state->eof = 1;
} else {
// xml_code = 1;
Copy link
Collaborator

Choose a reason for hiding this comment

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

drop of switch to #ifdef 0

SREG_XML_TEXT,
localname,
xmlStrlen (localname));
/* TODO: cleanup and code namespace stuff and check what to do on endElement */
Copy link
Collaborator

Choose a reason for hiding this comment

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

done?

Comment on lines +1783 to +1784
switch (ctxt->standalone) {
case 1 :
Copy link
Collaborator

Choose a reason for hiding this comment

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

Change to simple condition?

Comment on lines +1885 to +1893
const xmlChar *attr_name = attributes[cntr]; // ATTRIBUTE-NAME
const xmlChar *attr_prefix = attributes[cntr + 1]; // ATTRIBUTE-NAMESPACE
const xmlChar *attr_value_start = attributes[cntr + 3]; // ATTRIBUTE-CHARACTERS start
const xmlChar *attr_value_end = attributes[cntr + 4]; // ATTRIBUTE-CHARACTERS end

// Calculate attribute value length
attr_value_len = attr_value_end - attr_value_start;

// Use the extracted information
Copy link
Collaborator

Choose a reason for hiding this comment

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

// to /* */

Comment on lines +1976 to +1982
fprintf(stderr, "WARNING: Encoding mismatch detected!\n");
fprintf(stderr, "Message: %s\n", error->message);
if (error->str1) {
fprintf(stderr, "Declared encoding: %s\n", error->str1);
}
if (error->str2) {
fprintf(stderr, "Auto-detected encoding: %s\n", error->str2);
Copy link
Collaborator

Choose a reason for hiding this comment

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

these should be done with cob_runtime_warning and possilby (partially) into #ifdef DEBUG.

"Encoding declaration '%s' appears incompatible with input data\n"
"The current runtime character encoding is %s \n"
"This caused XML declaration parsing to fail with: %s",
state->ctx->encoding, locale_charset(), error->message);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't this be acquired by locale (in common.c)? If this is the single place then the function call + header as well as conditional compilation may go away as well.

"This caused XML declaration parsing to fail with: %s",
state->ctx->encoding, error->message);
#endif
fprintf(stderr,
Copy link
Collaborator

Choose a reason for hiding this comment

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

all of those with cob_runtime_warning and possibly in a debug conditional

Comment on lines +2147 to +2151
#if LIBXML_VERSION >= 21200
int options = xmlCtxtGetOptions(state->ctx);
#else
int options = state->ctx->options;
#endif
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe go with the approach of fileio and define a macro for get/set at the start, then just using them here?

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