Sha256: 44cca4cf6992ff44288ee690214c15a016b81f6000b66402d8dc620613e6faf7

Contents?: true

Size: 1.09 KB

Versions: 173

Compression:

Stored size: 1.09 KB

Contents

#include <nokogiri.h>

static VALUE foreign_error_handler_block = Qnil;

static void
foreign_error_handler(void *user_data, xmlErrorConstPtr c_error)
{
  rb_funcall(foreign_error_handler_block, rb_intern("call"), 0);
}

/*
 * call-seq:
 *   __foreign_error_handler { ... } -> nil
 *
 * Override libxml2's global error handlers to call the block. This method thus has very little
 * value except to test that Nokogiri is properly setting error handlers elsewhere in the code. See
 * test/helper.rb for how this is being used.
 */
static VALUE
rb_foreign_error_handler(VALUE klass)
{
  rb_need_block();
  foreign_error_handler_block = rb_block_proc();
  xmlSetStructuredErrorFunc(NULL, foreign_error_handler);
  return Qnil;
}

/*
 *  Document-module: Nokogiri::Test
 *
 *  The Nokogiri::Test module should only be used for testing Nokogiri.
 *  Do NOT use this outside of the Nokogiri test suite.
 */
void
noko_init_test_global_handlers(void)
{
  VALUE mNokogiriTest = rb_define_module_under(mNokogiri, "Test");

  rb_define_singleton_method(mNokogiriTest, "__foreign_error_handler", rb_foreign_error_handler, 0);
}

Version data entries

173 entries across 173 versions & 7 rubygems

Version Path
minato_ruby_api_client-0.2.2 vendor/bundle/ruby/3.2.0/gems/nokogiri-1.16.6-x86_64-linux/ext/nokogiri/test_global_handlers.c
nokogiri-1.18.1-x86_64-linux-musl ext/nokogiri/test_global_handlers.c
nokogiri-1.18.1-x86_64-linux-gnu ext/nokogiri/test_global_handlers.c
nokogiri-1.18.1-x86_64-darwin ext/nokogiri/test_global_handlers.c
nokogiri-1.18.1-x64-mingw-ucrt ext/nokogiri/test_global_handlers.c
nokogiri-1.18.1-java ext/nokogiri/test_global_handlers.c
nokogiri-1.18.1 ext/nokogiri/test_global_handlers.c
nokogiri-1.18.1-arm-linux-musl ext/nokogiri/test_global_handlers.c
nokogiri-1.18.1-arm-linux-gnu ext/nokogiri/test_global_handlers.c
nokogiri-1.18.1-arm64-darwin ext/nokogiri/test_global_handlers.c
nokogiri-1.18.1-aarch64-linux-musl ext/nokogiri/test_global_handlers.c
nokogiri-1.18.1-aarch64-linux-gnu ext/nokogiri/test_global_handlers.c
nokogiri-1.18.0-x86_64-linux-musl ext/nokogiri/test_global_handlers.c
nokogiri-1.18.0-x86_64-linux-gnu ext/nokogiri/test_global_handlers.c
nokogiri-1.18.0-x86_64-darwin ext/nokogiri/test_global_handlers.c
nokogiri-1.18.0-x64-mingw-ucrt ext/nokogiri/test_global_handlers.c
nokogiri-1.18.0-java ext/nokogiri/test_global_handlers.c
nokogiri-1.18.0 ext/nokogiri/test_global_handlers.c
nokogiri-1.18.0-arm-linux-musl ext/nokogiri/test_global_handlers.c
nokogiri-1.18.0-arm-linux-gnu ext/nokogiri/test_global_handlers.c