leptris 1.9.401.0 → 1.9.403.0
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/Rakefile +1 -1
- data/lib/leptris/vendor/aarch64-linux/libleptris.so +0 -0
- data/lib/leptris/vendor/aarch64-linux-musl/libleptris.so +0 -0
- data/lib/leptris/vendor/arm-linux/libleptris.so +0 -0
- data/lib/leptris/vendor/arm-linux-musl/libleptris.so +0 -0
- data/lib/leptris/vendor/arm64-darwin/libleptris.dylib +0 -0
- data/lib/leptris/vendor/ppc64le-linux/libleptris.so +0 -0
- data/lib/leptris/vendor/s390x-linux-musl/libleptris.so +0 -0
- data/lib/leptris/vendor/x86_64-darwin/libleptris.dylib +0 -0
- data/lib/leptris/vendor/x86_64-linux/libleptris.so +0 -0
- data/lib/leptris/vendor/x86_64-linux-musl/libleptris.so +0 -0
- data/lib/leptris/version.rb +1 -1
- data/vendor-src/README.md +1 -1
- data/vendor-src/libleptris/CHANGELOG.md +43 -0
- data/vendor-src/libleptris/CMakeLists.txt +1 -1
- data/vendor-src/libleptris/src/leptris/rng/rng_regex.c +235 -41
- data/vendor-src/libleptris/src/leptris/xsd/compile.c +60 -7
- data/vendor-src/libleptris/src/leptris/xsd/datatypes.c +166 -4
- data/vendor-src/libleptris/src/leptris/xsd/validate.c +90 -14
- data/vendor-src/libleptris/src/leptris/xsd/xsd_internal.h +1 -1
- data/vendor-src/libleptris/test/xsd/test_xsd_compile.cpp +551 -0
- data/vendor-src/libleptris/vcpkg.json +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9ebfe2b30ce92337532b49a43280042b311479e6e86859b97bde9e9359ff0904
|
|
4
|
+
data.tar.gz: bf4fc28871fbb610089542182af8fb232e4d9fed7d8b31bc73cf40df26d29b4d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d431e17e7d8fbe1dfcd557876b11e7953f42ff00b77e9e384b92fd7e2fa27eb577b6d4c46c6f5e454dd5a069f828103f2ce5efef2569b06b34755152b1de899d
|
|
7
|
+
data.tar.gz: 88e75cd2106e5e68b9158bb543e82be5e8cb629f3760dcafcb90c9ec2c73e5e76b061600fd5fcbfb8ffbcace6ab19935f2bab86200bf5402160af5b2ddf3be70
|
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.403"
|
|
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
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
data/lib/leptris/version.rb
CHANGED
data/vendor-src/README.md
CHANGED
|
@@ -1,5 +1,48 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
+
## [1.9.403] - 2026-11-03
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
- temporal enumeration compares by value, not lexically (leptris-rs#27) (xsd)
|
|
8
|
+
- whiteSpace=collapse covers every non-string builtin (leptris-rs#29, elemZ002) (xsd)
|
|
9
|
+
- a nilled element must have empty content - the model is not applied (leptris-rs#26) (xsd)
|
|
10
|
+
- empty content satisfies a fixed value; -0 lexes for nonNegativeInteger (leptris-rs#25/#28) (xsd)
|
|
11
|
+
- subtraction root cause, XSD \w excludes '_', empty content model (leptris#1936 reF39/reZ002/p2) (rng,xsd)
|
|
12
|
+
- in-class builtin merge carries uni ranges and XML pins (leptris#1936 reZ003-006) (rng)
|
|
13
|
+
- {n,} unbounded, empty branches, and REP over nullable bodies (leptris#1936 reC57/reE10/reD3) (rng)
|
|
14
|
+
- regex-tail conformance - pattern disjunction, class grammar, empty content (leptris#1936 p16/reG) (xsd)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
## [1.9.402] - 2026-11-02
|
|
19
|
+
|
|
20
|
+
### Fixed
|
|
21
|
+
|
|
22
|
+
- **`\\w` is the complement of punctuation/separators/controls
|
|
23
|
+
(leptris#1936 reV family, 39 rows, PR #1948).** XSD Part 2
|
|
24
|
+
App. F defines wordChar as NOT in `\\p{P}\\p{Z}\\p{C}` —
|
|
25
|
+
Sm/Sc/No/Mn/Me are all word chars. The engine's `\\w` was
|
|
26
|
+
ASCII-only, so `\\W` accepted every non-ASCII letter, mark,
|
|
27
|
+
superscript, fraction slash and currency sign (reV6-43). A
|
|
28
|
+
`cat_neg` flag on the regex class node expresses the category
|
|
29
|
+
complement; `\\W` inherits through its negation. reV 42/42
|
|
30
|
+
oracle agreement against the real suite documents.
|
|
31
|
+
- **Global elements with inline anonymous types get their
|
|
32
|
+
declaration (leptris#1936 stE, 15 rows, PR #1948).** The
|
|
33
|
+
global-element capture required both `name` and `type`
|
|
34
|
+
attributes — a global element whose type is an inline
|
|
35
|
+
`<xs:simpleType>` child never produced a declaration, so the
|
|
36
|
+
element's `fixed` value constraint and the type both vanished
|
|
37
|
+
and every instance validated. The `nm`-only branch now records
|
|
38
|
+
`fixed` alongside the #1592 synthesized-slot type.
|
|
39
|
+
- **The element `fixed` VALUE constraint fires regardless of type
|
|
40
|
+
resolution (PR #1948).** The check sat after the type
|
|
41
|
+
resolution's anyType early-return and its `*text` guard let
|
|
42
|
+
empty content pass a non-empty fixed value.
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
3
46
|
## [1.9.401] - 2026-11-01
|
|
4
47
|
|
|
5
48
|
### Fixed
|
|
@@ -36,6 +36,8 @@ enum {
|
|
|
36
36
|
RRE_CAT,
|
|
37
37
|
RRE_ALT,
|
|
38
38
|
RRE_REP,
|
|
39
|
+
RRE_EMPTY, /* F.1 [2]: a branch of zero pieces matches only "" */
|
|
40
|
+
RRE_MINPOS, /* count-loop sentinel: iteration must consume */
|
|
39
41
|
};
|
|
40
42
|
|
|
41
43
|
typedef struct RreNode {
|
|
@@ -55,12 +57,11 @@ typedef struct RreNode {
|
|
|
55
57
|
* LEPTRIS_HAS_UTF8PROC (without it the escapes fail loudly). */
|
|
56
58
|
unsigned cat_set;
|
|
57
59
|
unsigned cat_mask;
|
|
58
|
-
/*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
|
|
63
|
-
unsigned cat_strict;
|
|
60
|
+
/* cat_neg (#1936 reV33-43): the class matches when the codepoint
|
|
61
|
+
* is NOT in the masked categories — XSD \w is defined as the
|
|
62
|
+
* complement of punctuation/separators/controls, not the union
|
|
63
|
+
* of letters (Sm/Sc/Sk are word chars per the suite). */
|
|
64
|
+
unsigned cat_neg;
|
|
64
65
|
/* XSD charClassSub: the bracketed subtrahend (moxml#464). The
|
|
65
66
|
* node is consulted at match time so its ranges, blocks and
|
|
66
67
|
* categories all subtract — the old byte-bitmap merge ignored
|
|
@@ -125,10 +126,40 @@ static void cls_add_builtin(RreNode* n, char c) {
|
|
|
125
126
|
}
|
|
126
127
|
break;
|
|
127
128
|
case 'w':
|
|
128
|
-
|
|
129
|
+
/* XSD 1.0 Part 2 App. F: wordChar is the COMPLEMENT of
|
|
130
|
+
* punctuation, separators and controls — Sm/Sc/No/Mn/
|
|
131
|
+
* Me are all word chars (the suite's reV rows: U+2044,
|
|
132
|
+
* U+20A0, U+00B2, U+20DD never match \W). The ASCII-only
|
|
133
|
+
* form made \W accept every non-ASCII non-punct char
|
|
134
|
+
* (#1936 reV family). '_' (Pc) is PUNCTUATION per the
|
|
135
|
+
* table's \p{P} exclusion — NOT a word char (reZ002:
|
|
136
|
+
* first_last fails [\w\-\.]+@.*; Perl's \w includes it,
|
|
137
|
+
* XSD's does not). */
|
|
129
138
|
for (int i = 'a'; i <= 'z'; i++) cls_add(n, (unsigned char)i);
|
|
130
139
|
for (int i = 'A'; i <= 'Z'; i++) cls_add(n, (unsigned char)i);
|
|
131
|
-
cls_add(n,
|
|
140
|
+
for (int i = '0'; i <= '9'; i++) cls_add(n, (unsigned char)i);
|
|
141
|
+
/* Pc rides the cat_mask below (the byte bitmap cannot
|
|
142
|
+
* express "excluded" once the complement negates) */
|
|
143
|
+
#if defined(LEPTRIS_HAS_UTF8PROC)
|
|
144
|
+
n->cat_set = 1;
|
|
145
|
+
n->cat_neg = 1;
|
|
146
|
+
n->cat_mask =
|
|
147
|
+
(1u << UTF8PROC_CATEGORY_PC) |
|
|
148
|
+
(1u << UTF8PROC_CATEGORY_PD) |
|
|
149
|
+
(1u << UTF8PROC_CATEGORY_PS) |
|
|
150
|
+
(1u << UTF8PROC_CATEGORY_PE) |
|
|
151
|
+
(1u << UTF8PROC_CATEGORY_PI) |
|
|
152
|
+
(1u << UTF8PROC_CATEGORY_PF) |
|
|
153
|
+
(1u << UTF8PROC_CATEGORY_PO) |
|
|
154
|
+
(1u << UTF8PROC_CATEGORY_ZL) |
|
|
155
|
+
(1u << UTF8PROC_CATEGORY_ZP) |
|
|
156
|
+
(1u << UTF8PROC_CATEGORY_ZS) |
|
|
157
|
+
(1u << UTF8PROC_CATEGORY_CC) |
|
|
158
|
+
(1u << UTF8PROC_CATEGORY_CF) |
|
|
159
|
+
(1u << UTF8PROC_CATEGORY_CN) |
|
|
160
|
+
(1u << UTF8PROC_CATEGORY_CO) |
|
|
161
|
+
(1u << UTF8PROC_CATEGORY_CS);
|
|
162
|
+
#endif
|
|
132
163
|
break;
|
|
133
164
|
case 's':
|
|
134
165
|
cls_add(n, ' ');
|
|
@@ -143,6 +174,13 @@ static void cls_add_builtin(RreNode* n, char c) {
|
|
|
143
174
|
for (int i = 'A'; i <= 'Z'; i++) cls_add(n, (unsigned char)i);
|
|
144
175
|
cls_add(n, '_');
|
|
145
176
|
cls_add(n, ':');
|
|
177
|
+
/* XML 1.0 lists U+212E ESTIMATE SIGN explicitly in the
|
|
178
|
+
* Letter production (So in modern tables) — reZ005v */
|
|
179
|
+
if (n->uni_n < 4) {
|
|
180
|
+
n->uni_lo[n->uni_n] = 0x212E;
|
|
181
|
+
n->uni_hi[n->uni_n] = 0x212E;
|
|
182
|
+
n->uni_n++;
|
|
183
|
+
}
|
|
146
184
|
#if defined(LEPTRIS_HAS_UTF8PROC)
|
|
147
185
|
/* letters above the bitmap: the old 0x80-0xFF blanket
|
|
148
186
|
* also accepted symbols like U+00D7 (moxml#464) */
|
|
@@ -165,6 +203,36 @@ static void cls_add_builtin(RreNode* n, char c) {
|
|
|
165
203
|
cls_add(n, ':');
|
|
166
204
|
cls_add(n, '.');
|
|
167
205
|
cls_add(n, '-');
|
|
206
|
+
/* XML 1.0 vintage pins: U+212E (BaseChar, reZ005v),
|
|
207
|
+
* U+06DD (CombiningChar: Mn in Unicode 3.1, demoted to
|
|
208
|
+
* Cf in 4.0.1 — reZ006v), and U+00B7/U+0387 (the
|
|
209
|
+
* Extender production's explicit Po members — reZ006v),
|
|
210
|
+
* the same vintage-demotion family as the \d legacy-Nd
|
|
211
|
+
* pin */
|
|
212
|
+
if (n->uni_n < 4) {
|
|
213
|
+
n->uni_lo[n->uni_n] = 0x212E;
|
|
214
|
+
n->uni_hi[n->uni_n] = 0x212E;
|
|
215
|
+
n->uni_n++;
|
|
216
|
+
}
|
|
217
|
+
if (n->uni_n < 4) {
|
|
218
|
+
n->uni_lo[n->uni_n] = 0x06DD;
|
|
219
|
+
n->uni_hi[n->uni_n] = 0x06DD;
|
|
220
|
+
n->uni_n++;
|
|
221
|
+
}
|
|
222
|
+
/* U+06DE: Mn in Unicode 3.1 -> So in 4.0.1 (reZ006v) */
|
|
223
|
+
if (n->uni_n < 4) {
|
|
224
|
+
n->uni_lo[n->uni_n] = 0x06DE;
|
|
225
|
+
n->uni_hi[n->uni_n] = 0x06DE;
|
|
226
|
+
n->uni_n++;
|
|
227
|
+
}
|
|
228
|
+
/* 0xB7 sits in the BYTE bitmap (uni ranges are only
|
|
229
|
+
* consulted above 0x100) */
|
|
230
|
+
cls_add(n, 0xB7);
|
|
231
|
+
if (n->uni_n < 4) {
|
|
232
|
+
n->uni_lo[n->uni_n] = 0x0387;
|
|
233
|
+
n->uni_hi[n->uni_n] = 0x0387;
|
|
234
|
+
n->uni_n++;
|
|
235
|
+
}
|
|
168
236
|
#if defined(LEPTRIS_HAS_UTF8PROC)
|
|
169
237
|
n->cat_set = 1;
|
|
170
238
|
n->cat_mask = (1u << UTF8PROC_CATEGORY_LU) |
|
|
@@ -175,7 +243,9 @@ static void cls_add_builtin(RreNode* n, char c) {
|
|
|
175
243
|
(1u << UTF8PROC_CATEGORY_NL) |
|
|
176
244
|
(1u << UTF8PROC_CATEGORY_ND) |
|
|
177
245
|
(1u << UTF8PROC_CATEGORY_MN) |
|
|
178
|
-
(1u << UTF8PROC_CATEGORY_MC)
|
|
246
|
+
(1u << UTF8PROC_CATEGORY_MC) |
|
|
247
|
+
(1u << UTF8PROC_CATEGORY_ME) |
|
|
248
|
+
(1u << UTF8PROC_CATEGORY_NO);
|
|
179
249
|
#else
|
|
180
250
|
for (int i = 0x80; i < 0x100; i++) cls_add(n, (unsigned char)i);
|
|
181
251
|
#endif
|
|
@@ -256,16 +326,23 @@ static int cls_has_cp(const RreNode* n, unsigned cp) {
|
|
|
256
326
|
int c = (n->cat_mask &
|
|
257
327
|
(1u << utf8proc_get_property((utf8proc_int32_t)cp)
|
|
258
328
|
->category)) != 0;
|
|
259
|
-
|
|
329
|
+
if (n->cat_neg) c = !c;
|
|
330
|
+
hit = hit || c;
|
|
260
331
|
}
|
|
261
332
|
#else
|
|
262
333
|
(void)0;
|
|
263
334
|
#endif
|
|
264
335
|
if (n->negm)
|
|
265
336
|
hit = hit || !cls_has_cp(n->negm, cp);
|
|
337
|
+
/* charClassSub [16] applies to the GROUP's set: the neg flip
|
|
338
|
+
* (negCharGroup) composes BEFORE the subtraction — for
|
|
339
|
+
* [^cde-[ag]] the complement is the minuend, so 'a'/'g' are
|
|
340
|
+
* excluded even though they sit outside the raw bitmap
|
|
341
|
+
* (RegexTest_430). */
|
|
342
|
+
if (n->neg) hit = !hit;
|
|
266
343
|
if (hit && n->subtract)
|
|
267
344
|
hit = !cls_has_cp(n->subtract, cp);
|
|
268
|
-
return
|
|
345
|
+
return hit;
|
|
269
346
|
}
|
|
270
347
|
|
|
271
348
|
/* Strict UTF-8 decode at s (text is well-formed UTF-8; malformed
|
|
@@ -551,8 +628,11 @@ static RreNode* parse_class(RreParser* ps) {
|
|
|
551
628
|
ps->p++;
|
|
552
629
|
}
|
|
553
630
|
int first = 1;
|
|
631
|
+
int member_ord = 0;
|
|
554
632
|
while (*ps->p && (*ps->p != ']' || first)) {
|
|
555
633
|
first = 0;
|
|
634
|
+
int is_first_member = (member_ord == 0);
|
|
635
|
+
member_ord++;
|
|
556
636
|
if (*ps->p == '\\' && (ps->p[1] == 'p' || ps->p[1] == 'P') &&
|
|
557
637
|
ps->p[2] == '{') {
|
|
558
638
|
/* XSD property classes for the Latin-1 byte world —
|
|
@@ -646,49 +726,114 @@ static RreNode* parse_class(RreParser* ps) {
|
|
|
646
726
|
node_free(n);
|
|
647
727
|
return NULL;
|
|
648
728
|
}
|
|
649
|
-
cls_add_builtin
|
|
729
|
+
/* cls_add_builtin implements the LOWERCASE spellings;
|
|
730
|
+
* the uppercase forms negate via negm (reG21/reG23:
|
|
731
|
+
* [\D]+ must reject '1' — the old path passed 'D'
|
|
732
|
+
* raw, built an empty member set, and the complement
|
|
733
|
+
* memset accepted every byte). */
|
|
734
|
+
char pos = (char)((e >= 'A' && e <= 'Z')
|
|
735
|
+
? e - 'A' + 'a' : e);
|
|
736
|
+
cls_add_builtin(tmp, pos);
|
|
650
737
|
int neg_b = e == 'D' || e == 'W' || e == 'S' ||
|
|
651
738
|
e == 'I' || e == 'C';
|
|
739
|
+
if (neg_b) {
|
|
740
|
+
/* Negated built-in: the class gains the
|
|
741
|
+
* COMPLEMENT of the member — the negm slot
|
|
742
|
+
* (hit || !cls_has_cp(negm)) unions a flipped
|
|
743
|
+
* sub-class, codepoint-exact across bytes, uni
|
|
744
|
+
* ranges (the \d legacy-Nd pin stays excluded
|
|
745
|
+
* from \D) and categories (\W flips the \w
|
|
746
|
+
* complement form back to P|Z|C). A second
|
|
747
|
+
* negated member degrades to the positive
|
|
748
|
+
* spelling (single negm slot, as with \P). */
|
|
749
|
+
if (!n->negm) {
|
|
750
|
+
n->negm = tmp;
|
|
751
|
+
continue;
|
|
752
|
+
}
|
|
652
753
|
#if defined(LEPTRIS_HAS_UTF8PROC)
|
|
653
|
-
|
|
754
|
+
if (tmp->cat_set) {
|
|
755
|
+
n->cat_set = 1;
|
|
756
|
+
n->cat_mask |= tmp->cat_mask;
|
|
757
|
+
}
|
|
758
|
+
#endif
|
|
759
|
+
for (int i = 0; i < 256; i++)
|
|
760
|
+
if ((tmp->cls[i >> 3] >> (i & 7)) & 1)
|
|
761
|
+
cls_add(n, (unsigned char)i);
|
|
762
|
+
node_free(tmp);
|
|
763
|
+
continue;
|
|
764
|
+
}
|
|
765
|
+
#if defined(LEPTRIS_HAS_UTF8PROC)
|
|
766
|
+
if (tmp->cat_set) {
|
|
654
767
|
n->cat_set = 1;
|
|
655
768
|
n->cat_mask |= tmp->cat_mask;
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
769
|
+
/* \w rides the COMPLEMENT form: the mask lists
|
|
770
|
+
* P|Z|C and the verdict negates (reZ003-006:
|
|
771
|
+
* [\w] accepts Sm/No/letters, rejects P/Z/C) */
|
|
772
|
+
if (tmp->cat_neg) n->cat_neg = 1;
|
|
660
773
|
}
|
|
661
774
|
#endif
|
|
775
|
+
/* the builtin's UNI ranges ride too — [\d] must keep
|
|
776
|
+
* the legacy-Nd pin U+1369-1371 (reZ004v) */
|
|
777
|
+
for (int i = 0; i < tmp->uni_n && n->uni_n < 4; i++) {
|
|
778
|
+
n->uni_lo[n->uni_n] = tmp->uni_lo[i];
|
|
779
|
+
n->uni_hi[n->uni_n] = tmp->uni_hi[i];
|
|
780
|
+
n->uni_n++;
|
|
781
|
+
}
|
|
662
782
|
for (int i = 0; i < 256; i++)
|
|
663
|
-
if ((
|
|
664
|
-
(neg_b ? 0 : 1))
|
|
783
|
+
if ((tmp->cls[i >> 3] >> (i & 7)) & 1)
|
|
665
784
|
cls_add(n, (unsigned char)i);
|
|
666
|
-
if (neg_b) {
|
|
667
|
-
/* Negated built-in: everything except the set. */
|
|
668
|
-
memset(n->cls, 0xff, sizeof(n->cls));
|
|
669
|
-
for (int i = 0; i < 256; i++)
|
|
670
|
-
if ((tmp->cls[i >> 3] >> (i & 7)) & 1)
|
|
671
|
-
n->cls[i >> 3] &=
|
|
672
|
-
(unsigned char)~(1u << (i & 7));
|
|
673
|
-
}
|
|
674
785
|
node_free(tmp);
|
|
675
786
|
continue;
|
|
676
787
|
}
|
|
677
788
|
/* XSD singleCharEsc covers the control escapes too
|
|
678
789
|
* (the OPC ST_ContentType pattern uses \t) —
|
|
679
|
-
* leptris-ruby#434.
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
790
|
+
* leptris-ruby#434. Greedy seRange [18]: a singleCharEsc
|
|
791
|
+
* may open a range ([\\-\\{^], reG17: range \..{ union
|
|
792
|
+
* ^) — the end must be a charOrEsc and NOT `\\`/`[` per
|
|
793
|
+
* the seRange bullets. */
|
|
794
|
+
{
|
|
795
|
+
unsigned scp = (e == 't') ? (unsigned)'\t'
|
|
796
|
+
: (e == 'n') ? (unsigned)'\n'
|
|
797
|
+
: (e == 'r') ? (unsigned)'\r'
|
|
798
|
+
: (unsigned char)e;
|
|
799
|
+
/* `-[` is charClassSub, not a range toward '[' (the
|
|
800
|
+
* subtraction branch fires at the member loop) */
|
|
801
|
+
if (*ps->p == '-' && ps->p[1] && ps->p[1] != ']' &&
|
|
802
|
+
ps->p[1] != '[') {
|
|
803
|
+
ps->p++;
|
|
804
|
+
int hi_esc = (*ps->p == '\\');
|
|
805
|
+
unsigned hi = 0;
|
|
806
|
+
if (!cls_read_cp(ps, &hi) || hi < scp ||
|
|
807
|
+
hi == 0x5B || (hi_esc && hi == 0x5C)) {
|
|
808
|
+
node_free(n);
|
|
809
|
+
ps->bad = 1;
|
|
810
|
+
return NULL;
|
|
811
|
+
}
|
|
812
|
+
if (scp < 0x100 && hi < 0x100) {
|
|
813
|
+
for (unsigned int i = scp; i <= hi; i++)
|
|
814
|
+
cls_add(n, (unsigned char)i);
|
|
815
|
+
} else if (n->uni_n < 4) {
|
|
816
|
+
n->uni_lo[n->uni_n] = scp;
|
|
817
|
+
n->uni_hi[n->uni_n] = hi;
|
|
818
|
+
n->uni_n++;
|
|
819
|
+
}
|
|
820
|
+
continue;
|
|
821
|
+
}
|
|
822
|
+
cls_add_cp(n, scp);
|
|
823
|
+
continue;
|
|
824
|
+
}
|
|
685
825
|
}
|
|
686
826
|
/* XSD charClassSub: `[ A - [ B ] ]` — the '-' followed by
|
|
687
827
|
* '[' subtracts the bracketed class (leptris-ruby#434, the
|
|
688
828
|
* OPC ST_ContentType shape). The subtraction is the last
|
|
689
829
|
* member of the class. */
|
|
690
830
|
if (*ps->p == '-' && ps->p[1] == '[') {
|
|
691
|
-
|
|
831
|
+
/* skip BOTH '-' and '[': parse_class expects to be
|
|
832
|
+
* entered past the opening bracket (the atom path does
|
|
833
|
+
* the same) — skipping only '-' parsed the subtrahend's
|
|
834
|
+
* '[' as a literal member and dropped a leading '^'
|
|
835
|
+
* (reF39: [a-z-[^a]] must be {a}) */
|
|
836
|
+
ps->p += 2;
|
|
692
837
|
RreNode* sub = parse_class(ps);
|
|
693
838
|
if (!sub) {
|
|
694
839
|
node_free(n);
|
|
@@ -710,10 +855,15 @@ static RreNode* parse_class(RreParser* ps) {
|
|
|
710
855
|
ps->bad = 1;
|
|
711
856
|
return NULL;
|
|
712
857
|
}
|
|
713
|
-
|
|
858
|
+
/* the same `-[` precedence: a single-char member followed
|
|
859
|
+
* by subtraction is charClassSub, not a range toward '[' */
|
|
860
|
+
if (*ps->p == '-' && ps->p[1] && ps->p[1] != ']' &&
|
|
861
|
+
ps->p[1] != '[') {
|
|
714
862
|
ps->p++;
|
|
863
|
+
int hi_esc = (*ps->p == '\\');
|
|
715
864
|
unsigned hi = 0;
|
|
716
|
-
if (!cls_read_cp(ps, &hi) || hi < lo
|
|
865
|
+
if (!cls_read_cp(ps, &hi) || hi < lo ||
|
|
866
|
+
hi == 0x5B || (hi_esc && hi == 0x5C)) {
|
|
717
867
|
node_free(n);
|
|
718
868
|
ps->bad = 1;
|
|
719
869
|
return NULL;
|
|
@@ -727,6 +877,15 @@ static RreNode* parse_class(RreParser* ps) {
|
|
|
727
877
|
n->uni_n++;
|
|
728
878
|
}
|
|
729
879
|
} else {
|
|
880
|
+
/* F.1 [17]/[22]: a standalone '-' is a member only at
|
|
881
|
+
* the BEGINNING or END of the group — after a completed
|
|
882
|
+
* member with a following non-']' char it is a grammar
|
|
883
|
+
* error (reG26-33/reH19: [a-c-1-4x-z-7-9], [a-a-x-x]) */
|
|
884
|
+
if (lo == '-' && !is_first_member && *ps->p != ']') {
|
|
885
|
+
node_free(n);
|
|
886
|
+
ps->bad = 1;
|
|
887
|
+
return NULL;
|
|
888
|
+
}
|
|
730
889
|
cls_add_cp(n, lo);
|
|
731
890
|
}
|
|
732
891
|
}
|
|
@@ -884,12 +1043,14 @@ static RreNode* parse_piece(RreParser* ps) {
|
|
|
884
1043
|
} else if (*ps->p == '{') {
|
|
885
1044
|
const char* q = ps->p + 1;
|
|
886
1045
|
int l = -1, h = -1;
|
|
1046
|
+
int saw_comma = 0;
|
|
887
1047
|
char* end = NULL;
|
|
888
1048
|
long v = strtol(q, &end, 10);
|
|
889
1049
|
if (end > q) {
|
|
890
1050
|
l = (int)v;
|
|
891
1051
|
q = end;
|
|
892
1052
|
if (*q == ',') {
|
|
1053
|
+
saw_comma = 1;
|
|
893
1054
|
q++;
|
|
894
1055
|
if (*q == '}') {
|
|
895
1056
|
h = -1;
|
|
@@ -903,8 +1064,11 @@ static RreNode* parse_piece(RreParser* ps) {
|
|
|
903
1064
|
}
|
|
904
1065
|
/* {n} with no comma is EXACT — h must be l, not the
|
|
905
1066
|
* -1 "unbounded" sentinel. The old code left h = -1,
|
|
906
|
-
* so [A-Z]{3} matched ABCD (open-ended {3,}).
|
|
907
|
-
|
|
1067
|
+
* so [A-Z]{3} matched ABCD (open-ended {3,}). {n,}
|
|
1068
|
+
* (comma seen) stays unbounded — the old exact-fix
|
|
1069
|
+
* checked *q != ',' AFTER the comma was consumed, so
|
|
1070
|
+
* a{2,} collapsed to {2,2} and never matched 'aaa'. */
|
|
1071
|
+
if (!saw_comma && h == -1) h = l;
|
|
908
1072
|
if (*q == '}' && l >= 0 && (h == -1 || h >= l)) {
|
|
909
1073
|
lo = l;
|
|
910
1074
|
hi = h;
|
|
@@ -925,6 +1089,12 @@ static RreNode* parse_piece(RreParser* ps) {
|
|
|
925
1089
|
}
|
|
926
1090
|
|
|
927
1091
|
static RreNode* parse_cat(RreParser* ps) {
|
|
1092
|
+
/* F.1 [2]: branch ::= piece* — ZERO pieces is a legal empty
|
|
1093
|
+
* branch matching only "" (reE10: the pattern "|" is valid). */
|
|
1094
|
+
if (!*ps->p || *ps->p == '|' || *ps->p == ')') {
|
|
1095
|
+
RreNode* e = node_new(RRE_EMPTY);
|
|
1096
|
+
return e;
|
|
1097
|
+
}
|
|
928
1098
|
RreNode* first = parse_piece(ps);
|
|
929
1099
|
if (!first) return NULL;
|
|
930
1100
|
if (!*ps->p || *ps->p == '|' || *ps->p == ')') return first;
|
|
@@ -980,6 +1150,16 @@ static const char* rre_run(const RreCont* k, const char* s) {
|
|
|
980
1150
|
static const char* rre_match(RreNode* n, const char* s,
|
|
981
1151
|
const RreCont* k) {
|
|
982
1152
|
switch (n->kind) {
|
|
1153
|
+
case RRE_EMPTY:
|
|
1154
|
+
return rre_run(k, s);
|
|
1155
|
+
case RRE_MINPOS: {
|
|
1156
|
+
/* the stored start of the iteration: an empty match is
|
|
1157
|
+
* rejected so the caller's ALT falls through to
|
|
1158
|
+
* alternatives that progress (reD3-6) */
|
|
1159
|
+
const char* iter_start = (const char*)n->l;
|
|
1160
|
+
if (s != iter_start) return rre_run(k, s);
|
|
1161
|
+
return NULL;
|
|
1162
|
+
}
|
|
983
1163
|
case RRE_END:
|
|
984
1164
|
return *s == 0 ? rre_run(k, s) : NULL;
|
|
985
1165
|
case RRE_CHAR:
|
|
@@ -1013,15 +1193,25 @@ static const char* rre_match(RreNode* n, const char* s,
|
|
|
1013
1193
|
}
|
|
1014
1194
|
case RRE_REP: {
|
|
1015
1195
|
/* Two passes: count the greedy maximum, then store the
|
|
1016
|
-
* end position of every prefix count in a heap array.
|
|
1196
|
+
* end position of every prefix count in a heap array.
|
|
1197
|
+
* Each counted iteration is pinned to CONSUME (the
|
|
1198
|
+
* RRE_MINPOS continuation): a nullable body whose first
|
|
1199
|
+
* alternative matches empty must not end the count
|
|
1200
|
+
* while later alternatives progress (reD3-6:
|
|
1201
|
+
* ((boy|(girl))...?)|(man|woman)... under 'woman1y'). */
|
|
1017
1202
|
size_t cap = n->hi < 0 ? 64 : (size_t)n->hi + 1;
|
|
1018
1203
|
const char** ends =
|
|
1019
1204
|
(const char**)malloc((cap + 1) * sizeof(*ends));
|
|
1020
1205
|
if (!ends) return NULL;
|
|
1206
|
+
RreNode minpos;
|
|
1207
|
+
memset(&minpos, 0, sizeof(minpos));
|
|
1208
|
+
minpos.kind = RRE_MINPOS;
|
|
1209
|
+
RreCont mk = {&minpos, NULL};
|
|
1021
1210
|
ends[0] = s;
|
|
1022
1211
|
size_t cnt = 0;
|
|
1023
1212
|
while (n->hi < 0 || (int)cnt < n->hi) {
|
|
1024
|
-
|
|
1213
|
+
minpos.l = (RreNode*)ends[cnt];
|
|
1214
|
+
const char* r = rre_match(n->l, ends[cnt], &mk);
|
|
1025
1215
|
if (!r || r == ends[cnt]) break;
|
|
1026
1216
|
if (cnt == cap) {
|
|
1027
1217
|
cap *= 2;
|
|
@@ -1048,7 +1238,11 @@ static const char* rre_match(RreNode* n, const char* s,
|
|
|
1048
1238
|
}
|
|
1049
1239
|
|
|
1050
1240
|
int rng_regex_supported(const char* pat) {
|
|
1051
|
-
if (!pat
|
|
1241
|
+
if (!pat) return 0;
|
|
1242
|
+
/* an EMPTY branch is a valid regExp (F.1 [1]: branch*) — it
|
|
1243
|
+
* matches only the empty string (reA1/reA7: pattern='' with
|
|
1244
|
+
* value='' [valid]; matches() implements the semantics) */
|
|
1245
|
+
if (!*pat) return 1;
|
|
1052
1246
|
RreParser ps;
|
|
1053
1247
|
ps.p = pat;
|
|
1054
1248
|
ps.depth = 0;
|