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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +30 -0
- data/Rakefile +1 -1
- data/lib/leptris/version.rb +1 -1
- data/lib/libleptris.so +0 -0
- data/vendor-src/README.md +1 -1
- data/vendor-src/libleptris/CHANGELOG.md +92 -0
- data/vendor-src/libleptris/CMakeLists.txt +1 -1
- data/vendor-src/libleptris/bindings/rust/descriptor/src/lib.rs +6 -0
- data/vendor-src/libleptris/bindings/rust/descriptor/tests/layout.rs +1 -0
- data/vendor-src/libleptris/cli/commands/xquery.c +25 -2
- data/vendor-src/libleptris/src/include/leptris/descriptor.h +8 -1
- data/vendor-src/libleptris/src/leptris/descriptor/plan.c +46 -5
- data/vendor-src/libleptris/src/leptris/leptris_internal.h +19 -0
- data/vendor-src/libleptris/src/leptris/xpath/evaluator.c +12 -0
- data/vendor-src/libleptris/src/leptris/xpath/evaluator_operators.c +276 -24
- data/vendor-src/libleptris/src/leptris/xpath/functions.c +35 -0
- data/vendor-src/libleptris/src/leptris/xpath/functions_ext31.c +158 -28
- data/vendor-src/libleptris/src/leptris/xpath/parser.c +48 -8
- data/vendor-src/libleptris/src/leptris/xpath/xpath_public.c +19 -0
- data/vendor-src/libleptris/src/leptris/xquery/xquery.c +16 -0
- data/vendor-src/libleptris/test/CMakeLists.txt +1 -0
- data/vendor-src/libleptris/test/abi/test_descriptor.cpp +141 -0
- data/vendor-src/libleptris/test/parser/test_whitespace_shape.cpp +153 -0
- data/vendor-src/libleptris/test/xquery/test_qt3.cpp +6 -6
- data/vendor-src/libleptris/test/xquery/test_xquery.cpp +134 -5
- data/vendor-src/libleptris/vcpkg.json +1 -1
- metadata +2 -1
|
@@ -144,6 +144,24 @@ void leptris_dur_format(double secs, char* buf, size_t cap) {
|
|
|
144
144
|
|
|
145
145
|
extern char* get_node_text(void* node);
|
|
146
146
|
|
|
147
|
+
/* functions_ext31.c — #691 source-document anchoring (#181 ctor docs). */
|
|
148
|
+
extern int xq_anchor_on_source(XPathContext* ctx,
|
|
149
|
+
struct leptris_document* anchored);
|
|
150
|
+
/* carrier-by-pointer decode (fold-left-009/016). */
|
|
151
|
+
extern void* xpath_carrier_node_of(const char* s);
|
|
152
|
+
|
|
153
|
+
/* #181: a materialized ctor node splices its MARKUP into a
|
|
154
|
+
* parent's serialized content — get_node_text would yield only its
|
|
155
|
+
* string value and the element would vanish. Non-element members
|
|
156
|
+
* keep the text fetch. Shared with the collect-items family
|
|
157
|
+
* (functions_ext31.c). */
|
|
158
|
+
char* ctor_member_markup(void* node) {
|
|
159
|
+
if (node && (int)XPATH_NODE_TYPE(node) ==
|
|
160
|
+
(int)LEPTRIS_NODE_TYPE_ELEMENT)
|
|
161
|
+
return leptris_element_serialize((LeptrisElement)node, NULL);
|
|
162
|
+
return get_node_text(node);
|
|
163
|
+
}
|
|
164
|
+
|
|
147
165
|
/* ============================================================================
|
|
148
166
|
* Operator Evaluation
|
|
149
167
|
* ============================================================================ */
|
|
@@ -775,6 +793,7 @@ static int op_relational_cmp(XPathOperatorType op, double a, double b) {
|
|
|
775
793
|
* `instance of` and XQuery typeswitch. */
|
|
776
794
|
int xpath_result_matches_type(struct leptris_xpath_result* v,
|
|
777
795
|
const char* base) {
|
|
796
|
+
extern const char* leptris_element_get_name(LeptrisElement e);
|
|
778
797
|
int is_string_ty = strcmp(base, "xs:string") == 0 ||
|
|
779
798
|
strcmp(base, "xs:anyURI") == 0 ||
|
|
780
799
|
strncmp(base, "xs:date", 7) == 0 ||
|
|
@@ -785,7 +804,9 @@ int xpath_result_matches_type(struct leptris_xpath_result* v,
|
|
|
785
804
|
strcmp(base, "node()") != 0 &&
|
|
786
805
|
strcmp(base, "item()") != 0 &&
|
|
787
806
|
strcmp(base, "element()") != 0 &&
|
|
807
|
+
strncmp(base, "element(", 8) != 0 &&
|
|
788
808
|
strcmp(base, "attribute()") != 0 &&
|
|
809
|
+
strncmp(base, "attribute(", 10) != 0 &&
|
|
789
810
|
strcmp(base, "text()") != 0 &&
|
|
790
811
|
strcmp(base, "comment()") != 0 &&
|
|
791
812
|
strcmp(base, "processing-instruction()") != 0;
|
|
@@ -809,6 +830,22 @@ int xpath_result_matches_type(struct leptris_xpath_result* v,
|
|
|
809
830
|
if (!(tag >= 0 && tag <= 7)) return 0;
|
|
810
831
|
} else if (strcmp(base, "element()") == 0) {
|
|
811
832
|
if (tag != (int)LEPTRIS_NODE_ELEMENT) return 0;
|
|
833
|
+
} else if (strncmp(base, "element(", 8) == 0) {
|
|
834
|
+
/* ElementTest with a NAME: element(id) matches
|
|
835
|
+
* local-name "id" (fold-left-016 selector arms);
|
|
836
|
+
* element(*) is any element. */
|
|
837
|
+
size_t bl = strlen(base);
|
|
838
|
+
if (tag != (int)LEPTRIS_NODE_ELEMENT || bl < 10 ||
|
|
839
|
+
base[bl - 1] != ')')
|
|
840
|
+
return 0;
|
|
841
|
+
if (!(bl == 11 && base[9] == '*')) {
|
|
842
|
+
const char* en =
|
|
843
|
+
leptris_element_get_name((LeptrisElement)n);
|
|
844
|
+
size_t nl = bl - 9;
|
|
845
|
+
if (!en || strlen(en) != nl ||
|
|
846
|
+
strncmp(en, base + 8, nl) != 0)
|
|
847
|
+
return 0;
|
|
848
|
+
}
|
|
812
849
|
} else if (strcmp(base, "attribute()") == 0) {
|
|
813
850
|
if (tag != (int)LEPTRIS_NODE_ATTRIBUTE) return 0;
|
|
814
851
|
} else if (strcmp(base, "text()") == 0) {
|
|
@@ -1132,6 +1169,15 @@ struct leptris_xpath_result* evaluate_operator(XPathContext* ctx,
|
|
|
1132
1169
|
item->value.nodeset_value->count > 1) {
|
|
1133
1170
|
XPathNodeSet* sq = item->value.nodeset_value;
|
|
1134
1171
|
for (size_t si = 0; si < sq->count; si++) {
|
|
1172
|
+
/* #181: element members pass through as
|
|
1173
|
+
* NODES (identity preserved into the output
|
|
1174
|
+
* sequence); a text wrap would leave only
|
|
1175
|
+
* their string value. */
|
|
1176
|
+
if ((int)XPATH_NODE_TYPE(sq->nodes[si]) ==
|
|
1177
|
+
(int)LEPTRIS_NODE_TYPE_ELEMENT) {
|
|
1178
|
+
xpath_nodeset_add(out, sq->nodes[si]);
|
|
1179
|
+
continue;
|
|
1180
|
+
}
|
|
1135
1181
|
char* piece = get_node_text(sq->nodes[si]);
|
|
1136
1182
|
XPathTextNode* tn =
|
|
1137
1183
|
synth_text(piece ? piece : "",
|
|
@@ -1186,6 +1232,27 @@ struct leptris_xpath_result* evaluate_operator(XPathContext* ctx,
|
|
|
1186
1232
|
ctx->variable_set, loop_var);
|
|
1187
1233
|
continue;
|
|
1188
1234
|
}
|
|
1235
|
+
/* #181: a single ELEMENT member passes through as a
|
|
1236
|
+
* NODE (identity into the output sequence) — the
|
|
1237
|
+
* string wrap would leave its string value. Order-by
|
|
1238
|
+
* keeps the wrap (the ObItem collector stores text
|
|
1239
|
+
* nodes). */
|
|
1240
|
+
if (item->type == XPATH_RESULT_NODESET &&
|
|
1241
|
+
item->value.nodeset_value &&
|
|
1242
|
+
item->value.nodeset_value->count == 1 && !n_obk &&
|
|
1243
|
+
(int)XPATH_NODE_TYPE(
|
|
1244
|
+
item->value.nodeset_value->nodes[0]) ==
|
|
1245
|
+
(int)LEPTRIS_NODE_TYPE_ELEMENT) {
|
|
1246
|
+
void* en = item->value.nodeset_value->nodes[0];
|
|
1247
|
+
xpath_result_free(item);
|
|
1248
|
+
xpath_nodeset_add(out, en);
|
|
1249
|
+
if (pos_var)
|
|
1250
|
+
xpath_variable_set_remove(
|
|
1251
|
+
ctx->variable_set, pos_var);
|
|
1252
|
+
xpath_variable_set_remove(
|
|
1253
|
+
ctx->variable_set, loop_var);
|
|
1254
|
+
continue;
|
|
1255
|
+
}
|
|
1189
1256
|
char* piece =
|
|
1190
1257
|
(ctx->xquery_spelling &&
|
|
1191
1258
|
item->type == XPATH_RESULT_NUMBER && !item->is_int)
|
|
@@ -1843,9 +1910,18 @@ struct leptris_xpath_result* evaluate_operator(XPathContext* ctx,
|
|
|
1843
1910
|
if (sv && sv[0] == '\x03' && sv[1] == 'M' &&
|
|
1844
1911
|
xpath_array_members_of(sv, &mem, &mn) && mn) {
|
|
1845
1912
|
for (size_t j = 0; j < mn; j++) {
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1913
|
+
/* carrier-by-pointer: element members
|
|
1914
|
+
* decode to their NODE (identity —
|
|
1915
|
+
* fold-left-009/016). */
|
|
1916
|
+
void* cn = xpath_carrier_node_of(mem[j]);
|
|
1917
|
+
if (cn) {
|
|
1918
|
+
xpath_nodeset_add(one,
|
|
1919
|
+
(LeptrisNode*)cn);
|
|
1920
|
+
} else {
|
|
1921
|
+
XPathTextNode* tn = synth_text(
|
|
1922
|
+
mem[j], strlen(mem[j]));
|
|
1923
|
+
if (tn) xpath_nodeset_add(one, tn);
|
|
1924
|
+
}
|
|
1849
1925
|
free(mem[j]);
|
|
1850
1926
|
}
|
|
1851
1927
|
free(mem);
|
|
@@ -1854,11 +1930,19 @@ struct leptris_xpath_result* evaluate_operator(XPathContext* ctx,
|
|
|
1854
1930
|
sv[1] == 'E') {
|
|
1855
1931
|
free(sv);
|
|
1856
1932
|
} else {
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1933
|
+
void* cn =
|
|
1934
|
+
xpath_carrier_node_of(sv ? sv : "");
|
|
1935
|
+
if (cn) {
|
|
1936
|
+
xpath_nodeset_add(one, (LeptrisNode*)cn);
|
|
1937
|
+
} else {
|
|
1938
|
+
XPathTextNode* tn =
|
|
1939
|
+
synth_text(sv ? sv : "",
|
|
1940
|
+
sv ? strlen(sv) : 0);
|
|
1941
|
+
free(sv);
|
|
1942
|
+
if (tn) xpath_nodeset_add(one, tn);
|
|
1943
|
+
sv = NULL;
|
|
1944
|
+
}
|
|
1945
|
+
if (sv) free(sv);
|
|
1862
1946
|
}
|
|
1863
1947
|
}
|
|
1864
1948
|
XPathVariable* ex = xpath_variable_set_get(
|
|
@@ -1999,11 +2083,26 @@ struct leptris_xpath_result* evaluate_operator(XPathContext* ctx,
|
|
|
1999
2083
|
XPathNodeSet* one = xpath_nodeset_new();
|
|
2000
2084
|
if (one) {
|
|
2001
2085
|
one->owns_synthetic_text = 1;
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2086
|
+
if (v->type == XPATH_RESULT_NODESET &&
|
|
2087
|
+
v->value.nodeset_value &&
|
|
2088
|
+
v->value.nodeset_value->count > 0) {
|
|
2089
|
+
/* Node operands bind AS NODES — the arm
|
|
2090
|
+
* body steps axes on them
|
|
2091
|
+
* (fold-left-016: $a/text()); a
|
|
2092
|
+
* string-value synth has no children. */
|
|
2093
|
+
for (size_t xi = 0;
|
|
2094
|
+
xi < v->value.nodeset_value->count;
|
|
2095
|
+
xi++)
|
|
2096
|
+
xpath_nodeset_add(
|
|
2097
|
+
one,
|
|
2098
|
+
v->value.nodeset_value->nodes[xi]);
|
|
2099
|
+
} else {
|
|
2100
|
+
const char* bindv =
|
|
2101
|
+
marked ? marked : (vs_ ? vs_ : "");
|
|
2102
|
+
XPathTextNode* tn = xpath_synth_text(
|
|
2103
|
+
bindv, strlen(bindv));
|
|
2104
|
+
if (tn) xpath_nodeset_add(one, tn);
|
|
2105
|
+
}
|
|
2007
2106
|
XPathVariable* var = xpath_variable_set_add(
|
|
2008
2107
|
vs, vn, XPATH_VAR_TYPE_NODE_SET);
|
|
2009
2108
|
if (var)
|
|
@@ -2127,7 +2226,7 @@ struct leptris_xpath_result* evaluate_operator(XPathContext* ctx,
|
|
|
2127
2226
|
if (!v) continue;
|
|
2128
2227
|
if (v->type == XPATH_RESULT_NODESET && v->value.nodeset_value) {
|
|
2129
2228
|
for (size_t m = 0; m < v->value.nodeset_value->count; m++) {
|
|
2130
|
-
char* t =
|
|
2229
|
+
char* t = ctor_member_markup(v->value.nodeset_value->nodes[m]);
|
|
2131
2230
|
if (!t) continue;
|
|
2132
2231
|
while (len + strlen(t) + 1 > cap) { cap *= 2; buf = (char*)realloc(buf, cap); if (!buf) return NULL; }
|
|
2133
2232
|
memcpy(buf + len, t, strlen(t));
|
|
@@ -2427,8 +2526,9 @@ struct leptris_xpath_result* evaluate_operator(XPathContext* ctx,
|
|
|
2427
2526
|
* (adjacent constructed items). */
|
|
2428
2527
|
for (size_t m = 0; m < v->value.nodeset_value->count;
|
|
2429
2528
|
m++) {
|
|
2430
|
-
char* t =
|
|
2431
|
-
|
|
2529
|
+
char* t =
|
|
2530
|
+
ctor_member_markup(
|
|
2531
|
+
v->value.nodeset_value->nodes[m]);
|
|
2432
2532
|
if (!t) continue;
|
|
2433
2533
|
for (const char* q = t; *q; q++) {
|
|
2434
2534
|
while (len + 8 > cap) { cap *= 2; buf = (char*)realloc(buf, cap); if (!buf) return NULL; }
|
|
@@ -2465,6 +2565,113 @@ struct leptris_xpath_result* evaluate_operator(XPathContext* ctx,
|
|
|
2465
2565
|
while (len + strlen(name) + 4 > cap) { cap *= 2; buf = (char*)realloc(buf, cap); if (!buf) return NULL; }
|
|
2466
2566
|
len += (size_t)snprintf(buf + len, cap - len, "</%s>", name);
|
|
2467
2567
|
}
|
|
2568
|
+
/* #181: node materialization — the ctor's serialized form
|
|
2569
|
+
* parses into a REAL document (the document{} / fn:doc
|
|
2570
|
+
* pattern above): the ctor yields its root ELEMENT node,
|
|
2571
|
+
* so identity (is / intersect), axis steps, and HOF
|
|
2572
|
+
* callbacks all see one stable node per evaluation. The
|
|
2573
|
+
* document is anchored in the context's owned chain —
|
|
2574
|
+
* results borrow the handle, exactly like document{}.
|
|
2575
|
+
* Non-markup or parser-rejected content keeps the string
|
|
2576
|
+
* spelling. */
|
|
2577
|
+
{
|
|
2578
|
+
/* #181 memo: reuse what THIS (AST occurrence, content)
|
|
2579
|
+
* already materialized. Without it, re-evaluation of a
|
|
2580
|
+
* bound ctor re-runs it per reference and each run
|
|
2581
|
+
* anchors a fresh document — through fold recursion that
|
|
2582
|
+
* reached 200GB. Same occurrence + same serialized form
|
|
2583
|
+
* = the same binding's node (stable identity); a new
|
|
2584
|
+
* serialized form (next loop iteration) is a new node. */
|
|
2585
|
+
for (size_t mi = 0; mi < ctx->n_ctor_cache; mi++)
|
|
2586
|
+
if (ctx->ctor_cache[mi].ast == (void*)ast &&
|
|
2587
|
+
strcmp(ctx->ctor_cache[mi].key, buf) == 0) {
|
|
2588
|
+
XPathNodeSet* mns = xpath_nodeset_new();
|
|
2589
|
+
struct leptris_xpath_result* mr =
|
|
2590
|
+
mns ? xpath_result_new(XPATH_RESULT_NODESET)
|
|
2591
|
+
: NULL;
|
|
2592
|
+
if (mr) {
|
|
2593
|
+
mr->value.nodeset_value = mns;
|
|
2594
|
+
xpath_nodeset_add(
|
|
2595
|
+
mns, (LeptrisNode*)ctx->ctor_cache[mi].root);
|
|
2596
|
+
free(buf);
|
|
2597
|
+
return mr;
|
|
2598
|
+
}
|
|
2599
|
+
if (mns) xpath_nodeset_free(mns);
|
|
2600
|
+
break;
|
|
2601
|
+
}
|
|
2602
|
+
size_t blen = strlen(buf);
|
|
2603
|
+
LeptrisStatus pst = LEPTRIS_OK;
|
|
2604
|
+
LeptrisDocument pdoc =
|
|
2605
|
+
blen ? leptris_parse_string(buf, blen, &pst) : NULL;
|
|
2606
|
+
if (pdoc) {
|
|
2607
|
+
LeptrisElement root = leptris_document_root(pdoc);
|
|
2608
|
+
/* #181: anchor on the SOURCE document (the #691
|
|
2609
|
+
* discipline — fn:snapshot / analyze-string). The
|
|
2610
|
+
* ctx owned_docs chain dies at cleanup, BEFORE the
|
|
2611
|
+
* public eval returns, and FLWOR member capture
|
|
2612
|
+
* borrows ctor roots into the result sequence — the
|
|
2613
|
+
* materialized doc must outlive the result, so it
|
|
2614
|
+
* rides the source tree's anchored_docs chain
|
|
2615
|
+
* (released with the caller's document). */
|
|
2616
|
+
int anchored =
|
|
2617
|
+
root ? xq_anchor_on_source(ctx, pdoc) : -1;
|
|
2618
|
+
if (anchored == 0) {
|
|
2619
|
+
if (ctx->n_ctor_cache == ctx->cap_ctor_cache) {
|
|
2620
|
+
size_t nc = ctx->cap_ctor_cache
|
|
2621
|
+
? ctx->cap_ctor_cache * 2 : 8;
|
|
2622
|
+
XPathCtorCacheEntry* ne =
|
|
2623
|
+
(XPathCtorCacheEntry*)realloc(
|
|
2624
|
+
ctx->ctor_cache,
|
|
2625
|
+
nc * sizeof(XPathCtorCacheEntry));
|
|
2626
|
+
if (!ne) {
|
|
2627
|
+
/* No cache slot: the node is still
|
|
2628
|
+
* valid, just unmemoized. */
|
|
2629
|
+
XPathNodeSet* fns = xpath_nodeset_new();
|
|
2630
|
+
struct leptris_xpath_result* fout =
|
|
2631
|
+
fns ? xpath_result_new(
|
|
2632
|
+
XPATH_RESULT_NODESET)
|
|
2633
|
+
: NULL;
|
|
2634
|
+
if (fout) {
|
|
2635
|
+
fout->value.nodeset_value = fns;
|
|
2636
|
+
xpath_nodeset_add(fns, (LeptrisNode*)root);
|
|
2637
|
+
free(buf);
|
|
2638
|
+
return fout;
|
|
2639
|
+
}
|
|
2640
|
+
if (fns) xpath_nodeset_free(fns);
|
|
2641
|
+
} else {
|
|
2642
|
+
ctx->ctor_cache = ne;
|
|
2643
|
+
ctx->cap_ctor_cache = nc;
|
|
2644
|
+
}
|
|
2645
|
+
}
|
|
2646
|
+
if (ctx->n_ctor_cache < ctx->cap_ctor_cache) {
|
|
2647
|
+
char* nkey = leptris_strdup(buf);
|
|
2648
|
+
if (nkey) {
|
|
2649
|
+
ctx->ctor_cache[ctx->n_ctor_cache].ast =
|
|
2650
|
+
(void*)ast;
|
|
2651
|
+
ctx->ctor_cache[ctx->n_ctor_cache].key = nkey;
|
|
2652
|
+
ctx->ctor_cache[ctx->n_ctor_cache].doc = pdoc;
|
|
2653
|
+
ctx->ctor_cache[ctx->n_ctor_cache].root =
|
|
2654
|
+
(void*)root;
|
|
2655
|
+
ctx->n_ctor_cache++;
|
|
2656
|
+
}
|
|
2657
|
+
}
|
|
2658
|
+
XPathNodeSet* ns = xpath_nodeset_new();
|
|
2659
|
+
struct leptris_xpath_result* nout =
|
|
2660
|
+
ns ? xpath_result_new(XPATH_RESULT_NODESET)
|
|
2661
|
+
: NULL;
|
|
2662
|
+
if (nout) {
|
|
2663
|
+
nout->value.nodeset_value = ns;
|
|
2664
|
+
xpath_nodeset_add(ns, (LeptrisNode*)root);
|
|
2665
|
+
free(buf);
|
|
2666
|
+
return nout;
|
|
2667
|
+
}
|
|
2668
|
+
if (ns) xpath_nodeset_free(ns);
|
|
2669
|
+
return NULL;
|
|
2670
|
+
}
|
|
2671
|
+
if (!root) leptris_document_free(pdoc);
|
|
2672
|
+
/* anchor failure: the helper already freed pdoc */
|
|
2673
|
+
}
|
|
2674
|
+
}
|
|
2468
2675
|
struct leptris_xpath_result* out =
|
|
2469
2676
|
xpath_result_new(XPATH_RESULT_STRING);
|
|
2470
2677
|
if (!out) { free(buf); return NULL; }
|
|
@@ -2615,6 +2822,19 @@ struct leptris_xpath_result* evaluate_operator(XPathContext* ctx,
|
|
|
2615
2822
|
}
|
|
2616
2823
|
}
|
|
2617
2824
|
}
|
|
2825
|
+
/* Element values are REAL nodes now (#181): ride the
|
|
2826
|
+
* serialized MARKUP, not the string-value — otherwise
|
|
2827
|
+
* every <a>…</a> maps to its text ("23") and map
|
|
2828
|
+
* deep-equality cannot see attributes at all
|
|
2829
|
+
* (fn-deep-equal-maps-12). */
|
|
2830
|
+
if (!v && vr && vr->type == XPATH_RESULT_NODESET &&
|
|
2831
|
+
vr->value.nodeset_value &&
|
|
2832
|
+
vr->value.nodeset_value->count == 1 &&
|
|
2833
|
+
(int)XPATH_NODE_TYPE(vr->value.nodeset_value->nodes[0]) ==
|
|
2834
|
+
(int)LEPTRIS_NODE_TYPE_ELEMENT) {
|
|
2835
|
+
v = ctor_member_markup(
|
|
2836
|
+
vr->value.nodeset_value->nodes[0]);
|
|
2837
|
+
}
|
|
2618
2838
|
if (!v && vr) v = xpath_to_string(vr);
|
|
2619
2839
|
if (vr) xpath_result_free(vr);
|
|
2620
2840
|
size_t kn = k ? strlen(k) : 0, vn = v ? strlen(v) : 0;
|
|
@@ -4210,6 +4430,17 @@ struct leptris_xpath_result* xpath_call_function_item(
|
|
|
4210
4430
|
* typed/untyped carrier marks the M members
|
|
4211
4431
|
* now carry. */
|
|
4212
4432
|
const char* mv = mem[j];
|
|
4433
|
+
void* cn = xpath_carrier_node_of(mv);
|
|
4434
|
+
if (cn) {
|
|
4435
|
+
/* Node members atomize to their string
|
|
4436
|
+
* value (XDM function conversion). */
|
|
4437
|
+
const char* sv =
|
|
4438
|
+
leptris_element_text((LeptrisElement)cn);
|
|
4439
|
+
kids[j].value =
|
|
4440
|
+
(char*)(sv ? sv : "");
|
|
4441
|
+
karr[j] = &kids[j];
|
|
4442
|
+
continue;
|
|
4443
|
+
}
|
|
4213
4444
|
if (mv && mv[0] == '\x03' && mv[1] &&
|
|
4214
4445
|
mv[1] != 'A' && mv[1] != 'M')
|
|
4215
4446
|
mv += 2;
|
|
@@ -4241,8 +4472,16 @@ struct leptris_xpath_result* xpath_call_function_item(
|
|
|
4241
4472
|
else if (argv[i] && argv[i][0] == '\x03' &&
|
|
4242
4473
|
argv[i][1] == 'E')
|
|
4243
4474
|
argn[i].value = "";
|
|
4244
|
-
else
|
|
4245
|
-
|
|
4475
|
+
else {
|
|
4476
|
+
void* cn = xpath_carrier_node_of(argv[i]);
|
|
4477
|
+
if (cn) {
|
|
4478
|
+
const char* sv = leptris_element_text(
|
|
4479
|
+
(LeptrisElement)cn);
|
|
4480
|
+
argn[i].value = (char*)(sv ? sv : "");
|
|
4481
|
+
} else {
|
|
4482
|
+
argn[i].value = argv[i];
|
|
4483
|
+
}
|
|
4484
|
+
}
|
|
4246
4485
|
}
|
|
4247
4486
|
child_arr[i] = &argn[i];
|
|
4248
4487
|
}
|
|
@@ -4309,17 +4548,30 @@ struct leptris_xpath_result* xpath_call_function_item(
|
|
|
4309
4548
|
if (argv[ai][0] == '\x03' && argv[ai][1] == 'M' &&
|
|
4310
4549
|
xpath_array_members_of(argv[ai], &mem, &mn) && mn) {
|
|
4311
4550
|
for (size_t j = 0; j < mn; j++) {
|
|
4312
|
-
|
|
4313
|
-
|
|
4314
|
-
|
|
4551
|
+
/* carrier-by-pointer: element members decode to
|
|
4552
|
+
* their NODE (identity — fold-left-009/016);
|
|
4553
|
+
* borrowed, not synth. */
|
|
4554
|
+
void* cn = xpath_carrier_node_of(mem[j]);
|
|
4555
|
+
if (cn) {
|
|
4556
|
+
xpath_nodeset_add(one, (LeptrisNode*)cn);
|
|
4557
|
+
} else {
|
|
4558
|
+
XPathTextNode* tn =
|
|
4559
|
+
synth_text(mem[j], strlen(mem[j]));
|
|
4560
|
+
if (tn) xpath_nodeset_add(one, tn);
|
|
4561
|
+
}
|
|
4315
4562
|
free(mem[j]);
|
|
4316
4563
|
}
|
|
4317
4564
|
free(mem);
|
|
4318
4565
|
} else if (!(argv[ai][0] == '\x03' &&
|
|
4319
4566
|
argv[ai][1] == 'E')) {
|
|
4320
|
-
|
|
4321
|
-
|
|
4322
|
-
|
|
4567
|
+
void* cn = xpath_carrier_node_of(argv[ai]);
|
|
4568
|
+
if (cn) {
|
|
4569
|
+
xpath_nodeset_add(one, (LeptrisNode*)cn);
|
|
4570
|
+
} else {
|
|
4571
|
+
XPathTextNode* tn =
|
|
4572
|
+
synth_text(argv[ai], strlen(argv[ai]));
|
|
4573
|
+
if (tn) xpath_nodeset_add(one, tn);
|
|
4574
|
+
}
|
|
4323
4575
|
}
|
|
4324
4576
|
/* "\x03E": the empty sequence binds NO nodes, so
|
|
4325
4577
|
* empty($p) is true (fold zero accumulators). */
|
|
@@ -234,6 +234,8 @@ XPathFunctionDef* xpath_function_registry_get(
|
|
|
234
234
|
* This is declared in evaluator_internal.h and implemented in evaluator_types.c
|
|
235
235
|
*/
|
|
236
236
|
extern char* get_node_text(void* node);
|
|
237
|
+
/* evaluator_operators.c — element markup discipline (#181). */
|
|
238
|
+
extern char* ctor_member_markup(void* node);
|
|
237
239
|
extern char* xpath_number_to_string(double number);
|
|
238
240
|
extern char* xpath_int_to_string(long long v);
|
|
239
241
|
|
|
@@ -1118,6 +1120,26 @@ static size_t de_collect(struct leptris_xpath_result* r, DeItem* out,
|
|
|
1118
1120
|
if (c[0] == '\x03' && c[1] == 'B') {
|
|
1119
1121
|
out[i].kind = 3;
|
|
1120
1122
|
out[i].num = c[2] == 't' ? 1 : 0;
|
|
1123
|
+
} else if (c[0] == '\x03' && c[1] == 'P') {
|
|
1124
|
+
/* carrier-by-pointer: decode to the NODE's
|
|
1125
|
+
* MARKUP so both sides compare as markup
|
|
1126
|
+
* strings (real elements collect as markup in
|
|
1127
|
+
* the element branch below); the markup compare
|
|
1128
|
+
* reparses into de_node_equal. */
|
|
1129
|
+
extern void* xpath_carrier_node_of(const char*);
|
|
1130
|
+
extern char* ctor_member_markup(void* node);
|
|
1131
|
+
void* cn = xpath_carrier_node_of(c);
|
|
1132
|
+
if (cn) {
|
|
1133
|
+
out[i].kind = 2;
|
|
1134
|
+
out[i].str = ctor_member_markup(cn);
|
|
1135
|
+
if (!out[i].str) {
|
|
1136
|
+
out[i].kind = 0;
|
|
1137
|
+
out[i].node = cn;
|
|
1138
|
+
}
|
|
1139
|
+
} else {
|
|
1140
|
+
out[i].kind = 2;
|
|
1141
|
+
out[i].borrow = c;
|
|
1142
|
+
}
|
|
1121
1143
|
} else if (c[0] == '\x03' && c[1] == 'A') {
|
|
1122
1144
|
/* attribute ctor carrier: kind 4 compares
|
|
1123
1145
|
* name + value (K2-SeqDeepEqualFunc-25/31/32) */
|
|
@@ -1140,6 +1162,19 @@ static size_t de_collect(struct leptris_xpath_result* r, DeItem* out,
|
|
|
1140
1162
|
out[i].kind = 2;
|
|
1141
1163
|
out[i].borrow = leptris_text_get_content(
|
|
1142
1164
|
(LeptrisTextNode*)ns->nodes[i]);
|
|
1165
|
+
} else if (ty == LEPTRIS_NODE_TYPE_ELEMENT) {
|
|
1166
|
+
/* #181: ctor elements are real nodes now. Collect as
|
|
1167
|
+
* MARKUP so a constructed element compares against
|
|
1168
|
+
* the markup-string member every sequence function
|
|
1169
|
+
* emits (fn:reverse output) — de_markup_equal_n
|
|
1170
|
+
* reparses both sides into de_node_equal, so this is
|
|
1171
|
+
* the same compare, order-insensitive attrs and all. */
|
|
1172
|
+
out[i].kind = 2;
|
|
1173
|
+
out[i].str = ctor_member_markup(ns->nodes[i]);
|
|
1174
|
+
if (!out[i].str) {
|
|
1175
|
+
out[i].kind = 0;
|
|
1176
|
+
out[i].node = ns->nodes[i];
|
|
1177
|
+
}
|
|
1143
1178
|
} else {
|
|
1144
1179
|
out[i].kind = 0;
|
|
1145
1180
|
out[i].node = ns->nodes[i];
|