Skip to content

Commit

Permalink
Incompatible change! Remove all global deprecated LibXML options. The…
Browse files Browse the repository at this point in the history
…n update all Ruby methods that used to take an hash table of options to Ruby named parameters.
  • Loading branch information
cfis committed Jan 8, 2024
1 parent 317e55a commit ffc40d2
Show file tree
Hide file tree
Showing 17 changed files with 2,585 additions and 3,008 deletions.
343 changes: 0 additions & 343 deletions ext/libxml/ruby_xml.c
Original file line number Diff line number Diff line change
Expand Up @@ -328,264 +328,6 @@ static VALUE rxml_enabled_zlib_q(VALUE klass)
#endif
}

/*
* call-seq:
* XML.debug_entities -> (true|false)
*
* Determine whether included-entity debugging is enabled.
* (Requires Libxml to be compiled with debugging support)
*/
static VALUE rxml_debug_entities_get(VALUE klass)
{
#ifdef LIBXML_DEBUG_ENABLED
if (xmlParserDebugEntities)
return(Qtrue);
else
return(Qfalse);
#else
rb_warn("libxml was compiled with debugging turned off");
return (Qfalse);
#endif
}

/*
* call-seq:
* XML.debug_entities = true|false
*
* Enable or disable included-entity debugging.
* (Requires Libxml to be compiled with debugging support)
*/
static VALUE rxml_debug_entities_set(VALUE klass, VALUE value)
{
#ifdef LIBXML_DEBUG_ENABLED
if (value == Qfalse)
{
xmlParserDebugEntities = 0;
return(Qfalse);
}
else
{
xmlParserDebugEntities = 1;
return(Qtrue);
}
#else
rb_warn("libxml was compiled with debugging turned off");
#endif
}

/*
* call-seq:
* XML.default_keep_blanks -> (true|false)
*
* Determine whether parsers retain whitespace by default.
*/
static VALUE rxml_default_keep_blanks_get(VALUE klass)
{
if (xmlKeepBlanksDefaultValue)
return (Qtrue);
else
return (Qfalse);
}

/*
* call-seq:
* XML.default_keep_blanks = true|false
*
* Controls whether parsers retain whitespace by default.
*/
static VALUE rxml_default_keep_blanks_set(VALUE klass, VALUE value)
{
if (value == Qfalse)
{
xmlKeepBlanksDefaultValue = 0;
return (Qfalse);
}
else if (value == Qtrue)
{
xmlKeepBlanksDefaultValue = 1;
return (Qtrue);
}
else
{
rb_raise(rb_eArgError, "Invalid argument, must be a boolean");
}
}

/*
* call-seq:
* XML.default_load_external_dtd -> (true|false)
*
* Determine whether parsers load external DTDs by default.
*/
static VALUE rxml_default_load_external_dtd_get(VALUE klass)
{
if (xmlLoadExtDtdDefaultValue)
return (Qtrue);
else
return (Qfalse);
}

/*
* call-seq:
* XML.default_load_external_dtd = true|false
*
* Controls whether parsers load external DTDs by default.
*/
static VALUE rxml_default_load_external_dtd_set(VALUE klass, VALUE value)
{
if (value == Qfalse)
{
xmlLoadExtDtdDefaultValue = 0;
return (Qfalse);
}
else
{
xmlLoadExtDtdDefaultValue = 1;
return (Qtrue);
}
}

/*
* call-seq:
* XML.default_line_numbers -> (true|false)
*
* Determine whether parsers retain line-numbers by default.
*/
static VALUE rxml_default_line_numbers_get(VALUE klass)
{
if (xmlLineNumbersDefaultValue)
return (Qtrue);
else
return (Qfalse);
}

/*
* call-seq:
* XML.default_line_numbers = true|false
*
* Controls whether parsers retain line-numbers by default.
*/
static VALUE rxml_default_line_numbers_set(VALUE klass, VALUE value)
{
if (value == Qfalse)
{
xmlLineNumbersDefault(0);
return (Qfalse);
}
else
{
xmlLineNumbersDefault(1);
return (Qtrue);
}
}

int rxml_libxml_default_options(void)
{
int options = 0;

if (xmlLoadExtDtdDefaultValue)
options |= XML_PARSE_DTDLOAD;

if (xmlDoValidityCheckingDefaultValue)
options |= XML_PARSE_DTDVALID;

if (!xmlKeepBlanksDefaultValue)
options |= XML_PARSE_NOBLANKS;

if (xmlSubstituteEntitiesDefaultValue)
options |= XML_PARSE_NOENT;

if (!xmlGetWarningsDefaultValue)
options |= XML_PARSE_NOWARNING;

if (xmlPedanticParserDefaultValue)
options |= XML_PARSE_PEDANTIC;

return options;
}

/*
* call-seq:
* XML.default_options -> int
*
* Returns an integer that summarize libxml2's default options.
*/
static VALUE rxml_default_options_get(VALUE klass)
{
int options = rxml_libxml_default_options();
return INT2NUM(options);
}

/*
* call-seq:
* XML.default_pedantic_parser -> (true|false)
*
* Determine whether parsers are pedantic by default.
*/
static VALUE rxml_default_pedantic_parser_get(VALUE klass)
{
if (xmlPedanticParserDefaultValue)
return (Qtrue);
else
return (Qfalse);
}

/*
* call-seq:
* XML.default_pedantic_parser = true|false
*
* Controls whether parsers are pedantic by default.
*/
static VALUE rxml_default_pedantic_parser_set(VALUE klass, VALUE value)
{
if (value == Qfalse)
{
xmlPedanticParserDefault(0);
return (Qfalse);
}
else
{
xmlPedanticParserDefault(1);
return (Qtrue);
}
}

