leptris 1.9.401.0-ppc64le-linux → 1.9.403.0-ppc64le-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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4f71ef13bcf7f5b618ca282cbbf6c6c2b15372e35d3338fbf316b0498edfe168
4
- data.tar.gz: 58c8d347cfc2705d559970d0c243e32484eacc754ad3d3d9d3a5b7d5d997f1d8
3
+ metadata.gz: 2c30c2597d3380f6a0de071629f4b7e9cfb77a82110466fc696bb994c3b1ed18
4
+ data.tar.gz: 81dfdce78ff0810b8753b88c4e0c42547204b3e3b6a8022f384f941e19c5f883
5
5
  SHA512:
6
- metadata.gz: e6873270b9be6339344cf1ffa544763f72e02417b75d8327e661e979fd48f7e223a93ad5266d02dc5ee1dd4e85634304e1619f8b53f91334537d4753aa1edecf
7
- data.tar.gz: 5deab639c5552aaa389e37a50fe4af577f754afaebb13e5211746195dbbf1144e6a4fc94b75a13bdeacdab1d62b7ce81c06d1410493b06644baa69cf703128c1
6
+ metadata.gz: 6ab807cf55b4bd6e7d94adf3a7de7b717cf5b0882bf054c2bc9769fda9ed33ff8bf40452552319e7805132b334079dc31ab9afaba55d7dbd2ba7dbb36164a11e
7
+ data.tar.gz: 8d30a71f94553066b645780cf527271399955be60f240e30b8839dd00a2cf9c68ee10d1d8d9572f13bbd371b56c209b7eb435cf42813f73545049ac5eb4f67dd
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.401"
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Leptris
4
- VERSION = "1.9.401.0"
4
+ VERSION = "1.9.403.0"
5
5
  end
data/lib/libleptris.so CHANGED
Binary file
data/vendor-src/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  Sources vendored in this gem (recompile rights; the ruby
2
2
  variant builds them at install via extconf.rb):
3
3
 
4
- - libleptris v1.9.401
4
+ - libleptris v1.9.403
5
5
  - utf8proc v2.11.0
6
6
 
7
7
  Rebuild by hand:
@@ -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
@@ -3,7 +3,7 @@
3
3
  cmake_minimum_required(VERSION 3.20)
4
4
 
5
5
  project(leptris
6
- VERSION 1.9.401
6
+ VERSION 1.9.403
7
7
  DESCRIPTION "Fast XML parser and XPath evaluator in pure C"
8
8
  LANGUAGES C CXX
9
9
  )
