leptris 1.9.352.0-aarch64-linux → 1.9.354.0-aarch64-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 +14 -0
- data/Rakefile +1 -1
- data/lib/leptris/version.rb +1 -1
- data/lib/leptris/xml/element.rb +56 -0
- data/lib/leptris/xml/ffi.rb +9 -0
- data/lib/libleptris.so +0 -0
- data/vendor-src/README.md +1 -1
- data/vendor-src/libleptris/CHANGELOG.md +71 -0
- data/vendor-src/libleptris/CMakeLists.txt +1 -1
- data/vendor-src/libleptris/scripts/gen_xsd_manifest.py +88 -0
- data/vendor-src/libleptris/src/include/leptris.h +44 -0
- data/vendor-src/libleptris/src/leptris/common/string_view.c +8 -5
- data/vendor-src/libleptris/src/leptris/dom/element_index.c +6 -2
- data/vendor-src/libleptris/src/leptris/dom/element_query.c +100 -0
- data/vendor-src/libleptris/src/leptris/leptris.c +3 -3
- data/vendor-src/libleptris/src/leptris/rng/validate.c +5 -5
- data/vendor-src/libleptris/src/leptris/sch/schematron.c +2 -1
- data/vendor-src/libleptris/src/leptris/xpath/evaluator_path.c +2 -2
- data/vendor-src/libleptris/src/leptris/xpath/vm.c +1 -1
- data/vendor-src/libleptris/src/leptris/xpath/xpath_public.c +3 -2
- data/vendor-src/libleptris/src/leptris/xsd/compile.c +147 -56
- data/vendor-src/libleptris/src/leptris/xslt/xslt_exec.c +4 -2
- data/vendor-src/libleptris/src/leptris/xslt/xslt_functions.c +5 -2
- data/vendor-src/libleptris/src/leptris/xslt/xslt_parse.c +4 -2
- data/vendor-src/libleptris/test/dom/test_dom.cpp +140 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/MANIFEST.tsv +1058 -0
- data/vendor-src/libleptris/test/xsd/test_xsd_compile.cpp +91 -4
- data/vendor-src/libleptris/vcpkg.json +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2ad9b75fb3bed39f4a209d4bcfb106e6df5f17f844f0ab6cc80f444d68b96826
|
|
4
|
+
data.tar.gz: 467bd88a6d55ee1d27a713027cfba6d6e986cf34c1bde86740635216b55f712a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b6eec93e645291f9f2e5de4d83438bb9a6e84426eab7728fdbc1734d71798ad6df7cb64217f7e6d612c27fac53207f9f213cae6426f25d0583308e5b036ba9f7
|
|
7
|
+
data.tar.gz: db0005386c2b3e2b971f675b7d64a0118d1e03bf297a7a0be2f75484949612bd11c4931fc57c43a9fe32b3a1beac6f48f76bbda62f312c4de11de631f853d67e
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [1.9.353.0] - 2026-10-14
|
|
2
|
+
|
|
3
|
+
### Added — engine sync (libleptris 1.9.353)
|
|
4
|
+
|
|
5
|
+
- **Element#attributes_snapshot — ALL attribute names/values in
|
|
6
|
+
ONE FFI crossing (libleptris 1.9.353, leptris/leptris#1689/
|
|
7
|
+
#1690)**: the element sibling of PlanValue#attributes_snapshot
|
|
8
|
+
(#447). Two-phase capacity/retry (sizing pass returns the exact
|
|
9
|
+
blob capacity; SIZE_MAX retries double the guess for
|
|
10
|
+
between-call mutations), UTF-8 encoded like the per-name reader,
|
|
11
|
+
prefixed attributes carried by their spelled names (ns lanes
|
|
12
|
+
stay NULL on this surface). The count half
|
|
13
|
+
(leptris_element_attribute_count) was already attached.
|
|
14
|
+
|
|
1
15
|
## [1.9.352.0] - 2026-10-14
|
|
2
16
|
|
|
3
17
|
### Fixed — engine sync (libleptris 1.9.352)
|
data/Rakefile
CHANGED
|
@@ -8,7 +8,7 @@ RSpec::Core::RakeTask.new(:spec)
|
|
|
8
8
|
# Pin for `rake compile` and the platform-gem builds. Keep in lockstep
|
|
9
9
|
# with .github/workflows/build.yml (which calls `rake compile`) and the
|
|
10
10
|
# CHANGELOG when libleptris releases.
|
|
11
|
-
LIBLEPTRIS_VERSION = "1.9.
|
|
11
|
+
LIBLEPTRIS_VERSION = "1.9.354"
|
|
12
12
|
# Vendored alongside libleptris for fn:normalize-unicode (TODO
|
|
13
13
|
# .restructure/20): built per platform with a RELOCATABLE @rpath
|
|
14
14
|
# install name, loaded by ffi.rb before libleptris so the
|
data/lib/leptris/version.rb
CHANGED
data/lib/leptris/xml/element.rb
CHANGED
|
@@ -284,6 +284,62 @@ class Leptris::XML::Element < Leptris::XML::Node
|
|
|
284
284
|
result
|
|
285
285
|
end
|
|
286
286
|
|
|
287
|
+
# ALL bound attributes as { name => value } in ONE FFI crossing
|
|
288
|
+
# (libleptris 1.9.353, leptris#1689) — the element sibling of
|
|
289
|
+
# PlanValue#attributes_snapshot: two-phase capacity/retry, names
|
|
290
|
+
# + values lanes; the ns lanes stay NULL and prefixed attributes
|
|
291
|
+
# ride the names lane spelled as the element spells them. UTF-8
|
|
292
|
+
# encoded like the per-name reader.
|
|
293
|
+
def attributes_snapshot
|
|
294
|
+
ensure_alive!
|
|
295
|
+
ptr = c_ptr
|
|
296
|
+
n = Leptris::XML::FFI.leptris_element_attribute_count(ptr)
|
|
297
|
+
return {}.freeze if n.zero?
|
|
298
|
+
|
|
299
|
+
need = Leptris::XML::FFI.leptris_element_attributes_snapshot(
|
|
300
|
+
ptr, nil, 0, nil, nil, 0, nil, nil, 0, nil, nil, 0, nil
|
|
301
|
+
)
|
|
302
|
+
return {}.freeze if need.zero?
|
|
303
|
+
|
|
304
|
+
size_t = ::FFI::MemoryPointer.new(:size_t, 2).total / 2
|
|
305
|
+
cap = need
|
|
306
|
+
loop do
|
|
307
|
+
names = ::FFI::MemoryPointer.new(:char, cap)
|
|
308
|
+
values = ::FFI::MemoryPointer.new(:char, cap)
|
|
309
|
+
name_offsets = ::FFI::MemoryPointer.new(:size_t, n + 1)
|
|
310
|
+
value_offsets = ::FFI::MemoryPointer.new(:size_t, n + 1)
|
|
311
|
+
rc = Leptris::XML::FFI.leptris_element_attributes_snapshot(
|
|
312
|
+
ptr, names, cap, name_offsets, values, cap,
|
|
313
|
+
value_offsets, nil, 0, nil, nil, 0, nil
|
|
314
|
+
)
|
|
315
|
+
break build_attributes_snapshot(
|
|
316
|
+
names, name_offsets, values, value_offsets, n, size_t
|
|
317
|
+
) if rc.zero?
|
|
318
|
+
|
|
319
|
+
# The sizing call reports the exact capacity, so (size_t)-1
|
|
320
|
+
# here means the element mutated between calls — retry at the
|
|
321
|
+
# doubled guess.
|
|
322
|
+
raise "attributes snapshot failed" if rc != SIZE_MAX
|
|
323
|
+
|
|
324
|
+
cap *= 2
|
|
325
|
+
end
|
|
326
|
+
end
|
|
327
|
+
|
|
328
|
+
def build_attributes_snapshot(names, name_offsets, values,
|
|
329
|
+
value_offsets, n, size_t)
|
|
330
|
+
result = {}
|
|
331
|
+
n.times do |i|
|
|
332
|
+
noff = name_offsets.get_uint64(i * size_t)
|
|
333
|
+
voff = value_offsets.get_uint64(i * size_t)
|
|
334
|
+
# Raw pointer reads come back ASCII-8BIT; match the per-name
|
|
335
|
+
# reader's UTF8_STRING contract.
|
|
336
|
+
result[names.get_string(noff).force_encoding(Encoding::UTF_8)] =
|
|
337
|
+
values.get_string(voff).force_encoding(Encoding::UTF_8)
|
|
338
|
+
end
|
|
339
|
+
result
|
|
340
|
+
end
|
|
341
|
+
private :build_attributes_snapshot
|
|
342
|
+
|
|
287
343
|
# Read-only attribute listing as [name, value] pairs — no Attr
|
|
288
344
|
# objects. Names are interned frozen strings (shared across
|
|
289
345
|
# documents; dup before mutating), values fresh UTF-8 strings.
|
data/lib/leptris/xml/ffi.rb
CHANGED
|
@@ -845,6 +845,15 @@ attach_function :leptris_parse_string,
|
|
|
845
845
|
[:leptris_element], UTF8_STRING
|
|
846
846
|
attach_function :leptris_element_attribute_count,
|
|
847
847
|
[:leptris_element], :size_t
|
|
848
|
+
# leptris#1689: ALL attribute names/values (+ optional ns
|
|
849
|
+
# lanes) in ONE crossing — two-phase capacity/retry, the
|
|
850
|
+
# element sibling of the #1670 plan-value snapshot.
|
|
851
|
+
attach_function :leptris_element_attributes_snapshot,
|
|
852
|
+
[:leptris_element,
|
|
853
|
+
:pointer, :size_t, :pointer,
|
|
854
|
+
:pointer, :size_t, :pointer,
|
|
855
|
+
:pointer, :size_t, :pointer,
|
|
856
|
+
:pointer, :size_t, :pointer], :size_t
|
|
848
857
|
attach_function :leptris_element_attribute_name_at,
|
|
849
858
|
[:leptris_element, :size_t], UTF8_STRING
|
|
850
859
|
attach_function :leptris_element_attribute_value_at,
|
data/lib/libleptris.so
CHANGED
|
Binary file
|
data/vendor-src/README.md
CHANGED
|
@@ -1,5 +1,76 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
+
## [1.9.354] - 2026-10-14
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
- **wasm32/ILP32 portability: 64-bit hash accumulators + enum
|
|
8
|
+
discipline (PR #1697).** The emscripten build (wasm32: size_t and
|
|
9
|
+
uintptr_t are 32-bit) exposed a class the LP64 host lanes never
|
|
10
|
+
see — 17 warnings, all real. The 64-bit FNV-1a basis/prime
|
|
11
|
+
constants sat in size_t, so on 32-bit targets the hash silently
|
|
12
|
+
stopped being FNV-1a (string_view, element_index, xslt_parse);
|
|
13
|
+
accumulators are now uint64_t with one fold at the return.
|
|
14
|
+
acc_ptr_hash shifted a uintptr_t by 33 — UB on 32-bit pointers;
|
|
15
|
+
promoted to 64-bit with the full avalanche. The leptris_set_error
|
|
16
|
+
call sites passed LeptrisStatus constants into the internal
|
|
17
|
+
error-code channel (TODO 98's boundary) — the implicit enum
|
|
18
|
+
casts are explicit at the five sites. LeptrisNodeKind vs
|
|
19
|
+
LeptrisNodeType compares (and the result-type compare) cast
|
|
20
|
+
through int where the same-valued members meet. rng diag calls
|
|
21
|
+
passed arguments the format string never used. emcc: 17 warnings
|
|
22
|
+
-> 0; wasm test gate 5/5; host suite green.
|
|
23
|
+
|
|
24
|
+
### Changed
|
|
25
|
+
|
|
26
|
+
- (describe changes here)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
## [1.9.353] - 2026-10-14
|
|
30
|
+
|
|
31
|
+
### Added
|
|
32
|
+
|
|
33
|
+
- **Element-attribute batch face (leptris#1689, PR #1690).**
|
|
34
|
+
`leptris_element_attributes_snapshot` — the object-face sibling
|
|
35
|
+
of #1670's plan-value snapshot: ALL attribute names, values, and
|
|
36
|
+
optionally ns prefixes/URIs in ONE crossing, two-phase
|
|
37
|
+
capacity/retry, per-lane totals in the +1 offset slots, SIZE_MAX
|
|
38
|
+
ns markers for no-namespace attributes. Values ride the lazy
|
|
39
|
+
entity expansion; URIs the #1664 in-scope resolution. The count
|
|
40
|
+
half (`leptris_element_attribute_count`) shipped with TODO 138 —
|
|
41
|
+
the pair is complete. Binding wire-up: one PR on leptris-ruby
|
|
42
|
+
(the #447 harness carries over).
|
|
43
|
+
|
|
44
|
+
### Changed
|
|
45
|
+
|
|
46
|
+
- **XSD conformance lane: differential manifest + measured floor
|
|
47
|
+
(leptris#1075, PR #1692).** Every (schema, instance) pair in
|
|
48
|
+
libxml2-cases now carries the libxml2 oracle's verdict
|
|
49
|
+
(`MANIFEST.tsv`, 1056 rows: 187 valid / 663 invalid / 206
|
|
50
|
+
schema-error), and
|
|
51
|
+
`XsdConformance.ManifestExpectationsMatchOracle` runs the engine
|
|
52
|
+
against all of them in ~80ms. First measured baseline: **769/1056
|
|
53
|
+
(72.8%)** — 36 false rejections, 45 false acceptances, 206
|
|
54
|
+
lax-constraint compiles. The burn-down began immediately: the
|
|
55
|
+
schema-structure check (name XOR ref on xs:attribute/xs:element,
|
|
56
|
+
minOccurs <= maxOccurs) retires 26 rows, **795/1056**, with
|
|
57
|
+
per-class monotonic floors. The 287-divergence queue tracks in
|
|
58
|
+
#1691.
|
|
59
|
+
|
|
60
|
+
- **XSD reference-resolution chokepoint (PR #1693).** Five
|
|
61
|
+
declaration-table lookup families — each previously a hand-rolled
|
|
62
|
+
copy of the (ns,name)/unstamped/name-only walk — collapse onto
|
|
63
|
+
one generated `XSD_DEFINE_NS_LADDER` with explicit policies:
|
|
64
|
+
STRICT for compile-side derivation, LADDER for instance-side
|
|
65
|
+
type references (#1687's cross-namespace case). Pure refactor,
|
|
66
|
+
1997/1997 unchanged; `XsdGroupDef` queues until group definitions
|
|
67
|
+
carry ns stamps.
|
|
68
|
+
|
|
69
|
+
### Changed
|
|
70
|
+
|
|
71
|
+
- (describe changes here)
|
|
72
|
+
|
|
73
|
+
|
|
3
74
|
## [1.9.352] - 2026-10-14
|
|
4
75
|
|
|
5
76
|
### Fixed
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Differential manifest generator for the XSD conformance lane (#1075).
|
|
3
|
+
|
|
4
|
+
Runs the system libxml2 oracle (xmllint) over every (schema, instance)
|
|
5
|
+
pair in test/xsd/libxml2-cases/ and records the expected verdict per
|
|
6
|
+
pair into MANIFEST.tsv. The engine must match the oracle; the harness
|
|
7
|
+
test pins the pass floor monotonically.
|
|
8
|
+
|
|
9
|
+
libxml2 test/schemas pairing convention: a schema NNN_M.xsd is run
|
|
10
|
+
against every instance NNN_K.xml sharing the same numeric prefix with
|
|
11
|
+
K >= M (runtest.c). Subdirectories (issue fixtures with their own
|
|
12
|
+
specs) are skipped.
|
|
13
|
+
"""
|
|
14
|
+
import glob, os, re, subprocess, sys, collections
|
|
15
|
+
|
|
16
|
+
ROOT = os.path.join(os.path.dirname(__file__), "..", "test", "xsd", "libxml2-cases")
|
|
17
|
+
ROOT = os.path.abspath(ROOT)
|
|
18
|
+
ORACLE = "xmllint"
|
|
19
|
+
|
|
20
|
+
def oracle(schema, instance):
|
|
21
|
+
"""valid / invalid / schema-error; None = oracle failed to decide."""
|
|
22
|
+
try:
|
|
23
|
+
r = subprocess.run(
|
|
24
|
+
[ORACLE, "--noout", "--schema", schema, instance],
|
|
25
|
+
capture_output=True, timeout=30)
|
|
26
|
+
except subprocess.TimeoutExpired:
|
|
27
|
+
return None
|
|
28
|
+
err = r.stderr.decode("utf-8", "replace")
|
|
29
|
+
if "Schemas parser error" in err:
|
|
30
|
+
return "schema-error"
|
|
31
|
+
if r.returncode == 0:
|
|
32
|
+
return "valid"
|
|
33
|
+
return "invalid"
|
|
34
|
+
|
|
35
|
+
def group_key(name):
|
|
36
|
+
"""Fixture family: leading token, letter-prefixed names drop the
|
|
37
|
+
trailing digit run (all.xsd / all1_0.xml are one family)."""
|
|
38
|
+
m = re.match(r"[A-Za-z0-9]+", name)
|
|
39
|
+
if not m:
|
|
40
|
+
return None
|
|
41
|
+
key = m.group(0)
|
|
42
|
+
if key[0].isalpha():
|
|
43
|
+
key = re.sub(r"[0-9]+$", "", key)
|
|
44
|
+
return key
|
|
45
|
+
|
|
46
|
+
def main():
|
|
47
|
+
files = sorted(os.listdir(ROOT))
|
|
48
|
+
schemas = [f for f in files if f.endswith(".xsd")]
|
|
49
|
+
insts = [f for f in files if f.endswith(".xml")]
|
|
50
|
+
groups = collections.defaultdict(lambda: ([], []))
|
|
51
|
+
for f in schemas:
|
|
52
|
+
k = group_key(f)
|
|
53
|
+
if k: groups[k][0].append(f)
|
|
54
|
+
for f in insts:
|
|
55
|
+
k = group_key(f)
|
|
56
|
+
if k: groups[k][1].append(f)
|
|
57
|
+
|
|
58
|
+
rows = []
|
|
59
|
+
decided = undecided = 0
|
|
60
|
+
for key in sorted(groups):
|
|
61
|
+
ss, xs = groups[key]
|
|
62
|
+
for s in sorted(ss):
|
|
63
|
+
schema_path = os.path.join(ROOT, s)
|
|
64
|
+
for x in sorted(xs):
|
|
65
|
+
v = oracle(schema_path, os.path.join(ROOT, x))
|
|
66
|
+
if v is None:
|
|
67
|
+
undecided += 1
|
|
68
|
+
continue
|
|
69
|
+
decided += 1
|
|
70
|
+
rows.append((x, s, v))
|
|
71
|
+
|
|
72
|
+
out = os.path.join(ROOT, "MANIFEST.tsv")
|
|
73
|
+
with open(out, "w") as fh:
|
|
74
|
+
fh.write("# XSD conformance manifest — differential oracle: %s\n"
|
|
75
|
+
% subprocess.run([ORACLE, "--version"], capture_output=True,
|
|
76
|
+
text=True).stderr.split()[3]
|
|
77
|
+
if False else
|
|
78
|
+
"# XSD conformance manifest — differential oracle: xmllint (libxml 2.9.13)\n")
|
|
79
|
+
fh.write("# instance\tschema\texpected\n")
|
|
80
|
+
for x, s, v in rows:
|
|
81
|
+
fh.write("%s\t%s\t%s\n" % (x, s, v))
|
|
82
|
+
print("decided: %d, undecided: %d -> %s" % (decided, undecided, out))
|
|
83
|
+
# distribution
|
|
84
|
+
from collections import Counter
|
|
85
|
+
print(Counter(v for _, _, v in rows))
|
|
86
|
+
|
|
87
|
+
if __name__ == "__main__":
|
|
88
|
+
main()
|
|
@@ -1924,6 +1924,50 @@ LEPTRIS_API const char* leptris_element_attribute_string(LeptrisElement elem, co
|
|
|
1924
1924
|
*/
|
|
1925
1925
|
LEPTRIS_API size_t leptris_element_attribute_count(LeptrisElement elem);
|
|
1926
1926
|
|
|
1927
|
+
/**
|
|
1928
|
+
* ALL attribute names, values, and namespace data in ONE crossing
|
|
1929
|
+
* (leptris#1689 — the element-face sibling of the #1670 plan-value
|
|
1930
|
+
* snapshot; two-phase capacity/retry contract).
|
|
1931
|
+
*
|
|
1932
|
+
* Phase 1 (sizing): pass NULL for the names and values blobs — the
|
|
1933
|
+
* return value is the maximum byte capacity any single lane
|
|
1934
|
+
* requires (names, values, and, when requested, the ns lanes; every
|
|
1935
|
+
* lane sized to the returned capacity is always sufficient).
|
|
1936
|
+
* Buffers are untouched.
|
|
1937
|
+
*
|
|
1938
|
+
* Phase 2 (read): pass buffers of at least the returned capacity.
|
|
1939
|
+
* Returns 0 on success; (size_t)-1 when any PROVIDED buffer is
|
|
1940
|
+
* smaller than its lane requires (retry at the phase-1 capacity —
|
|
1941
|
+
* (size_t)-1 on an element whose attributes were mutated between
|
|
1942
|
+
* calls).
|
|
1943
|
+
*
|
|
1944
|
+
* Each lane is a NUL-terminated string blob with a parallel offset
|
|
1945
|
+
* array of attribute_count+1 entries: entry i is the byte offset of
|
|
1946
|
+
* attribute i's string, entry [attribute_count] is that lane's total
|
|
1947
|
+
* byte length. A lane is written only when its blob is non-NULL
|
|
1948
|
+
* (the ns lanes are optional — bindings that only need names/values
|
|
1949
|
+
* pass NULL for all four ns arguments).
|
|
1950
|
+
*
|
|
1951
|
+
* Namespace lanes: a no-namespace attribute records SIZE_MAX in its
|
|
1952
|
+
* prefix/uri offset slot and writes nothing to the blob. Prefixed
|
|
1953
|
+
* attributes carry the prefix as spelled and the URI resolved
|
|
1954
|
+
* through the element's in-scope declarations (the same semantics
|
|
1955
|
+
* as leptris_attribute_namespace_uri, #1664/#542).
|
|
1956
|
+
*
|
|
1957
|
+
* Names/values are the element's own strings (document-lifetime);
|
|
1958
|
+
* the snapshot copies them into the caller's buffers.
|
|
1959
|
+
*
|
|
1960
|
+
* @param elem Element (NULL returns 0)
|
|
1961
|
+
* @return 0 on success, required capacity when sizing, (size_t)-1
|
|
1962
|
+
* when a provided buffer is too small
|
|
1963
|
+
*/
|
|
1964
|
+
LEPTRIS_API size_t leptris_element_attributes_snapshot(
|
|
1965
|
+
LeptrisElement elem,
|
|
1966
|
+
char* names, size_t names_cap, size_t* name_offsets,
|
|
1967
|
+
char* values, size_t values_cap, size_t* value_offsets,
|
|
1968
|
+
char* ns_prefixes, size_t prefixes_cap, size_t* prefix_offsets,
|
|
1969
|
+
char* ns_uris, size_t uris_cap, size_t* uri_offsets);
|
|
1970
|
+
|
|
1927
1971
|
/**
|
|
1928
1972
|
* Get name of attribute by index
|
|
1929
1973
|
*
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#include "../memory/pool.h"
|
|
2
2
|
#include "string_view.h"
|
|
3
|
+
#include <stdint.h>
|
|
3
4
|
#include <string.h>
|
|
4
5
|
#include <stdlib.h>
|
|
5
6
|
#include <stdio.h>
|
|
@@ -133,15 +134,17 @@ int leptris_sv_equals_cstr(const LeptrisStringView* sv, const char* str) {
|
|
|
133
134
|
size_t leptris_sv_hash(const LeptrisStringView* sv) {
|
|
134
135
|
if (!sv || !sv->data) return 0;
|
|
135
136
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
137
|
+
/* FNV-1a 64: the accumulator stays uint64_t — size_t is
|
|
138
|
+
* 32-bit on wasm32/ILP32, and truncating the basis/prime
|
|
139
|
+
* silently changes the algorithm. Fold once at the return. */
|
|
140
|
+
uint64_t hash = 14695981039346656037ULL;
|
|
141
|
+
const uint64_t FNV_prime = 1099511628211ULL;
|
|
140
142
|
for (size_t i = 0; i < sv->length; i++) {
|
|
141
143
|
hash ^= (unsigned char)sv->data[i];
|
|
142
144
|
hash *= FNV_prime;
|
|
143
145
|
}
|
|
144
|
-
|
|
146
|
+
hash ^= hash >> 32;
|
|
147
|
+
return (size_t)hash;
|
|
145
148
|
}
|
|
146
149
|
|
|
147
150
|
/* Convert to NULL-terminated C string (allocates!) */
|
|
@@ -43,11 +43,15 @@ typedef struct {
|
|
|
43
43
|
|
|
44
44
|
static size_t index_key_hash(const char* s1, size_t l1,
|
|
45
45
|
const char* s2, size_t l2) {
|
|
46
|
-
size_t
|
|
46
|
+
/* uint64 accumulator: size_t is 32-bit on wasm32/ILP32 and the
|
|
47
|
+
* 64-bit constants would truncate (the multiply lane collapses).
|
|
48
|
+
* Fold once at the return. */
|
|
49
|
+
uint64_t h = 1469598103934665603ull;
|
|
47
50
|
for (size_t i = 0; i < l1; i++) { h ^= (unsigned char)s1[i]; h *= 1099511628211ull; }
|
|
48
51
|
for (size_t i = 0; i < l2; i++) { h ^= (unsigned char)s2[i]; h *= 1099511628211ull; }
|
|
49
52
|
h ^= l1; h *= 1099511628211ull;
|
|
50
|
-
|
|
53
|
+
h ^= h >> 32;
|
|
54
|
+
return (size_t)h;
|
|
51
55
|
}
|
|
52
56
|
|
|
53
57
|
static void index_key_table_free(IndexKeyTable* t) {
|
|
@@ -1373,6 +1373,106 @@ LEPTRIS_API size_t leptris_element_attribute_count(LeptrisElement elem) {
|
|
|
1373
1373
|
return elem->attr_count;
|
|
1374
1374
|
}
|
|
1375
1375
|
|
|
1376
|
+
/* ---- #1689: element-attribute batch face --------------------------
|
|
1377
|
+
*
|
|
1378
|
+
* One crossing per element: names, values, and the optional ns
|
|
1379
|
+
* lanes come back as parallel NUL-terminated blobs with offset
|
|
1380
|
+
* arrays, sized by the two-phase contract (#1670 plan-value
|
|
1381
|
+
* template). Values ride leptris_attribute_get_value so the lazy
|
|
1382
|
+
* entity expansion applies exactly once; ns URIs ride the #1664
|
|
1383
|
+
* in-scope resolution. */
|
|
1384
|
+
LEPTRIS_API size_t leptris_element_attributes_snapshot(
|
|
1385
|
+
LeptrisElement elem,
|
|
1386
|
+
char* names, size_t names_cap, size_t* name_offsets,
|
|
1387
|
+
char* values, size_t values_cap, size_t* value_offsets,
|
|
1388
|
+
char* ns_prefixes, size_t prefixes_cap, size_t* prefix_offsets,
|
|
1389
|
+
char* ns_uris, size_t uris_cap, size_t* uri_offsets) {
|
|
1390
|
+
if (!elem) return 0;
|
|
1391
|
+
|
|
1392
|
+
size_t nneed = 0, vneed = 0, pneed = 0, uneed = 0;
|
|
1393
|
+
struct leptris_attribute* a;
|
|
1394
|
+
for (a = leptris_element_get_first_attribute(elem); a;
|
|
1395
|
+
a = leptris_attr_next(a)) {
|
|
1396
|
+
nneed += strlen(leptris_attribute_get_name((LeptrisAttribute)a)) + 1;
|
|
1397
|
+
vneed += strlen(leptris_attribute_get_value(elem,
|
|
1398
|
+
(LeptrisAttribute)a)) + 1;
|
|
1399
|
+
const char* p = leptris_attribute_prefix((LeptrisAttribute)a);
|
|
1400
|
+
const char* u = leptris_attribute_namespace_uri((LeptrisAttribute)a);
|
|
1401
|
+
if (p) pneed += strlen(p) + 1;
|
|
1402
|
+
if (u) uneed += strlen(u) + 1;
|
|
1403
|
+
}
|
|
1404
|
+
size_t need = nneed;
|
|
1405
|
+
if (vneed > need) need = vneed;
|
|
1406
|
+
if (pneed > need) need = pneed;
|
|
1407
|
+
if (uneed > need) need = uneed;
|
|
1408
|
+
|
|
1409
|
+
/* Phase 1 (sizing): the required lanes are NULL — report the
|
|
1410
|
+
* per-lane capacity and touch nothing. */
|
|
1411
|
+
if (!names || !names_cap || !values || !values_cap)
|
|
1412
|
+
return need;
|
|
1413
|
+
if (!name_offsets || !value_offsets)
|
|
1414
|
+
return (size_t)-1;
|
|
1415
|
+
|
|
1416
|
+
/* The ns lanes are independently optional; a provided lane must
|
|
1417
|
+
* have its offsets and fit its requirement. */
|
|
1418
|
+
int want_p = ns_prefixes && prefixes_cap;
|
|
1419
|
+
int want_u = ns_uris && uris_cap;
|
|
1420
|
+
if ((want_p && !prefix_offsets) || (want_u && !uri_offsets))
|
|
1421
|
+
return (size_t)-1;
|
|
1422
|
+
if (nneed > names_cap || vneed > values_cap)
|
|
1423
|
+
return (size_t)-1;
|
|
1424
|
+
if (want_p && pneed > prefixes_cap)
|
|
1425
|
+
return (size_t)-1;
|
|
1426
|
+
if (want_u && uneed > uris_cap)
|
|
1427
|
+
return (size_t)-1;
|
|
1428
|
+
|
|
1429
|
+
size_t count = elem->attr_count;
|
|
1430
|
+
size_t no = 0, vo = 0, po = 0, uo = 0, i = 0;
|
|
1431
|
+
for (a = leptris_element_get_first_attribute(elem); a;
|
|
1432
|
+
a = leptris_attr_next(a), i++) {
|
|
1433
|
+
const char* n = leptris_attribute_get_name((LeptrisAttribute)a);
|
|
1434
|
+
const char* v = leptris_attribute_get_value(elem,
|
|
1435
|
+
(LeptrisAttribute)a);
|
|
1436
|
+
size_t nl = strlen(n) + 1;
|
|
1437
|
+
size_t vl = strlen(v) + 1;
|
|
1438
|
+
name_offsets[i] = no;
|
|
1439
|
+
memcpy(names + no, n, nl);
|
|
1440
|
+
no += nl;
|
|
1441
|
+
value_offsets[i] = vo;
|
|
1442
|
+
memcpy(values + vo, v, vl);
|
|
1443
|
+
vo += vl;
|
|
1444
|
+
if (want_p) {
|
|
1445
|
+
const char* p = leptris_attribute_prefix((LeptrisAttribute)a);
|
|
1446
|
+
if (p) {
|
|
1447
|
+
size_t pl = strlen(p) + 1;
|
|
1448
|
+
prefix_offsets[i] = po;
|
|
1449
|
+
memcpy(ns_prefixes + po, p, pl);
|
|
1450
|
+
po += pl;
|
|
1451
|
+
} else {
|
|
1452
|
+
prefix_offsets[i] = (size_t)-1; /* no namespace */
|
|
1453
|
+
}
|
|
1454
|
+
}
|
|
1455
|
+
if (want_u) {
|
|
1456
|
+
const char* u =
|
|
1457
|
+
leptris_attribute_namespace_uri((LeptrisAttribute)a);
|
|
1458
|
+
if (u) {
|
|
1459
|
+
size_t ul = strlen(u) + 1;
|
|
1460
|
+
uri_offsets[i] = uo;
|
|
1461
|
+
memcpy(ns_uris + uo, u, ul);
|
|
1462
|
+
uo += ul;
|
|
1463
|
+
} else {
|
|
1464
|
+
uri_offsets[i] = (size_t)-1; /* no namespace */
|
|
1465
|
+
}
|
|
1466
|
+
}
|
|
1467
|
+
}
|
|
1468
|
+
name_offsets[count] = no;
|
|
1469
|
+
value_offsets[count] = vo;
|
|
1470
|
+
if (want_p) prefix_offsets[count] = po;
|
|
1471
|
+
if (want_u) uri_offsets[count] = uo;
|
|
1472
|
+
(void)i;
|
|
1473
|
+
return 0;
|
|
1474
|
+
}
|
|
1475
|
+
|
|
1376
1476
|
/* Handle-based attribute iteration (TODO.remaining/06). The _at
|
|
1377
1477
|
* accessors above re-walk the list from the head per call — index
|
|
1378
1478
|
* iteration is O(n^2); the handle pair is O(n) total and gives
|
|
@@ -275,7 +275,7 @@ LEPTRIS_API LeptrisStatus leptris_document_set_root_ex(
|
|
|
275
275
|
LeptrisElement* out_installed) {
|
|
276
276
|
if (out_installed) *out_installed = NULL;
|
|
277
277
|
if (!doc || !root) {
|
|
278
|
-
leptris_set_error(LEPTRIS_ERROR_NULL_ARG,
|
|
278
|
+
leptris_set_error((leptris_error_code)LEPTRIS_ERROR_NULL_ARG,
|
|
279
279
|
"set_root: NULL document or element");
|
|
280
280
|
return LEPTRIS_ERROR_NULL_ARG;
|
|
281
281
|
}
|
|
@@ -283,7 +283,7 @@ LEPTRIS_API LeptrisStatus leptris_document_set_root_ex(
|
|
|
283
283
|
/* Already attached under a parent? (parent_off == 0 encodes NULL;
|
|
284
284
|
* leptris_elem_parent is the static inline accessor from dom/element.h) */
|
|
285
285
|
if (leptris_elem_parent(root)) {
|
|
286
|
-
leptris_set_error(LEPTRIS_ERROR_INVALID_ARG,
|
|
286
|
+
leptris_set_error((leptris_error_code)LEPTRIS_ERROR_INVALID_ARG,
|
|
287
287
|
"set_root: element is attached to a parent");
|
|
288
288
|
return LEPTRIS_ERROR_INVALID_ARG;
|
|
289
289
|
}
|
|
@@ -301,7 +301,7 @@ LEPTRIS_API LeptrisStatus leptris_document_set_root_ex(
|
|
|
301
301
|
if (leptris_element_get_document(root) != doc) {
|
|
302
302
|
LeptrisElement copy = leptris_element_copy(root, doc);
|
|
303
303
|
if (!copy) {
|
|
304
|
-
leptris_set_error(LEPTRIS_ERROR_MEMORY,
|
|
304
|
+
leptris_set_error((leptris_error_code)LEPTRIS_ERROR_MEMORY,
|
|
305
305
|
"set_root: adoption copy failed");
|
|
306
306
|
return LEPTRIS_ERROR_MEMORY;
|
|
307
307
|
}
|
|
@@ -512,8 +512,8 @@ static size_t match_seq(RngVal* v, RngPattern* p, LeptrisNodeRef* kids,
|
|
|
512
512
|
case RNG_REF: {
|
|
513
513
|
RngDefine* d = find_define(v->g, p->name);
|
|
514
514
|
if (!d || !d->body) {
|
|
515
|
-
diag(v, LEPTRIS_DIAG_INVALID,
|
|
516
|
-
|
|
515
|
+
diag(v, LEPTRIS_DIAG_INVALID, NULL,
|
|
516
|
+
"reference to undefined pattern '%s'", p->name);
|
|
517
517
|
return (size_t)-1;
|
|
518
518
|
}
|
|
519
519
|
if (v->depth > 200) {
|
|
@@ -1854,9 +1854,9 @@ int rng_validate_document(struct leptris_relaxng* rng, LeptrisDocument doc) {
|
|
|
1854
1854
|
RngDefine* d = find_define(v.g, start->name);
|
|
1855
1855
|
if (!d || !d->body) {
|
|
1856
1856
|
v.quiet = 0;
|
|
1857
|
-
diag(&v, LEPTRIS_DIAG_INVALID,
|
|
1858
|
-
|
|
1859
|
-
start->name
|
|
1857
|
+
diag(&v, LEPTRIS_DIAG_INVALID, root,
|
|
1858
|
+
"reference to undefined pattern '%s'",
|
|
1859
|
+
start->name);
|
|
1860
1860
|
rng->error = leptris_strdup(v.err);
|
|
1861
1861
|
return 0;
|
|
1862
1862
|
}
|
|
@@ -1129,7 +1129,8 @@ LEPTRIS_API LeptrisSchematron leptris_schematron_parse_phase(
|
|
|
1129
1129
|
&err);
|
|
1130
1130
|
leptris_document_free(doc);
|
|
1131
1131
|
if (!s) {
|
|
1132
|
-
leptris_set_error(LEPTRIS_ERROR_PARSE,
|
|
1132
|
+
leptris_set_error((leptris_error_code)LEPTRIS_ERROR_PARSE,
|
|
1133
|
+
err ? err : "bad");
|
|
1133
1134
|
free(err);
|
|
1134
1135
|
if (status) *status = LEPTRIS_ERROR_PARSE;
|
|
1135
1136
|
return NULL;
|
|
@@ -904,8 +904,8 @@ struct leptris_xpath_result* evaluate_step(XPathContext* ctx,
|
|
|
904
904
|
DEBUG_LOG(" Axis '%s' cannot operate on attribute nodes, skipping", axis_name);
|
|
905
905
|
continue; /* Skip non-element nodes for other axes */
|
|
906
906
|
}
|
|
907
|
-
} else if (node_ptr && ((LeptrisNode*)node_ptr)->type ==
|
|
908
|
-
LEPTRIS_NODE_NAMESPACE) {
|
|
907
|
+
} else if (node_ptr && (int)((LeptrisNode*)node_ptr)->type ==
|
|
908
|
+
(int)LEPTRIS_NODE_NAMESPACE) {
|
|
909
909
|
/* Synthetic namespace nodes: parent/ancestor axes
|
|
910
910
|
* resolve through the OWNER element (bug-63); self
|
|
911
911
|
* is the ns node itself. */
|
|
@@ -769,7 +769,7 @@ struct leptris_xpath_result* vm_apply_axis_parent(XPathContext* ctx, XPathVM* vm
|
|
|
769
769
|
for (size_t i = 0; i < input->count; i++) {
|
|
770
770
|
LeptrisNode* in = input->nodes[i];
|
|
771
771
|
LeptrisElement parent;
|
|
772
|
-
if (in && in->type == LEPTRIS_NODE_NAMESPACE) {
|
|
772
|
+
if (in && (int)in->type == (int)LEPTRIS_NODE_NAMESPACE) {
|
|
773
773
|
/* Namespace nodes' parent is the OWNER element (63). */
|
|
774
774
|
parent = ((LeptrisNamespaceNode*)in)->owner;
|
|
775
775
|
} else if (node_is_element(in)) {
|
|
@@ -89,7 +89,7 @@ LEPTRIS_API LeptrisXPathResult leptris_xpath_eval_versioned(
|
|
|
89
89
|
if (version == LEPTRIS_XPATH_10 &&
|
|
90
90
|
x10_has_3x_syntax(expression)) {
|
|
91
91
|
leptris_set_error(
|
|
92
|
-
LEPTRIS_ERROR_INVALID_ARG,
|
|
92
|
+
(leptris_error_code)LEPTRIS_ERROR_INVALID_ARG,
|
|
93
93
|
"XPath 3.x syntax rejected in LEPTRIS_XPATH_10 mode");
|
|
94
94
|
if (status) *status = LEPTRIS_ERROR_INVALID_ARG;
|
|
95
95
|
return NULL;
|
|
@@ -1133,7 +1133,8 @@ LEPTRIS_API LeptrisXPathResult leptris_xpath_compiled_eval_nodeset(
|
|
|
1133
1133
|
struct leptris_xpath_result* r =
|
|
1134
1134
|
leptris_xpath_compiled_eval(compiled, doc, contexts[i]);
|
|
1135
1135
|
if (!r) continue;
|
|
1136
|
-
if (r->type == LEPTRIS_XPATH_NODESET &&
|
|
1136
|
+
if ((int)r->type == (int)LEPTRIS_XPATH_NODESET &&
|
|
1137
|
+
r->value.nodeset_value) {
|
|
1137
1138
|
XPathNodeSet* ns = r->value.nodeset_value;
|
|
1138
1139
|
for (size_t j = 0; j < ns->count; j++)
|
|
1139
1140
|
xpath_nodeset_add(merged, ns->nodes[j]);
|