leptris 1.9.313.0-arm-linux → 1.9.317.0-arm-linux

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +30 -0
  3. data/Rakefile +1 -1
  4. data/lib/leptris/version.rb +1 -1
  5. data/lib/libleptris.so +0 -0
  6. data/vendor-src/README.md +1 -1
  7. data/vendor-src/libleptris/CHANGELOG.md +92 -0
  8. data/vendor-src/libleptris/CMakeLists.txt +1 -1
  9. data/vendor-src/libleptris/bindings/rust/descriptor/src/lib.rs +6 -0
  10. data/vendor-src/libleptris/bindings/rust/descriptor/tests/layout.rs +1 -0
  11. data/vendor-src/libleptris/cli/commands/xquery.c +25 -2
  12. data/vendor-src/libleptris/src/include/leptris/descriptor.h +8 -1
  13. data/vendor-src/libleptris/src/leptris/descriptor/plan.c +46 -5
  14. data/vendor-src/libleptris/src/leptris/leptris_internal.h +19 -0
  15. data/vendor-src/libleptris/src/leptris/xpath/evaluator.c +12 -0
  16. data/vendor-src/libleptris/src/leptris/xpath/evaluator_operators.c +276 -24
  17. data/vendor-src/libleptris/src/leptris/xpath/functions.c +35 -0
  18. data/vendor-src/libleptris/src/leptris/xpath/functions_ext31.c +158 -28
  19. data/vendor-src/libleptris/src/leptris/xpath/parser.c +48 -8
  20. data/vendor-src/libleptris/src/leptris/xpath/xpath_public.c +19 -0
  21. data/vendor-src/libleptris/src/leptris/xquery/xquery.c +16 -0
  22. data/vendor-src/libleptris/test/CMakeLists.txt +1 -0
  23. data/vendor-src/libleptris/test/abi/test_descriptor.cpp +141 -0
  24. data/vendor-src/libleptris/test/parser/test_whitespace_shape.cpp +153 -0
  25. data/vendor-src/libleptris/test/xquery/test_qt3.cpp +6 -6
  26. data/vendor-src/libleptris/test/xquery/test_xquery.cpp +134 -5
  27. data/vendor-src/libleptris/vcpkg.json +1 -1
  28. metadata +2 -1
