Skip to content

Commit 32659dd

Browse files
committed
Fix some libxml2 2.15.0 regressions
1 parent 63b9790 commit 32659dd

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

lib/LibXML/Raw.rakumod

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -884,8 +884,12 @@ class xmlXPathParserContext is export {
884884

885885
has int32 $.valueFrame; # used to limit Pop on the stack
886886

887+
#++ valuePush, valuePop renamed in libxml2 v2.15.0
887888
method valuePop(--> xmlXPathObject) is native($XML2) {*}
888889
method valuePush(xmlXPathObject --> int32) is native($XML2) {*}
890+
#++ libxml2 v2.15.0+
891+
method XPathPop(--> xmlXPathObject) is symbol('xmlXPathValuePop') is native($XML2) {*}
892+
method XPathPush(xmlXPathObject --> int32) is symbol('xmlXPathValuePush') is native($XML2) {*}
889893
}
890894

891895
class anyNode is export does LibXML::Raw::DOM::Node {

lib/LibXML/XPath/Context.rakumod

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,15 @@ method varLookupFunc returns Routine is rw {
325325
method registerFunctionNS(QName:D $name, Str $uri, &func, |args) {
326326
$!raw.RegisterFuncNS(
327327
$name, $uri,
328-
-> xmlXPathParserContext $ctxt, Int $n {
328+
self.config.version >= v2.15.00
329+
?? -> xmlXPathParserContext $ctxt, Int $n {
330+
CATCH { default { $ctxt.XPathPush: callback-error($_) } }
331+
my @params = reverse(self.get-value($ctxt.XPathPop) xx $n);
332+
my $ret = &func(|@params, |args) // '';
333+
my xmlXPathObject:D $out := xmlXPathObject.COERCE: $*XPATH-CONTEXT.park($ret, :$ctxt);
334+
$ctxt.XPathPush($_) for $out;
335+
}
336+
!! -> xmlXPathParserContext $ctxt, Int $n {
329337
CATCH { default { $ctxt.valuePush: callback-error($_) } }
330338
my @params = reverse(self.get-value($ctxt.valuePop) xx $n);
331339
my $ret = &func(|@params, |args) // '';

t/02parse.t

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -743,10 +743,10 @@ subtest 'line numbers', {
743743
lives-ok { $doc = $parser.parse: :string( $goodxml ); };
744744

745745
$root = $doc.documentElement();
746-
is $root.line-number(), 0, "line number is 0";
746+
is $root.line-number(), 0|2, "line number is 0";
747747

748748
@kids = $root.childNodes();
749-
is @kids[1].line-number(), 0, "line number is 0";
749+
is @kids[1].line-number(), 0|3, "line number is 0";
750750
}
751751

752752
subtest 'clean namespaces', {

0 commit comments

Comments
 (0)