0001-Make-it-compatible-with-libxml2--2-12-0.patch 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. From 49471812d57adfb22dcce3cbea1a8956658731b9 Mon Sep 17 00:00:00 2001
  2. From: Kjell Ahlstedt <kjellahlstedt@gmail.com>
  3. Date: Sat, 18 Nov 2023 18:34:07 +0100
  4. Subject: [PATCH] Make it compatible with libxml2 >= 2.12.0
  5. * libxml++/document.cc:
  6. * libxml++/dtd.cc:
  7. * libxml++/nodes/entitydeclaration.cc:
  8. * libxml++/nodes/entityreference.cc:
  9. * libxml++/validators/relaxngvalidator.cc: Modify #include directives.
  10. * libxml++/keepblanks.cc: Ignore deprecation of xmlKeepBlanksDefault().
  11. * tests/saxparser_chunk_parsing_inconsistent_state/main.cc:
  12. Accept that MySaxParser::on_start_document() can be called before
  13. MySaxParser::on_error().
  14. Upstream: https://github.com/libxmlplusplus/libxmlplusplus/commit/49471812d57adfb22dcce3cbea1a8956658731b9
  15. Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
  16. ---
  17. libxml++/document.cc | 1 +
  18. libxml++/dtd.cc | 2 +-
  19. libxml++/keepblanks.cc | 5 ++++-
  20. libxml++/nodes/entitydeclaration.cc | 2 +-
  21. libxml++/nodes/entityreference.cc | 2 +-
  22. libxml++/validators/relaxngvalidator.cc | 1 +
  23. .../saxparser_chunk_parsing_inconsistent_state/main.cc | 10 +++++++++-
  24. 7 files changed, 18 insertions(+), 5 deletions(-)
  25. diff --git a/libxml++/document.cc b/libxml++/document.cc
  26. index da0a8f5..d5476c6 100644
  27. --- a/libxml++/document.cc
  28. +++ b/libxml++/document.cc
  29. @@ -16,6 +16,7 @@
  30. #include <libxml/tree.h>
  31. #include <libxml/xinclude.h>
  32. +#include <libxml/xmlsave.h>
  33. #include <libxml/parser.h> // XML_PARSE_NOXINCNODE, XML_PARSE_NOBASEFIX
  34. #include <iostream>
  35. diff --git a/libxml++/dtd.cc b/libxml++/dtd.cc
  36. index 238b3a0..8014c07 100644
  37. --- a/libxml++/dtd.cc
  38. +++ b/libxml++/dtd.cc
  39. @@ -8,7 +8,7 @@
  40. #include <libxml++/exceptions/parse_error.h>
  41. #include <libxml++/io/istreamparserinputbuffer.h>
  42. -#include <libxml/tree.h>
  43. +#include <libxml/parser.h>
  44. #include <sstream>
  45. diff --git a/libxml++/keepblanks.cc b/libxml++/keepblanks.cc
  46. index 4228b8d..56b00cf 100644
  47. --- a/libxml++/keepblanks.cc
  48. +++ b/libxml++/keepblanks.cc
  49. @@ -5,8 +5,11 @@
  50. * included with libxml++ as the file COPYING.
  51. */
  52. -#include <libxml++/keepblanks.h>
  53. +// xmlKeepBlanksDefault() is deprecated since libxml2 2.12.0.
  54. +// Ignore deprecations here.
  55. +#define XML_DEPRECATED
  56. +#include <libxml++/keepblanks.h>
  57. #include <libxml/globals.h>
  58. namespace xmlpp
  59. diff --git a/libxml++/nodes/entitydeclaration.cc b/libxml++/nodes/entitydeclaration.cc
  60. index 0a6390e..d5bfa75 100644
  61. --- a/libxml++/nodes/entitydeclaration.cc
  62. +++ b/libxml++/nodes/entitydeclaration.cc
  63. @@ -5,7 +5,7 @@
  64. */
  65. #include <libxml++/nodes/entitydeclaration.h>
  66. -#include <libxml/tree.h>
  67. +#include <libxml/entities.h>
  68. namespace xmlpp
  69. {
  70. diff --git a/libxml++/nodes/entityreference.cc b/libxml++/nodes/entityreference.cc
  71. index 19b1b22..278a126 100644
  72. --- a/libxml++/nodes/entityreference.cc
  73. +++ b/libxml++/nodes/entityreference.cc
  74. @@ -6,7 +6,7 @@
  75. #include <libxml++/nodes/entityreference.h>
  76. -#include <libxml/tree.h>
  77. +#include <libxml/entities.h>
  78. namespace xmlpp
  79. {
  80. diff --git a/libxml++/validators/relaxngvalidator.cc b/libxml++/validators/relaxngvalidator.cc
  81. index 9bb10c2..68a814c 100644
  82. --- a/libxml++/validators/relaxngvalidator.cc
  83. +++ b/libxml++/validators/relaxngvalidator.cc
  84. @@ -22,6 +22,7 @@
  85. #include "libxml++/parsers/domparser.h"
  86. #include "libxml++/relaxngschema.h"
  87. +#include <libxml/tree.h>
  88. #include <libxml/relaxng.h>
  89. namespace xmlpp
  90. diff --git a/tests/saxparser_chunk_parsing_inconsistent_state/main.cc b/tests/saxparser_chunk_parsing_inconsistent_state/main.cc
  91. index 07cc3ef..53f55b3 100644
  92. --- a/tests/saxparser_chunk_parsing_inconsistent_state/main.cc
  93. +++ b/tests/saxparser_chunk_parsing_inconsistent_state/main.cc
  94. @@ -24,10 +24,14 @@
  95. class MySaxParser : public xmlpp::SaxParser
  96. {
  97. +public:
  98. + bool throw_on_start_doc = true;
  99. +
  100. protected:
  101. void on_start_document() override
  102. {
  103. - throw std::runtime_error("some custom runtime exception");
  104. + if (throw_on_start_doc)
  105. + throw std::runtime_error("some custom runtime exception");
  106. }
  107. void on_error(const xmlpp::ustring& /* text */) override
  108. {
  109. @@ -43,6 +47,9 @@ int main()
  110. bool exceptionThrown = false;
  111. try
  112. {
  113. + // Depending on the libxml2 version, MySaxParser::on_start_document()
  114. + // may or may not be called before MySaxParser::on_error().
  115. + parser.throw_on_start_doc = false;
  116. parser.parse_chunk("<?");
  117. parser.finish_chunk_parsing();
  118. }
  119. @@ -61,6 +68,7 @@ int main()
  120. exceptionThrown = false;
  121. try
  122. {
  123. + parser.throw_on_start_doc = true;
  124. std::stringstream ss("<root></root>");
  125. parser.parse_stream(ss);
  126. }