@@ -0,0 +1,153 @@
1
+ // test/parser/test_whitespace_shape.cpp — #1559 cross-platform DOM
2
+ // contract for inter-element whitespace.
3
+ //
4
+ // Same input must yield the same DOM on every platform build
5
+ // (x86_64-linux, aarch64-linux, s390x, macOS Intel/Apple Silicon,
6
+ // ILP32): the default parse PRESERVES whitespace-only text nodes
7
+ // (direct_parse runs with drop_ws_text = 0), and pretty-printed
8
+ // documents keep exactly one text child per indentation run.
9
+ // Relaton/moxl consumers observe field presence through these
10
+ // nodes, so a lane or SIMD path that drops them flips downstream
11
+ // joins on one architecture only. These specs pin the shape so any
12
+ // diverging build leg goes red on its own runner.
13
+
14
+ #include <gtest/gtest.h>
15
+
16
+ #include "leptris.h"
17
+
18
+ #include <cstring>
19
+
20
+ namespace {
21
+
22
+ struct ChildShape {
23
+ int kind; // LEPTRIS_NODE_TYPE_*
24
+ const char* text; // expected content when kind == TEXT
25
+ };
26
+
27
+ // Walk root's children in order and assert count + kind + content.
28
+ void expect_child_shape(LeptrisDocument doc, const ChildShape* want,
29
+ size_t n) {
30
+ LeptrisElement root = leptris_document_root(doc);
31
+ ASSERT_NE(root, nullptr);
32
+ LeptrisNodeRef c = leptris_node_first_child(leptris_element_as_node(root));
33
+ for (size_t i = 0; i < n; i++) {
34
+ ASSERT_NE(c, nullptr) << "child " << i << " missing";
35
+ EXPECT_EQ(leptris_node_get_type(c), want[i].kind)
36
+ << "child " << i << " kind";
37
+ if (want[i].kind == (int)LEPTRIS_NODE_TYPE_TEXT)
38
+ EXPECT_STREQ(leptris_text_node_get_content(c), want[i].text)
39
+ << "child " << i << " content";
40
+ c = leptris_node_next_sibling(c);
41
+ }
42
+ EXPECT_EQ(c, nullptr) << "extra children past " << n;
43
+ }
44
+
45
+ } // namespace
46
+
47
+ /* The #1559 repro shape: newline + indentation between elements.
48
+ * Every platform must keep all three ws-only text children. */
49
+ TEST(WhitespaceShape, PrettyPrintedChildrenPreserved) {
50
+ const char xml[] = "<r>\n <a/>\n <b/>\n</r>\n";
51
+ LeptrisDocument doc = leptris_parse_string(xml, std::strlen(xml), nullptr);
52
+ ASSERT_NE(doc, nullptr);
53
+ const ChildShape want[] = {
54
+ {(int)LEPTRIS_NODE_TYPE_TEXT, "\n "},
55
+ {(int)LEPTRIS_NODE_TYPE_ELEMENT, nullptr},
56
+ {(int)LEPTRIS_NODE_TYPE_TEXT, "\n "},
57
+ {(int)LEPTRIS_NODE_TYPE_ELEMENT, nullptr},
58
+ {(int)LEPTRIS_NODE_TYPE_TEXT, "\n"},
59
+ };
60
+ expect_child_shape(doc, want, 5);
61
+ leptris_document_free(doc);
62
+ }
63
+
64
+ /* Bibdata-shaped: nested pretty printing — each level keeps its
65
+ * indentation runs (relaton's field-presence signal). */
66
+ TEST(WhitespaceShape, PrettyPrintedNestedBibitem) {
67
+ const char xml[] =
68
+ "<bibitem>\n"
69
+ " <title>\n"
70
+ " <span>Standard</span>\n"
71
+ " </title>\n"
72
+ " <extent/>\n"
73
+ "</bibitem>\n";
74
+ LeptrisDocument doc = leptris_parse_string(xml, std::strlen(xml), nullptr);
75
+ ASSERT_NE(doc, nullptr);
76
+
77
+ LeptrisElement root = leptris_document_root(doc);
78
+ ASSERT_NE(root, nullptr);
79
+ const ChildShape bib[] = {
80
+ {(int)LEPTRIS_NODE_TYPE_TEXT, "\n "},
81
+ {(int)LEPTRIS_NODE_TYPE_ELEMENT, nullptr},
82
+ {(int)LEPTRIS_NODE_TYPE_TEXT, "\n "},
83
+ {(int)LEPTRIS_NODE_TYPE_ELEMENT, nullptr},
84
+ {(int)LEPTRIS_NODE_TYPE_TEXT, "\n"},
85
+ };
86
+ expect_child_shape(doc, bib, 5);
87
+
88
+ /* title: "\n ", span, "\n " — mixed content keeps runs. */
89
+ LeptrisNodeRef c = leptris_node_first_child(leptris_element_as_node(root));
90
+ c = leptris_node_next_sibling(c); /* past leading text */
91
+ ASSERT_EQ(leptris_node_get_type(c), (int)LEPTRIS_NODE_TYPE_ELEMENT);
92
+ LeptrisNodeRef tc = leptris_node_first_child(c);
93
+ ASSERT_NE(tc, nullptr);
94
+ ASSERT_EQ(leptris_node_get_type(tc), (int)LEPTRIS_NODE_TYPE_TEXT);
95
+ EXPECT_STREQ(leptris_text_node_get_content(tc), "\n ");
96
+ tc = leptris_node_next_sibling(tc);
97
+ ASSERT_EQ(leptris_node_get_type(tc), (int)LEPTRIS_NODE_TYPE_ELEMENT);
98
+ tc = leptris_node_next_sibling(tc);
99
+ ASSERT_NE(tc, nullptr);
100
+ EXPECT_EQ(leptris_node_get_type(tc), (int)LEPTRIS_NODE_TYPE_TEXT);
101
+ EXPECT_STREQ(leptris_text_node_get_content(tc), "\n ");
102
+ EXPECT_EQ(leptris_node_next_sibling(tc), nullptr);
103
+
104
+ /* extent: no children at all (two siblings past title:
105
+ * text("\n ") then extent). */
106
+ c = leptris_node_next_sibling(leptris_node_next_sibling(c));
107
+ ASSERT_NE(c, nullptr);
108
+ ASSERT_EQ(leptris_node_get_type(c), (int)LEPTRIS_NODE_TYPE_ELEMENT);
109
+ EXPECT_EQ(leptris_node_first_child(c), nullptr);
110
+ leptris_document_free(doc);
111
+ }
112
+
113
+ /* The collapsed spelling the issue used as the control: no
114
+ * whitespace, no text children — every platform. */
115
+ TEST(WhitespaceShape, CollapsedChildrenHaveNoTextNodes) {
116
+ const char xml[] = "<r><a/><b/></r>";
117
+ LeptrisDocument doc = leptris_parse_string(xml, std::strlen(xml), nullptr);
118
+ ASSERT_NE(doc, nullptr);
119
+ const ChildShape want[] = {
120
+ {(int)LEPTRIS_NODE_TYPE_ELEMENT, nullptr},
121
+ {(int)LEPTRIS_NODE_TYPE_ELEMENT, nullptr},
122
+ };
123
+ expect_child_shape(doc, want, 2);
124
+ leptris_document_free(doc);
125
+ }
126
+
127
+ /* Whitespace INSIDE an element is content, not inter-element —
128
+ * never eligible for the drop flag's fast path. */
129
+ TEST(WhitespaceShape, SoleChildWhitespaceIsContent) {
130
+ const char xml[] = "<p>\n </p>";
131
+ LeptrisDocument doc = leptris_parse_string(xml, std::strlen(xml), nullptr);
132
+ ASSERT_NE(doc, nullptr);
133
+ const ChildShape want[] = {
134
+ {(int)LEPTRIS_NODE_TYPE_TEXT, "\n "},
135
+ };
136
+ expect_child_shape(doc, want, 1);
137
+ leptris_document_free(doc);
138
+ }
139
+
140
+ /* CRLF runs normalize to LF (XML 1.0 §2.11 line-ending
141
+ * normalization) — same DOM on every platform. */
142
+ TEST(WhitespaceShape, CrlfRunsPreserved) {
143
+ const char xml[] = "<r>\r\n <a/>\r\n</r>";
144
+ LeptrisDocument doc = leptris_parse_string(xml, std::strlen(xml), nullptr);
145
+ ASSERT_NE(doc, nullptr);
146
+ const ChildShape want[] = {
147
+ {(int)LEPTRIS_NODE_TYPE_TEXT, "\n "},
148
+ {(int)LEPTRIS_NODE_TYPE_ELEMENT, nullptr},
149
+ {(int)LEPTRIS_NODE_TYPE_TEXT, "\n"},
150
+ };
151
+ expect_child_shape(doc, want, 3);
152
+ leptris_document_free(doc);
153
+ }
@@ -993,12 +993,12 @@ TEST(Qt3Subset, FnForEachPair) {
993
993
  run_test_set("fn/for-each-pair.xml", {}, 6);
994
994
  }
