Skip to content

Commit ffc40d2

Browse files
committed
Incompatible change! Remove all global deprecated LibXML options. Then update all Ruby methods that used to take an hash table of options to Ruby named parameters.
1 parent 317e55a commit ffc40d2

17 files changed

Lines changed: 2585 additions & 3008 deletions

ext/libxml/ruby_xml.c

Lines changed: 0 additions & 343 deletions
Original file line numberDiff line numberDiff line change
@@ -328,264 +328,6 @@ static VALUE rxml_enabled_zlib_q(VALUE klass)
328328
#endif
329329
}
330330

331-
/*
332-
* call-seq:
333-
* XML.debug_entities -> (true|false)
334-
*
335-
* Determine whether included-entity debugging is enabled.
336-
* (Requires Libxml to be compiled with debugging support)
337-
*/
338-
static VALUE rxml_debug_entities_get(VALUE klass)
339-
{
340-
#ifdef LIBXML_DEBUG_ENABLED
341-
if (xmlParserDebugEntities)
342-
return(Qtrue);
343-
else
344-
return(Qfalse);
345-
#else
346-
rb_warn("libxml was compiled with debugging turned off");
347-
return (Qfalse);
348-
#endif
349-
}
350-
351-
/*
352-
* call-seq:
353-
* XML.debug_entities = true|false
354-
*
355-
* Enable or disable included-entity debugging.
356-
* (Requires Libxml to be compiled with debugging support)
357-
*/
358-
static VALUE rxml_debug_entities_set(VALUE klass, VALUE value)
359-
{
360-
#ifdef LIBXML_DEBUG_ENABLED
361-
if (value == Qfalse)
362-
{
363-
xmlParserDebugEntities = 0;
364-
return(Qfalse);
365-
}
366-
else
367-
{
368-
xmlParserDebugEntities = 1;
369-
return(Qtrue);
370-
}
371-
#else
372-
rb_warn("libxml was compiled with debugging turned off");
373-
#endif
374-
}
375-
376-
/*
377-
* call-seq:
378-
* XML.default_keep_blanks -> (true|false)
379-
*
380-
* Determine whether parsers retain whitespace by default.
381-
*/
382-
static VALUE rxml_default_keep_blanks_get(VALUE klass)
383-
{
384-
if (xmlKeepBlanksDefaultValue)
385-
return (Qtrue);
386-
else
387-
return (Qfalse);
388-
}
389-
390-
/*
391-
* call-seq:
392-
* XML.default_keep_blanks = true|false
393-
*
394-
* Controls whether parsers retain whitespace by default.
395-
*/
396-
static VALUE rxml_default_keep_blanks_set(VALUE klass, VALUE value)
397-
{
398-
if (value == Qfalse)
399-
{
400-
xmlKeepBlanksDefaultValue = 0;
401-
return (Qfalse);
402-
}
403-
else if (value == Qtrue)
404-
{
405-
xmlKeepBlanksDefaultValue = 1;
406-
return (Qtrue);
407-
}
408-
else
409-
{
410-
rb_raise(rb_eArgError, "Invalid argument, must be a boolean");
411-
}
412-
}
413-
414-
/*
415-
* call-seq:
416-
* XML.default_load_external_dtd -> (true|false)
417-
*
418-
* Determine whether parsers load external DTDs by default.
419-
*/
420-
static VALUE rxml_default_load_external_dtd_get(VALUE klass)
421-
{
422-
if (xmlLoadExtDtdDefaultValue)
423-
return (Qtrue);
424-
else
425-
return (Qfalse);
426-
}
427-
428-
/*
429-
* call-seq:
430-
* XML.default_load_external_dtd = true|false
431-
*
432-
* Controls whether parsers load external DTDs by default.
433-
*/
434-
static VALUE rxml_default_load_external_dtd_set(VALUE klass, VALUE value)
435-
{
436-
if (value == Qfalse)
437-
{
438-
xmlLoadExtDtdDefaultValue = 0;
439-
return (Qfalse);
440-
}
441-
else
442-
{
443-
xmlLoadExtDtdDefaultValue = 1;
444-
return (Qtrue);
445-
}
446-
}
447-
448-
/*
449-
* call-seq:
450-
* XML.default_line_numbers -> (true|false)
451-
*
452-
* Determine whether parsers retain line-numbers by default.
453-
*/
454-
static VALUE rxml_default_line_numbers_get(VALUE klass)
455-
{
456-
if (xmlLineNumbersDefaultValue)
457-
return (Qtrue);
458-
else
459-
return (Qfalse);
460-
}
461-
462-
/*
463-
* call-seq:
464-
* XML.default_line_numbers = true|false
465-
*
466-
* Controls whether parsers retain line-numbers by default.
467-
*/
468-
static VALUE rxml_default_line_numbers_set(VALUE klass, VALUE value)
469-
{
470-
if (value == Qfalse)
471-
{
472-
xmlLineNumbersDefault(0);
473-
return (Qfalse);
474-
}
475-
else
476-
{
477-
xmlLineNumbersDefault(1);
478-
return (Qtrue);
479-
}
480-
}
481-
482-
int rxml_libxml_default_options(void)
483-
{
484-
int options = 0;
485-
486-
if (xmlLoadExtDtdDefaultValue)
487-
options |= XML_PARSE_DTDLOAD;
488-
489-
if (xmlDoValidityCheckingDefaultValue)
490-
options |= XML_PARSE_DTDVALID;
491-
492-
if (!xmlKeepBlanksDefaultValue)
493-
options |= XML_PARSE_NOBLANKS;
494-
495-
if (xmlSubstituteEntitiesDefaultValue)
496-
options |= XML_PARSE_NOENT;
497-
498-
if (!xmlGetWarningsDefaultValue)
499-
options |= XML_PARSE_NOWARNING;
500-
501-
if (xmlPedanticParserDefaultValue)
502-
options |= XML_PARSE_PEDANTIC;
503-
504-
return options;
505-
}
506-
507-
/*
508-
* call-seq:
509-
* XML.default_options -> int
510-
*
511-
* Returns an integer that summarize libxml2's default options.
512-
*/
513-
static VALUE rxml_default_options_get(VALUE klass)
514-
{
515-
int options = rxml_libxml_default_options();
516-
return INT2NUM(options);
517-
}
518-
519-
/*
520-
* call-seq:
521-
* XML.default_pedantic_parser -> (true|false)
522-
*
523-
* Determine whether parsers are pedantic by default.
524-
*/
525-
static VALUE rxml_default_pedantic_parser_get(VALUE klass)
526-
{
527-
if (xmlPedanticParserDefaultValue)
528-
return (Qtrue);
529-
else
530-
return (Qfalse);
531-
}
532-
533-
/*
534-
* call-seq:
535-
* XML.default_pedantic_parser = true|false
536-
*
537-
* Controls whether parsers are pedantic by default.
538-
*/
539-
static VALUE rxml_default_pedantic_parser_set(VALUE klass, VALUE value)
540-
{
541-
if (value == Qfalse)
542-
{
543-
xmlPedanticParserDefault(0);
544-
return (Qfalse);
545-
}
546-
else
547-
{
548-
xmlPedanticParserDefault(1);
549-
return (Qtrue);
550-
}
551-
}
552-
553-
/*
554-
* call-seq:
555-
* XML.default_substitute_entities -> (true|false)
556-
*
557-
* Determine whether parsers perform inline entity substitution
558-
* (for external entities) by default.
559-
*/
560-
static VALUE rxml_default_substitute_entities_get(VALUE klass)
561-
{
562-
if (xmlSubstituteEntitiesDefaultValue)
563-
return (Qtrue);
564-
else
565-
return (Qfalse);
566-
}
567-
568-
/*
569-
* call-seq:
570-
* XML.default_substitute_entities = true|false
571-
*
572-
* Controls whether parsers perform inline entity substitution
573-
* (for external entities) by default.
574-
*/
575-
static VALUE rxml_default_substitute_entities_set(VALUE klass, VALUE value)
576-
{
577-
if (value == Qfalse)
578-
{
579-
xmlSubstituteEntitiesDefault(0);
580-
return (Qfalse);
581-
}
582-
else
583-
{
584-
xmlSubstituteEntitiesDefault(1);
585-
return (Qtrue);
586-
}
587-
}
588-
589331
/*
590332
* call-seq:
591333
* XML.default_tree_indent_string -> "string"
@@ -615,74 +357,6 @@ static VALUE rxml_default_tree_indent_string_set(VALUE klass, VALUE string)
615357
return (string);
616358
}
617359

618-
/*
619-
* call-seq:
620-
* XML.default_validity_checking -> (true|false)
621-
*
622-
* Determine whether parsers perform XML validation by default.
623-
*/
624-
static VALUE rxml_default_validity_checking_get(VALUE klass)
625-
{
626-
if (xmlDoValidityCheckingDefaultValue)
627-
return (Qtrue);
628-
else
629-
return (Qfalse);
630-
}
631-
632-
/*
633-
* call-seq:
634-
* XML.default_validity_checking = true|false
635-
*
636-
* Controls whether parsers perform XML validation by default.
637-
*/
638-
static VALUE rxml_default_validity_checking_set(VALUE klass, VALUE value)
639-
{
640-
if (value == Qfalse)
641-
{
642-
xmlDoValidityCheckingDefaultValue = 0;
643-
return (Qfalse);
644-
}
645-
else
646-
{
647-
xmlDoValidityCheckingDefaultValue = 1;
648-
return (Qtrue);
649-
}
650-
}
651-
652-
/*
653-
* call-seq:
654-
* XML.default_warnings -> (true|false)
655-
*
656-
* Determine whether parsers output warnings by default.
657-
*/
658-
static VALUE rxml_default_warnings_get(VALUE klass)
659-
{
660-
if (xmlGetWarningsDefaultValue)
661-
return (Qtrue);
662-
else
663-
return (Qfalse);
664-
}
665-
666-
/*
667-
* call-seq:
668-
* XML.default_warnings = true|false
669-
*
670-
* Controls whether parsers output warnings by default.
671-
*/
672-
static VALUE rxml_default_warnings_set(VALUE klass, VALUE value)
673-
{
674-
if (value == Qfalse)
675-
{
676-
xmlGetWarningsDefaultValue = 0;
677-
return (Qfalse);
678-
}
679-
else
680-
{
681-
xmlGetWarningsDefaultValue = 1;
682-
return (Qtrue);
683-
}
684-
}
685-
686360
/*
687361
* call-seq:
688362
* XML.default_compression -> (true|false)
@@ -869,27 +543,10 @@ void rxml_init_xml(void)
869543
rb_define_module_function(mXML, "catalog_dump", rxml_catalog_dump, 0);
870544
rb_define_module_function(mXML, "catalog_remove", rxml_catalog_remove, 1);
871545
rb_define_module_function(mXML, "check_lib_versions", rxml_check_lib_versions, 0);
872-
rb_define_module_function(mXML, "debug_entities", rxml_debug_entities_get, 0);
873-
rb_define_module_function(mXML, "debug_entities=", rxml_debug_entities_set, 1);
874546
rb_define_module_function(mXML, "default_compression", rxml_default_compression_get, 0);
875547
rb_define_module_function(mXML, "default_compression=", rxml_default_compression_set, 1);
876-
rb_define_module_function(mXML, "default_keep_blanks", rxml_default_keep_blanks_get, 0);
877-
rb_define_module_function(mXML, "default_keep_blanks=", rxml_default_keep_blanks_set, 1);
878-
rb_define_module_function(mXML, "default_load_external_dtd", rxml_default_load_external_dtd_get, 0);
879-
rb_define_module_function(mXML, "default_load_external_dtd=", rxml_default_load_external_dtd_set, 1);
880-
rb_define_module_function(mXML, "default_line_numbers", rxml_default_line_numbers_get, 0);
881-
rb_define_module_function(mXML, "default_line_numbers=", rxml_default_line_numbers_set, 1);
882-
rb_define_module_function(mXML, "default_options", rxml_default_options_get, 0);
883-
rb_define_module_function(mXML, "default_pedantic_parser", rxml_default_pedantic_parser_get, 0);
884-
rb_define_module_function(mXML, "default_pedantic_parser=", rxml_default_pedantic_parser_set, 1);
885-
rb_define_module_function(mXML, "default_substitute_entities", rxml_default_substitute_entities_get, 0);
886-
rb_define_module_function(mXML, "default_substitute_entities=", rxml_default_substitute_entities_set, 1);
887548
rb_define_module_function(mXML, "default_tree_indent_string", rxml_default_tree_indent_string_get, 0);
888549
rb_define_module_function(mXML, "default_tree_indent_string=", rxml_default_tree_indent_string_set, 1);
889-
rb_define_module_function(mXML, "default_validity_checking", rxml_default_validity_checking_get, 0);
890-
rb_define_module_function(mXML, "default_validity_checking=", rxml_default_validity_checking_set, 1);
891-
rb_define_module_function(mXML, "default_warnings", rxml_default_warnings_get, 0);
892-
rb_define_module_function(mXML, "default_warnings=", rxml_default_warnings_set, 1);
893550
rb_define_module_function(mXML, "default_save_no_empty_tags", rxml_default_save_no_empty_tags_get, 0);
894551
rb_define_module_function(mXML, "default_save_no_empty_tags=", rxml_default_save_no_empty_tags_set, 1);
895552
rb_define_module_function(mXML, "indent_tree_output", rxml_indent_tree_output_get, 0);

ext/libxml/ruby_xml.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#define __RUBY_XML_H__
55

66
extern VALUE mXML;
7-
int rxml_libxml_default_options(void);
87
void rxml_init_xml(void);
98

109
#endif

0 commit comments

Comments
 (0)