Skip to content
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

dev: handle upcoming libxml2's use of const for xmlError pointers #3014

Closed
wants to merge 1 commit into from
Closed
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 ext/nokogiri/html4_sax_push_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ native_write(VALUE self, VALUE _chunk, VALUE _last_chunk)

if ((status != 0) && !(ctx->options & XML_PARSE_RECOVER)) {
// TODO: there appear to be no tests for this block
xmlErrorPtr e = xmlCtxtGetLastError(ctx);
xmlErrorConstPtr e = xmlCtxtGetLastError(ctx);
Nokogiri_error_raise(NULL, e);
}

Expand Down
9 changes: 6 additions & 3 deletions ext/nokogiri/nokogiri.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ xmlNodePtr xmlLastElementChild(xmlNodePtr parent);
#define XMLNS_PREFIX "xmlns"
#define XMLNS_PREFIX_LEN 6 /* including either colon or \0 */

#ifndef xmlErrorConstPtr
# define xmlErrorConstPtr const xmlError *
#endif

#include <ruby.h>
#include <ruby/st.h>
Expand Down Expand Up @@ -227,9 +230,9 @@ void Nokogiri_structured_error_func_save(libxmlStructuredErrorHandlerState *hand
void Nokogiri_structured_error_func_save_and_set(libxmlStructuredErrorHandlerState *handler_state, void *user_data,
xmlStructuredErrorFunc handler);
void Nokogiri_structured_error_func_restore(libxmlStructuredErrorHandlerState *handler_state);
VALUE Nokogiri_wrap_xml_syntax_error(xmlErrorPtr error);
void Nokogiri_error_array_pusher(void *ctx, xmlErrorPtr error);
NORETURN_DECL void Nokogiri_error_raise(void *ctx, xmlErrorPtr error);
VALUE Nokogiri_wrap_xml_syntax_error(xmlErrorConstPtr error);
void Nokogiri_error_array_pusher(void *ctx, xmlErrorConstPtr error);
NORETURN_DECL void Nokogiri_error_raise(void *ctx, xmlErrorConstPtr error);
void Nokogiri_marshal_xpath_funcall_and_return_values(xmlXPathParserContextPtr ctx, int nargs, VALUE handler,
const char *function_name) ;

Expand Down
2 changes: 1 addition & 1 deletion ext/nokogiri/test_global_handlers.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
static VALUE foreign_error_handler_block = Qnil;

static void
foreign_error_handler(void *user_data, xmlErrorPtr c_error)
foreign_error_handler(void *user_data, xmlErrorConstPtr c_error)
{
rb_funcall(foreign_error_handler_block, rb_intern("call"), 0);
}
Expand Down
6 changes: 3 additions & 3 deletions ext/nokogiri/xml_document.c
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ read_io(VALUE klass,
xmlSetStructuredErrorFunc(NULL, NULL);

if (doc == NULL) {
xmlErrorPtr error;
xmlErrorConstPtr error;

xmlFreeDoc(doc);

Expand Down Expand Up @@ -383,7 +383,7 @@ read_memory(VALUE klass,
xmlSetStructuredErrorFunc(NULL, NULL);

if (doc == NULL) {
xmlErrorPtr error;
xmlErrorConstPtr error;

xmlFreeDoc(doc);

Expand Down Expand Up @@ -537,7 +537,7 @@ create_entity(int argc, VALUE *argv, VALUE self)
);

if (NULL == ptr) {
xmlErrorPtr error = xmlGetLastError();
xmlErrorConstPtr error = xmlGetLastError();
if (error) {
rb_exc_raise(Nokogiri_wrap_xml_syntax_error(error));
} else {
Expand Down
2 changes: 1 addition & 1 deletion ext/nokogiri/xml_node.c
Original file line number Diff line number Diff line change
Expand Up @@ -2138,7 +2138,7 @@ process_xincludes(VALUE self, VALUE options)
xmlSetStructuredErrorFunc(NULL, NULL);

if (rcode < 0) {
xmlErrorPtr error;
xmlErrorConstPtr error;

error = xmlGetLastError();
if (error) {
Expand Down
2 changes: 1 addition & 1 deletion ext/nokogiri/xml_reader.c
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ static VALUE
read_more(VALUE self)
{
xmlTextReaderPtr reader;
xmlErrorPtr error;
xmlErrorConstPtr error;
VALUE error_list;
int ret;

Expand Down
2 changes: 1 addition & 1 deletion ext/nokogiri/xml_relax_ng.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ xml_relax_ng_parse_schema(
xmlRelaxNGFreeParserCtxt(c_parser_context);

if (NULL == c_schema) {
xmlErrorPtr error = xmlGetLastError();
xmlErrorConstPtr error = xmlGetLastError();
if (error) {
Nokogiri_error_raise(NULL, error);
} else {
Expand Down
2 changes: 1 addition & 1 deletion ext/nokogiri/xml_sax_push_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ native_write(VALUE self, VALUE _chunk, VALUE _last_chunk)

if (xmlParseChunk(ctx, chunk, size, Qtrue == _last_chunk ? 1 : 0)) {
if (!(ctx->options & XML_PARSE_RECOVER)) {
xmlErrorPtr e = xmlCtxtGetLastError(ctx);
xmlErrorConstPtr e = xmlCtxtGetLastError(ctx);
Nokogiri_error_raise(NULL, e);
}
}
Expand Down
2 changes: 1 addition & 1 deletion ext/nokogiri/xml_schema.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ xml_schema_parse_schema(
xmlSchemaFreeParserCtxt(c_parser_context);

if (NULL == c_schema) {
xmlErrorPtr error = xmlGetLastError();
xmlErrorConstPtr error = xmlGetLastError();
if (error) {
Nokogiri_error_raise(NULL, error);
} else {
Expand Down
6 changes: 3 additions & 3 deletions ext/nokogiri/xml_syntax_error.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,21 @@ Nokogiri_structured_error_func_restore(libxmlStructuredErrorHandlerState *handle
}

void
Nokogiri_error_array_pusher(void *ctx, xmlErrorPtr error)
Nokogiri_error_array_pusher(void *ctx, xmlErrorConstPtr error)
{
VALUE list = (VALUE)ctx;
Check_Type(list, T_ARRAY);
rb_ary_push(list, Nokogiri_wrap_xml_syntax_error(error));
}

void
Nokogiri_error_raise(void *ctx, xmlErrorPtr error)
Nokogiri_error_raise(void *ctx, xmlErrorConstPtr error)
{
rb_exc_raise(Nokogiri_wrap_xml_syntax_error(error));
}

VALUE
Nokogiri_wrap_xml_syntax_error(xmlErrorPtr error)
Nokogiri_wrap_xml_syntax_error(xmlErrorConstPtr error)
{
VALUE msg, e, klass;

Expand Down