@@ -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
- /* cat_strict (moxml#464): a class-internal COMPLEMENT builtin
59
- * ([\I], [\D]) needs bitmap AND cats to agree — the normal
60
- * union can't express "not in the set" once the bitmap holds
61
- * the complement's high bytes (U+00AA is in ~ASCII-bits but
62
- * excluded by the category). */
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
- for (int i = '0'; i <= '9'; i++) cls_add(n, (unsigned char)i);
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
- hit = n->cat_strict ? (hit && c) : (hit || c);
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 n->neg ? !hit : hit;
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(tmp, e);
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
- if (!neg_b && tmp->cat_set) {
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
- } else if (neg_b && tmp->cat_set && !n->cat_set) {
657
- n->cat_set = 1;
658
- n->cat_strict = 1;
659
- n->cat_mask = (~tmp->cat_mask) & 0x7FFFFFFFu;
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 (((tmp->cls[i >> 3] >> (i & 7)) & 1) ==
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
- if (e == 't') { cls_add(n, '\t'); continue; }
681
- if (e == 'n') { cls_add(n, '\n'); continue; }
682
- if (e == 'r') { cls_add(n, '\r'); continue; }
683
- cls_add(n, (unsigned char)e);
684
- continue;
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
- ps->p++;
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
- if (*ps->p == '-' && ps->p[1] && ps->p[1] != ']') {
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
- if (*q != ',' && h == -1) h = l;
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
- const char* r = rre_match(n->l, ends[cnt], NULL);
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 || !*pat) return 0;
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;
@@ -455,9 +455,15 @@ static XsdSimple* xsd_capture_simple(LeptrisElement st) {
455
455
  if (!fl || (fu && strcmp(fu, XSD_NS) != 0)) continue;
456
456
  const char* val =
457
457
  leptris_element_attribute(fe, "value");
458
- if (strcmp(fl, "pattern") == 0)
459
- simple->pattern = xsd_strdup(val);
460
- else if (strcmp(fl, "enumeration") == 0) {
458
+ if (strcmp(fl, "pattern") == 0) {
459
+ XsdFacetValue* fv =
460
+ (XsdFacetValue*)calloc(1, sizeof(*fv));
461
+ if (fv) {
462
+ fv->text = xsd_strdup(val);
463
+ fv->next = simple->patterns;
464
+ simple->patterns = fv;
465
+ }
466
+ } else if (strcmp(fl, "enumeration") == 0) {
461
467
  XsdFacetValue* fv =
462
468
  (XsdFacetValue*)calloc(1, sizeof(*fv));
463
469
  if (fv) {
@@ -659,9 +665,17 @@ static int xsd_deriv_valid(struct leptris_xsd_schema* s,
659
665
  if (ok && t->length >= 0 && (long)n != t->length) ok = 0;
660
666
  if (ok && t->min_length >= 0 && (long)n < t->min_length) ok = 0;
661
667
  if (ok && t->max_length >= 0 && (long)n > t->max_length) ok = 0;
662
- /* pattern applies to the whole lexical */
663
- if (ok && t->pattern && !rng_regex_matches(t->pattern, v))
664
- ok = 0;
668
+ /* pattern applies to the whole lexical; several patterns are
669
+ * a disjunction (p16: same as [abc]+|[123]+) */
670
+ if (ok && t->patterns) {
671
+ int matched = 0;
672
+ for (XsdFacetValue* p = t->patterns; p; p = p->next)
673
+ if (rng_regex_matches(p->text, v)) {
674
+ matched = 1;
675
+ break;
676
+ }
677
+ if (!matched) ok = 0;
678
+ }
665
679
  return ok;
666
680
  }
667
681
  if (t->deriv == XSD_SIMPLE_UNION) {
@@ -709,6 +723,24 @@ static void xsd_set_error(struct leptris_xsd_schema* s, const char* msg) {
709
723
  }
710
724
  }
711
725
 
726
+ /* XSD Part 2 §4.3.4: every pattern facet value is a regular
727
+ * expression — an unsupported one is a schema error AT COMPILE
728
+ * time (reG26-33/reH19: the suite's schemaTest=invalid rows, e.g.
729
+ * the mid-dash [a-c-1-4x-z-7-9]). Walks the def chains so inline
730
+ * anonymous members are covered too. */
731
+ extern int rng_regex_supported(const char* pat);
732
+ static int xsd_patterns_supported(const XsdSimple* t, int depth) {
733
+ if (!t || depth > 32) return 1;
734
+ for (const XsdFacetValue* p = t->patterns; p; p = p->next)
735
+ if (!rng_regex_supported(p->text)) return 0;
736
+ if (!xsd_patterns_supported(t->base_def, depth + 1)) return 0;
737
+ if (!xsd_patterns_supported(t->item_def, depth + 1)) return 0;
738
+ for (size_t i = 0; i < t->member_def_count; i++)
739
+ if (!xsd_patterns_supported(t->member_defs[i], depth + 1))
740
+ return 0;
741
+ return 1;
742
+ }
743
+
712
744
  /* A top-level schema-language declaration component. */
713
745
  static int xsd_is_declaration(const char* local, const char* uri) {
714
746
  if (uri && strcmp(uri, XSD_NS) != 0) return 0;
@@ -2086,6 +2118,15 @@ static LeptrisXsdSchema xsd_compile_impl(const char* xsd_text,
2086
2118
  xsd_resolve_extension_bases(s);
2087
2119
  xsd_resolve_pending_attr_refs(s);
2088
2120
 
2121
+ for (const XsdSimple* t = s->simple_types; t; t = t->next)
2122
+ if (!xsd_patterns_supported(t, 0)) {
2123
+ xsd_set_error(s, "pattern facet is not a supported "
2124
+ "regular expression");
2125
+ if (status) *status = LEPTRIS_ERROR_PARSE;
2126
+ leptris_document_free(doc);
2127
+ return (LeptrisXsdSchema)s;
2128
+ }
2129
+
2089
2130
  leptris_document_free(doc);
2090
2131
  return s;
2091
2132
 
@@ -2462,6 +2503,12 @@ static void xsd_capture_root(struct leptris_xsd_schema* s,
2462
2503
  if (s->target_ns) d->ns = xsd_strdup(s->target_ns);
2463
2504
  if (has_inline)
2464
2505
  d->type = xsd_strdup(synth);
2506
+ /* #1936 (stE): the fixed VALUE constraint rides
2507
+ * the decl whatever the type shape — inline
2508
+ * anonymous types used to lose it entirely. */
2509
+ d->fixed = xsd_strdup(
2510
+ leptris_element_attribute((LeptrisElement)n,
2511
+ "fixed"));
2465
2512
  const char* sg = leptris_element_attribute(
2466
2513
  (LeptrisElement)n, "substitutionGroup");
2467
2514
  if (sg) {
@@ -2566,7 +2613,13 @@ static void xsd_free_simple_one(XsdSimple* t) {
2566
2613
  free(t->name);
2567
2614
  free(t->ns);
2568
2615
  free(t->base);
2569
- free(t->pattern);
2616
+ XsdFacetValue* pv = t->patterns;
2617
+ while (pv) {
2618
+ XsdFacetValue* pn = pv->next;
2619
+ free(pv->text);
2620
+ free(pv);
2621
+ pv = pn;
2622
+ }
2570
2623
  XsdFacetValue* fv = t->enum_values;
2571
2624
  while (fv) {
2572
2625
  XsdFacetValue* fn = fv->next;