/*
* call-seq:
* XML.default_substitute_entities -> (true|false)
*
* Determine whether parsers perform inline entity substitution
* (for external entities) by default.
*/
static VALUE rxml_default_substitute_entities_get(VALUE klass)
{
if (xmlSubstituteEntitiesDefaultValue)
return (Qtrue);
else
return (Qfalse);
}

/*
* call-seq:
* XML.default_substitute_entities = true|false
*
* Controls whether parsers perform inline entity substitution
* (for external entities) by default.
*/
static VALUE rxml_default_substitute_entities_set(VALUE klass, VALUE value)
{
if (value == Qfalse)
{
xmlSubstituteEntitiesDefault(0);
return (Qfalse);
}
else
{
xmlSubstituteEntitiesDefault(1);
return (Qtrue);
}
}

/*
* call-seq:
* XML.default_tree_indent_string -> "string"
Expand Down Expand Up @@ -615,74 +357,6 @@ static VALUE rxml_default_tree_indent_string_set(VALUE klass, VALUE string)
return (string);
}

/*
* call-seq:
* XML.default_validity_checking -> (true|false)
*
* Determine whether parsers perform XML validation by default.
*/
static VALUE rxml_default_validity_checking_get(VALUE klass)
{
if (xmlDoValidityCheckingDefaultValue)
return (Qtrue);
else
return (Qfalse);
}

/*
* call-seq:
* XML.default_validity_checking = true|false
*
* Controls whether parsers perform XML validation by default.
*/
static VALUE rxml_default_validity_checking_set(VALUE klass, VALUE value)
{
if (value == Qfalse)
{
xmlDoValidityCheckingDefaultValue = 0;
return (Qfalse);
}
else
{
xmlDoValidityCheckingDefaultValue = 1;
return (Qtrue);
}
}

/*
* call-seq:
* XML.default_warnings -> (true|false)
*
* Determine whether parsers output warnings by default.
*/
static VALUE rxml_default_warnings_get(VALUE klass)
{
if (xmlGetWarningsDefaultValue)
return (Qtrue);
else
return (Qfalse);
}

/*
* call-seq:
* XML.default_warnings = true|false
*
* Controls whether parsers output warnings by default.
*/
static VALUE rxml_default_warnings_set(VALUE klass, VALUE value)
{
if (value == Qfalse)
{
xmlGetWarningsDefaultValue = 0;
return (Qfalse);
}
else
{
xmlGetWarningsDefaultValue = 1;
return (Qtrue);
}
}

/*
* call-seq:
* XML.default_compression -> (true|false)
Expand Down Expand Up @@ -869,27 +543,10 @@ void rxml_init_xml(void)
rb_define_module_function(mXML, "catalog_dump", rxml_catalog_dump, 0);
rb_define_module_function(mXML, "catalog_remove", rxml_catalog_remove, 1);
rb_define_module_function(mXML, "check_lib_versions", rxml_check_lib_versions, 0);
rb_define_module_function(mXML, "debug_entities", rxml_debug_entities_get, 0);
rb_define_module_function(mXML, "debug_entities=", rxml_debug_entities_set, 1);
rb_define_module_function(mXML, "default_compression", rxml_default_compression_get, 0);
rb_define_module_function(mXML, "default_compression=", rxml_default_compression_set, 1);
rb_define_module_function(mXML, "default_keep_blanks", rxml_default_keep_blanks_get, 0);
rb_define_module_function(mXML, "default_keep_blanks=", rxml_default_keep_blanks_set, 1);
rb_define_module_function(mXML, "default_load_external_dtd", rxml_default_load_external_dtd_get, 0);
rb_define_module_function(mXML, "default_load_external_dtd=", rxml_default_load_external_dtd_set, 1);
rb_define_module_function(mXML, "default_line_numbers", rxml_default_line_numbers_get, 0);
rb_define_module_function(mXML, "default_line_numbers=", rxml_default_line_numbers_set, 1);
rb_define_module_function(mXML, "default_options", rxml_default_options_get, 0);
rb_define_module_function(mXML, "default_pedantic_parser", rxml_default_pedantic_parser_get, 0);
rb_define_module_function(mXML, "default_pedantic_parser=", rxml_default_pedantic_parser_set, 1);
rb_define_module_function(mXML, "default_substitute_entities", rxml_default_substitute_entities_get, 0);
rb_define_module_function(mXML, "default_substitute_entities=", rxml_default_substitute_entities_set, 1);
rb_define_module_function(mXML, "default_tree_indent_string", rxml_default_tree_indent_string_get, 0);
rb_define_module_function(mXML, "default_tree_indent_string=", rxml_default_tree_indent_string_set, 1);
rb_define_module_function(mXML, "default_validity_checking", rxml_default_validity_checking_get, 0);
rb_define_module_function(mXML, "default_validity_checking=", rxml_default_validity_checking_set, 1);
rb_define_module_function(mXML, "default_warnings", rxml_default_warnings_get, 0);
rb_define_module_function(mXML, "default_warnings=", rxml_default_warnings_set, 1);
rb_define_module_function(mXML, "default_save_no_empty_tags", rxml_default_save_no_empty_tags_get, 0);
rb_define_module_function(mXML, "default_save_no_empty_tags=", rxml_default_save_no_empty_tags_set, 1);
rb_define_module_function(mXML, "indent_tree_output", rxml_indent_tree_output_get, 0);
Expand Down
1 change: 0 additions & 1 deletion ext/libxml/ruby_xml.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#define __RUBY_XML_H__

extern VALUE mXML;
int rxml_libxml_default_options(void);
void rxml_init_xml(void);

#endif
Loading

0 comments on commit ffc40d2

Please sign in to comment.