995
995
  TEST(Qt3Subset, FnFoldLeft) {
996
- /* 009/016: node-typed fold accumulators/callback args must be
997
- * REAL nodes for path/identity shapes ($ctx//*[@id = ...],
998
- * $foundSoFar intersect $this) — the narrowed node-carrier
999
- * lever. */
1000
- run_test_set("fn/fold-left.xml", {}, 14, {},
1001
- {"fold-left-009", "fold-left-016"});
996
+ /* 009/016 ADOPTED (v1.9.315 carrier-by-pointer): node-typed fold
997
+ * accumulators/callback args are REAL nodes now — the \x03P
998
+ * pointer carrier preserves identity ($foundSoFar intersect
999
+ * $this dedups by node), fold results decode so $result/text()
1000
+ * steps, and keyword-named ctors (<div/>) parse. */
1001
+ run_test_set("fn/fold-left.xml", {}, 16, {});
1002
1002
  }
1003
1003
  TEST(Qt3Subset, FnFoldRight) {
1004
1004
  run_test_set("fn/fold-right.xml", {}, 15);
@@ -9,6 +9,10 @@
9
9
  #include <gtest/gtest.h>
10
10
  #include <string.h>
11
11
 
12
+ /* carrier-by-pointer (fold-left-009/016): synth members may carry a
13
+ * node pointer — decode for markup rendering. */
14
+ extern "C" void* xpath_carrier_node_of(const char* s);
15
+
12
16
  namespace {
13
17
 
14
18
  const char* kBooks =
@@ -23,11 +27,27 @@ std::string seq_string(LeptrisDocument doc, const char* query) {
23
27
  if (!r) { leptris_xquery_free(xq); return "(eval-failed)"; }
24
28
  std::string out;
25
29
  if (leptris_xpath_result_type(r) == LEPTRIS_XPATH_NODESET) {
26
- /* FLWOR sequences join space-separated (value-of rule). */
30
+ /* FLWOR sequences join space-separated (value-of rule).
31
+ * #181: materialized ctor ELEMENT members render as their
32
+ * serialized markup (the QT3 assert-xml contract); other
33
+ * members keep their string value. */
27
34
  size_t n = leptris_xpath_result_count(r);
28
35
  for (size_t i = 0; i < n; i++) {
29
- const char* v = leptris_xpath_result_node_value(r, i);
30
36
  if (i) out += ' ';
37
+ LeptrisElement el = leptris_xpath_result_get(r, i);
38
+ if (!el) {
39
+ const char* raw =
40
+ leptris_xpath_result_node_value(r, i);
41
+ if (raw && (unsigned char)raw[0] == 0x03 &&
42
+ raw[1] == 'P')
43
+ el = (LeptrisElement)xpath_carrier_node_of(raw);
44
+ }
45
+ if (el) {
46
+ char* s = leptris_element_serialize(el, NULL);
47
+ if (s) { out += s; leptris_free_string(s); }
48
+ continue;
49
+ }
50
+ const char* v = leptris_xpath_result_node_value(r, i);
31
51
  out += v ? v : "";
32
52
  }
33
53
  } else {
@@ -42,6 +62,58 @@ std::string seq_string(LeptrisDocument doc, const char* query) {
42
62
 
43
63
  } // namespace
44
64
 
65
+ // #181: element constructors yield REAL nodes — stable identity
66
+ // across references, fold callbacks, and axis steps (the
67
+ // fold-left-009/016 lever; ctors were serialized TEXT before).
68
+ TEST(XQueryNodeCtor, CtorSequenceHasStableIdentity) {
69
+ LeptrisDocument doc;
70
+ LeptrisStatus st = LEPTRIS_OK;
71
+ doc = leptris_parse_string(kBooks, strlen(kBooks), &st);
72
+ ASSERT_NE(doc, nullptr);
73
+ EXPECT_EQ(seq_string(doc,
74
+ "let $n := (<a/>, <b/>) "
75
+ "return count($n[. intersect $n[1]])"), "1");
76
+ leptris_document_free(doc);
77
+ }
78
+
79
+ /* REMAINDER (task #181 follow-ups, in priority order):
80
+ * 1. LET-PREDICATE STABILITY: $nodes[1] re-evaluates the ctor per
81
+ * reference — each indexing is a NEW node, so identity-based
82
+ * dedup over let-bound ctor sequences is impossible until the
83
+ * let binding is evaluated once (var cache seam).
84
+ * 2. TYPED PARAMS: function($f as node()*, ...) closures take a
85
+ * string argv path that loses member identity (xq_fn_thunk).
86
+ * 3. DESCENDANT AXIS: $h//p from a var-bound ctor node misses
87
+ * (descendant-or-self over materialized nodes). */
88
+
89
+ /* KNOWN REMAINDER (task #181 follow-up): user-function arguments
90
+ * ride the string argv channel (xq_fn_thunk); a node sequence
91
+ * bound through `declare function local:d($s as node()*)`
92
+ * collapses. Pointer-carrying argv was probed and falsified
93
+ * (P-ref UAF); the channel needs a node-identity encoding. */
94
+
95
+ TEST(XQueryNodeCtor, CtorNodeTakesAxisSteps) {
96
+ LeptrisDocument doc;
97
+ LeptrisStatus st = LEPTRIS_OK;
98
+ doc = leptris_parse_string(kBooks, strlen(kBooks), &st);
99
+ ASSERT_NE(doc, nullptr);
100
+ EXPECT_EQ(seq_string(doc,
101
+ "count(<x><b/><b/></x>/b)"), "2");
102
+ leptris_document_free(doc);
103
+ }
104
+
105
+ TEST(XQueryNodeCtor, DistinctCtorOccurrencesAreDistinctNodes) {
106
+ LeptrisDocument doc;
107
+ LeptrisStatus st = LEPTRIS_OK;
108
+ doc = leptris_parse_string(kBooks, strlen(kBooks), &st);
109
+ ASSERT_NE(doc, nullptr);
110
+ /* Two occurrences are two nodes; the same reference is itself. */
111
+ EXPECT_EQ(seq_string(doc,
112
+ "let $n := (<a/>, <b/>) "
113
+ "return ($n[1] is $n[1], $n[1] is $n[2])"), "true false");
114
+ leptris_document_free(doc);
115
+ }
116
+
45
117
  TEST(XQueryCore, PlainExpressionIsXPath) {
46
118
  LeptrisDocument doc = leptris_parse_string(kBooks, strlen(kBooks),
47
119
  nullptr);
@@ -205,6 +277,59 @@ TEST(XQueryCore, AbsEmptyAndDurationAggregates) {
205
277
  leptris_document_free(doc);
206
278
  }
207
279
 
280
+ /* fold-left-009/016: node IDENTITY survives the HOF callback
281
+ * carrier — $foundSoFar intersect $this dedups by node, not by
282
+ * serialized form, and the fold RESULT is the real node so path
283
+ * steps and text() resolve on it (the \x03P pointer carrier). */
284
+ TEST(XQueryCore, FoldLeftCarriesNodeIdentity) {
285
+ LeptrisDocument doc = leptris_parse_string("<r/>", 4, nullptr);
286
+ ASSERT_NE(doc, nullptr);
287
+ /* Distinct literal ctors are DISTINCT nodes (one evaluation per
288
+ * occurrence) — the fold keeps all six, first-occurrence order. */
289
+ EXPECT_EQ(seq_string(doc,
290
+ "fold-left((<a/>, <b/>, <c/>, <d/>, <a/>, <b/>), (), "
291
+ "function($f, $t){ if ($f intersect $t) then $f "
292
+ "else ($f, $t) })/local-name()"),
293
+ "a b c d a b");
294
+ /* The declared-function shape of fold-left-009: distinct
295
+ * -nodes-stable over a permutation, first-occurrence order. */
296
+ EXPECT_EQ(seq_string(doc,
297
+ "declare function local:dns($seq as node()*) { "
298
+ "fold-left($seq, (), function($f as node()*, "
299
+ "$t as node()) as node()* { "
300
+ "if ($f intersect $t) then $f else ($f, $t) }) }; "
301
+ "let $n := (<a/>, <b/>, <c/>, <d/>, <e/>, <f/>) "
302
+ "let $p := ($n[1], $n[2], $n[4], $n[1], $n[2], "
303
+ "$n[3], $n[2], $n[1]) "
304
+ "return local:dns($p)/local-name()"),
305
+ "a b d c");
306
+ leptris_document_free(doc);
307
+ }
308
+
309
+ /* fold-left-016: the interpreter narrows the context through id
310
+ * then class selectors; only the nested <p> matches both, so
311
+ * $result/text() is its text — the Goodbye <p> sits outside the
312
+ * narrowed node. */
313
+ TEST(XQueryCore, FoldLeftDynamicSelection) {
314
+ LeptrisDocument doc = leptris_parse_string("<r/>", 4, nullptr);
315
+ ASSERT_NE(doc, nullptr);
316
+ EXPECT_EQ(seq_string(doc,
317
+ "let $html := <html><body><div id=\"main\">"
318
+ "<p class=\"para\">Hello World!</p></div>"
319
+ "<p class=\"para\">Goodbye!</p></body></html> "
320
+ "let $css := <selectors><id>main</id>"
321
+ "<class>para</class></selectors>/* "
322
+ "let $interp := function($ctx, $sel) { "
323
+ "typeswitch($sel) "
324
+ "case $a as element(id) return $ctx//*[@id = $a/text()] "
325
+ "case $a as element(class) "
326
+ "return $ctx//*[@class = $a/text()] "
327
+ "default return () } "
328
+ "return fold-left($css, $html, $interp)/text()"),
329
+ "Hello World!");
330
+ leptris_document_free(doc);
331
+ }
332
+
208
333
  TEST(XQueryCore, DeclaredFoldRecursionAndCarriers) {
209
334
  /* The spec'd fold via a DECLARED recursive function: the
210
335
  * function-test parameter type must parse (its commas broke
@@ -874,7 +999,7 @@ TEST(XQueryCore, DocumentConstructorWithDirectContent) {
874
999
  * FLWOR bodies) keep their value form. */
875
1000
  EXPECT_EQ(seq_string(doc,
876
1001
  "string-join((string(document { <a/> }), <b>2</b>), '|')"),
877
- "|<b>2</b>");
1002
+ "|2");
878
1003
  leptris_document_free(doc);
879
1004
  }
880
1005
 
@@ -1407,8 +1532,12 @@ TEST(XQueryCtors, DirectPICommentCtors) {
1407
1532
  {"deep-equal(<?foo?>, <?foo ?>)", "true"},
1408
1533
  {"deep-equal(<!--x-->, <!--x-->)", "true"},
1409
1534
  {"deep-equal(<!--x-->, <!--y-->)", "false"},
1410
- {"<doc><?pi content?></doc>",
1411
- "<doc><?pi content?></doc>"},
1535
+ /* result_string is the string-value contract (#514): no
1536
+ * text under <doc> renders "". The PI child surviving the
1537
+ * <doc> materialization is probed by the axis count. */
1538
+ {"<doc><?pi content?></doc>", ""},
1539
+ {"count(<doc><?pi content?></doc>/processing-instruction())",
1540
+ "1"},
1412
1541
  };
1413
1542
  for (auto& c : cases) {
1414
1543
  LeptrisXQuery xq = leptris_xquery_parse(c.q, strlen(c.q));
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://raw.githubusercontent.com/microsoft/vcpkg/master/scripts/vcpkg.schema.json",
3
3
  "name": "leptris",
4
- "version": "1.9.313",
4
+ "version": "1.9.317",
5
5
  "description": "High-performance XML parser and XPath 1.0 engine in C (libleptris)",
6
6
  "homepage": "https://github.com/leptris/leptris",
7
7
  "license": "MIT",
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: leptris
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.313.0
4
+ version: 1.9.317.0
5
5
  platform: arm-linux
6
6
  authors:
7
7
  - Ribose Inc.
@@ -817,6 +817,7 @@ files:
817
817
  - vendor-src/libleptris/test/parser/test_large_documents.cpp
818
818
  - vendor-src/libleptris/test/parser/test_parser.cpp
819
819
  - vendor-src/libleptris/test/parser/test_simd_count.cpp
820
+ - vendor-src/libleptris/test/parser/test_whitespace_shape.cpp
820
821
  - vendor-src/libleptris/test/perf/test_perf.cpp
821
822
  - vendor-src/libleptris/test/perf/test_stress_high_doc_count.cpp
822
823
  - vendor-src/libleptris/test/rng/include-cases/bad-construct.rng