ext/xml/ruby_xml_parser.c in libxml-ruby-0.3.8 vs ext/xml/ruby_xml_parser.c in libxml-ruby-0.3.8.2

- old
+ new

@@ -1,9 +1,11 @@ -/* $Id: ruby_xml_parser.c,v 1.3 2006/03/27 20:49:19 roscopeco Exp $ */ +/* $Id: ruby_xml_parser.c,v 1.5 2006/11/20 01:22:07 roscopeco Exp $ */ +/* $Id: ruby_xml_parser.c,v 1.5 2006/11/20 01:22:07 roscopeco Exp $ */ /* Please see the LICENSE file for copyright and distribution information */ +#include <stdarg.h> #include "libxml.h" static VALUE libxml_xmlRubyErrorProc = Qnil; static int id_call; @@ -1281,16 +1283,15 @@ #ifdef RDOC_NEVER_DEFINED mXML = rb_define_module("XML"); #endif void -ruby_init_parser(void) { - +ruby_init_parser(void) { cXMLParser = rb_define_class_under(mXML, "Parser", rb_cObject); eXMLParserParseError = rb_define_class_under(cXMLParser, "ParseError", rb_eRuntimeError); - + /* Constants */ rb_define_const(cXMLParser, "LIBXML_VERSION", rb_str_new2(LIBXML_DOTTED_VERSION)); rb_define_const(cXMLParser, "VERSION", rb_str_new2(RUBY_LIBXML_VERSION)); rb_define_const(cXMLParser, "VERNUM", INT2NUM(RUBY_LIBXML_VERNUM)); @@ -1411,7 +1412,12 @@ rb_define_method(cXMLParser, "string=", ruby_xml_parser_str_set, 1); // set up error handling xmlSetGenericErrorFunc(NULL, libxml_xmlErrorFuncHandler); xmlThrDefSetGenericErrorFunc(NULL, libxml_xmlErrorFuncHandler); + + // Ruby needs to know about this even though it's not exported, otherwise + // our error proc might get garbage collected. + rb_global_variable(&libxml_xmlRubyErrorProc); + id_call = rb_intern("call"); }