yeptris 0.6.59.1-arm-linux-eabihf → 0.6.61.1-arm-linux-eabihf
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/ext/yeptris_native/version.h +2 -2
- data/lib/yeptris/3.4/native.so +0 -0
- data/lib/yeptris/ffi.rb +19 -0
- data/lib/yeptris/yaml.rb +71 -0
- data/lib/yeptris.rb +1 -1
- data/libyeptris.so +0 -0
- data/vendor/libyeptris/CMakeLists.txt +1 -1
- data/vendor/libyeptris/src/CMakeLists.txt +7 -0
- data/vendor/libyeptris/src/include/yeptris/emit.h +30 -2
- data/vendor/libyeptris/src/include/yeptris/parse.h +73 -0
- data/vendor/libyeptris/src/include/yeptris/resolve.h +8 -0
- data/vendor/libyeptris/src/include/yeptris/validate.h +222 -21
- data/vendor/libyeptris/src/include/yeptris/values.h +8 -2
- data/vendor/libyeptris/src/yeptris/cbor/cbor.h +10 -0
- data/vendor/libyeptris/src/yeptris/cbor/decode.c +5 -7
- data/vendor/libyeptris/src/yeptris/cbor/encode.c +9 -9
- data/vendor/libyeptris/src/yeptris/cbor/from_marshal.c +1 -1
- data/vendor/libyeptris/src/yeptris/common/error.h +2 -0
- data/vendor/libyeptris/src/yeptris/doc.h +20 -0
- data/vendor/libyeptris/src/yeptris/dom/dom.c +12 -1
- data/vendor/libyeptris/src/yeptris/dom/ytape.c +56 -7
- data/vendor/libyeptris/src/yeptris/emit/emit.c +93 -13
- data/vendor/libyeptris/src/yeptris/emit/writer.c +243 -652
- data/vendor/libyeptris/src/yeptris/emit/writer.h +25 -8
- data/vendor/libyeptris/src/yeptris/events/push.c +28 -3
- data/vendor/libyeptris/src/yeptris/events/values.c +46 -0
- data/vendor/libyeptris/src/yeptris/marshal/to_json.c +650 -0
- data/vendor/libyeptris/src/yeptris/parse/engine.c +611 -130
- data/vendor/libyeptris/src/yeptris/parse/engine.h +5 -0
- data/vendor/libyeptris/src/yeptris/parse/stream_iter.c +358 -0
- data/vendor/libyeptris/src/yeptris/parse.c +216 -44
- data/vendor/libyeptris/src/yeptris/resolve/compat11.c +3 -6
- data/vendor/libyeptris/src/yeptris/resolve/core12.c +11 -3
- data/vendor/libyeptris/src/yeptris/resolve/full12.c +201 -0
- data/vendor/libyeptris/src/yeptris/resolve/json12.c +12 -6
- data/vendor/libyeptris/src/yeptris/resolve/resolver.h +38 -0
- data/vendor/libyeptris/src/yeptris/resolve/tags.c +192 -0
- data/vendor/libyeptris/src/yeptris/scan/scan.c +22 -7
- data/vendor/libyeptris/src/yeptris/tape.c +24 -5
- data/vendor/libyeptris/src/yeptris/validate/compile.c +39 -3
- data/vendor/libyeptris/src/yeptris/validate/internal.h +223 -7
- data/vendor/libyeptris/src/yeptris/validate/jsonschema.c +645 -115
- data/vendor/libyeptris/src/yeptris/validate/output.c +246 -0
- data/vendor/libyeptris/src/yeptris/validate/regexp.c +623 -157
- data/vendor/libyeptris/src/yeptris/validate/registry.c +118 -0
- data/vendor/libyeptris/src/yeptris/validate/resources.c +601 -0
- data/vendor/libyeptris/src/yeptris/validate/stream.c +1155 -0
- data/vendor/libyeptris/src/yeptris/validate/validate.c +288 -145
- metadata +8 -1
|
@@ -6,17 +6,23 @@
|
|
|
6
6
|
* bool: true | false
|
|
7
7
|
* int: -? ( 0 | [1-9] [0-9]* )
|
|
8
8
|
* float: -? ( 0 | [1-9] [0-9]* ) ( \. [0-9]* )? ( [eE] [-+]? [0-9]+ )?
|
|
9
|
-
* * ->
|
|
9
|
+
* * -> str (see below: example 10.8 governs; the Error row does not)
|
|
10
10
|
*
|
|
11
11
|
* Deliberately NOT accepted (the core schema's extensions): "True"/
|
|
12
12
|
* "False"/"NULL" casings, "~"/empty nulls, +signs, 0o/0x radix, .inf/
|
|
13
13
|
* .nan, underscores. The example-10.8 Invalid list pins each one.
|
|
14
14
|
*
|
|
15
15
|
* Shape: yep_json12_plain is the ONE classifier — the resolver wraps
|
|
16
|
-
* it, and the validator re-asks it per plain scalar (no second
|
|
17
|
-
* table anywhere).
|
|
18
|
-
*
|
|
19
|
-
*
|
|
16
|
+
* it, and the validator re-asks it per plain scalar key (no second
|
|
17
|
+
* truth table anywhere). SPEC NOTE (the 10.2.2 contradiction): the
|
|
18
|
+
* table's `* -> Error` row says no-match plains "should be considered
|
|
19
|
+
* an error", but example 10.8 — the spec's own JSON Tag Resolution
|
|
20
|
+
* demonstration — resolves no-match plains as strings BOTH as keys
|
|
21
|
+
* ("A null", "Booleans") and as values (the "Invalid" list). Example
|
|
22
|
+
* 10.8 wins: a scalar outside the productions resolves str so the DOM
|
|
23
|
+
* stays family-neutral, and the validation face does NOT turn no-match
|
|
24
|
+
* plains into diagnostics; the family's teeth are the string-key
|
|
25
|
+
* demand (12_JSON) and explicit non-JSON tags.
|
|
20
26
|
*/
|
|
21
27
|
|
|
22
28
|
#include <stdint.h>
|
|
@@ -96,7 +102,7 @@ static yep_tag_id json12_number(void* ctx, int is_float) {
|
|
|
96
102
|
return is_float ? 2 : 1;
|
|
97
103
|
}
|
|
98
104
|
|
|
99
|
-
static const yep_resolver k_json12 = {json12, json12_number, NULL};
|
|
105
|
+
static const yep_resolver k_json12 = {json12, json12_number, NULL, 0};
|
|
100
106
|
|
|
101
107
|
const yep_resolver* yep_resolver_json12(void) {
|
|
102
108
|
return &k_json12;
|
|
@@ -25,6 +25,12 @@ typedef struct yep_resolver {
|
|
|
25
25
|
* skips the digit re-walk resolve() would pay. NULL = resolve(). */
|
|
26
26
|
yep_tag_id (*resolve_number)(void* ctx, int is_float);
|
|
27
27
|
void* ctx;
|
|
28
|
+
/* 1 when timestamp:yaml.org,2002 is IN the family's implicit set —
|
|
29
|
+
* the validator family-checks explicit !!timestamp content through
|
|
30
|
+
* resolve() (#906 slice 3). Core leaves it consumer-defined (the
|
|
31
|
+
* core schema has no timestamp, spec 10.3); 11_COMPAT is not a
|
|
32
|
+
* validation family; json12 rejects the tag wholesale. */
|
|
33
|
+
int timestamped;
|
|
28
34
|
} yep_resolver;
|
|
29
35
|
|
|
30
36
|
/* Typing for a validated number span, through whichever hook the
|
|
@@ -39,6 +45,9 @@ static inline yep_tag_id yep_resolve_number(const yep_resolver* r, int is_float)
|
|
|
39
45
|
/* The two built-in resolvers (no ctx). */
|
|
40
46
|
const yep_resolver* yep_resolver_core12(void);
|
|
41
47
|
const yep_resolver* yep_resolver_compat11(void);
|
|
48
|
+
/* The core schema's plain-scalar classifier (the core truth table):
|
|
49
|
+
* the resolver wraps it and the full family composes it. */
|
|
50
|
+
yep_tag_id yep_core12_plain(const char* p, uint32_t n);
|
|
42
51
|
|
|
43
52
|
/* The spec 10.2 JSON schema resolver (#882): null/true/false exact,
|
|
44
53
|
* the JSON int and float productions, everything else str. Parse stays
|
|
@@ -49,6 +58,17 @@ const yep_resolver* yep_resolver_json12(void);
|
|
|
49
58
|
* truth table for the 12_JSON family (validate/ re-asks it). */
|
|
50
59
|
int yep_json12_plain(const char* p, uint32_t n);
|
|
51
60
|
|
|
61
|
+
/* The FULL 1.2 family resolver (#906 slice 3): the core productions
|
|
62
|
+
* verbatim (spec 10.4: interoperable schemas are "strongly recommended
|
|
63
|
+
* ... based on the core schema") extended with the yaml.org type
|
|
64
|
+
* repository's carried-forward set — RFC3339-era timestamps on untagged
|
|
65
|
+
* plains (spec 2.22's canonical/iso8601/spaced/date forms; PyYAML's
|
|
66
|
+
* timestamp regex as the practice oracle) and the merge/value words.
|
|
67
|
+
* The 1.1 NUMERIC quirks (underscores, sexagesimal, leading-0 octal,
|
|
68
|
+
* y/n booleans) stay in compat11 — full is spec-refereed, not
|
|
69
|
+
* psych-refereed. */
|
|
70
|
+
const yep_resolver* yep_resolver_full12(void);
|
|
71
|
+
|
|
52
72
|
/* core tag id <-> canonical URI (tags.c is the identity SSOT). */
|
|
53
73
|
const char* yep_tag_uri(yep_tag_id id);
|
|
54
74
|
|
|
@@ -62,4 +82,22 @@ yep_tag_id yep_tag_from_uri(const char* p, uint32_t len);
|
|
|
62
82
|
* portably). */
|
|
63
83
|
const char* yep_tag_float_word(const char* p, uint32_t len);
|
|
64
84
|
|
|
85
|
+
/* The BOOL truth table for a resolved-bool view: 1 true, 0 false,
|
|
86
|
+
* -1 not a bool word. One table, two consumers: compat11's classify
|
|
87
|
+
* and the canonical/JSON emitter's BOOL arm — the DOM stores only the
|
|
88
|
+
* tag + source text, so the emitter re-asks the table (#937: guessing
|
|
89
|
+
* the value from the text's length spelled every non-4-char true-word
|
|
90
|
+
* false). The ci union of the families' sets (core's true/false forms
|
|
91
|
+
* are in the compat superset), so no family fact is needed. */
|
|
92
|
+
int yep_tag_bool_value(const char* p, uint32_t len);
|
|
93
|
+
|
|
94
|
+
/* Decode a resolved-INT view to its value through the family's own
|
|
95
|
+
* accepted forms: radix prefixes 0x/0o in both (0b and the leading-0
|
|
96
|
+
* octal + _/,/sexagesimal forms only when compat — core spells
|
|
97
|
+
* leading-0 decimal), digits otherwise. Overflow beyond the int64
|
|
98
|
+
* range returns nonzero and *out is untouched. The canonical/JSON
|
|
99
|
+
* emitter's INT arm (#937: source text like 0x1F is not a JSON
|
|
100
|
+
* token). */
|
|
101
|
+
int yep_tag_int64(const char* p, uint32_t len, int compat, int64_t* out);
|
|
102
|
+
|
|
65
103
|
#endif /* YEP_RESOLVER_H */
|
|
@@ -56,3 +56,195 @@ const char* yep_tag_float_word(const char* p, uint32_t len) {
|
|
|
56
56
|
}
|
|
57
57
|
return NULL;
|
|
58
58
|
}
|
|
59
|
+
|
|
60
|
+
static int ci_eq(const char* p, uint32_t n, const char* s) {
|
|
61
|
+
uint32_t m = 0;
|
|
62
|
+
while (s[m] != '\0') {
|
|
63
|
+
m++;
|
|
64
|
+
}
|
|
65
|
+
if (n != m) {
|
|
66
|
+
return 0;
|
|
67
|
+
}
|
|
68
|
+
for (uint32_t k = 0; k < n; k++) {
|
|
69
|
+
char a = p[k], b = s[k];
|
|
70
|
+
if (a >= 'A' && a <= 'Z') {
|
|
71
|
+
a = (char)(a - 'A' + 'a');
|
|
72
|
+
}
|
|
73
|
+
if (b >= 'A' && b <= 'Z') {
|
|
74
|
+
b = (char)(b - 'A' + 'a');
|
|
75
|
+
}
|
|
76
|
+
if (a != b) {
|
|
77
|
+
return 0;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return 1;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
int yep_tag_bool_value(const char* p, uint32_t len) {
|
|
84
|
+
static const char* const words[8] = {"y", "yes", "true", "on", "n", "no", "false", "off"};
|
|
85
|
+
for (unsigned i = 0; i < 8; i++) {
|
|
86
|
+
if (ci_eq(p, len, words[i])) {
|
|
87
|
+
return i < 4 ? 1 : 0;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return -1;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/* One base-denominated digit with overflow detection (uint64 keeps
|
|
94
|
+
* the INT64_MIN magnitude representable). */
|
|
95
|
+
static int acc_digit(uint64_t* acc, int base, int dv) {
|
|
96
|
+
uint64_t na = *acc * (uint64_t)base;
|
|
97
|
+
if (na / (uint64_t)base != *acc) {
|
|
98
|
+
return 1;
|
|
99
|
+
}
|
|
100
|
+
na += (uint64_t)dv;
|
|
101
|
+
if (na < *acc) {
|
|
102
|
+
return 1;
|
|
103
|
+
}
|
|
104
|
+
*acc = na;
|
|
105
|
+
return 0;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
int yep_tag_int64(const char* p, uint32_t n, int compat, int64_t* out) {
|
|
109
|
+
uint32_t i = 0;
|
|
110
|
+
int neg = 0;
|
|
111
|
+
if (n == 0) {
|
|
112
|
+
return 1;
|
|
113
|
+
}
|
|
114
|
+
if (p[0] == '-' || p[0] == '+') {
|
|
115
|
+
neg = p[0] == '-';
|
|
116
|
+
i = 1;
|
|
117
|
+
if (i >= n) {
|
|
118
|
+
return 1;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
/* radix prefixes first (both families, lowercase only — "0X1A"
|
|
122
|
+
* rides a string in core AND compat; 0o is core's spelling, 0b
|
|
123
|
+
* compat's), then compat's leading-0 octal, then the plain
|
|
124
|
+
* decimal/sexagesimal walk */
|
|
125
|
+
uint64_t acc = 0;
|
|
126
|
+
int digits = 0;
|
|
127
|
+
int base = 10;
|
|
128
|
+
uint32_t d = i;
|
|
129
|
+
if (n - i > 2 && p[i] == '0' && p[i + 1] == 'x') {
|
|
130
|
+
base = 16;
|
|
131
|
+
d = i + 2;
|
|
132
|
+
if (compat && p[d] == '_') {
|
|
133
|
+
d++;
|
|
134
|
+
if (p[d] == '_') {
|
|
135
|
+
return 1;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
} else if (n - i > 2 && p[i] == '0' && p[i + 1] == 'o') {
|
|
139
|
+
if (compat) {
|
|
140
|
+
return 1; /* 0o is not a compat form (psych) */
|
|
141
|
+
}
|
|
142
|
+
base = 8;
|
|
143
|
+
d = i + 2;
|
|
144
|
+
} else if (compat && n - i > 2 && p[i] == '0' && p[i + 1] == 'b') {
|
|
145
|
+
base = 2;
|
|
146
|
+
d = i + 2;
|
|
147
|
+
if (p[d] == '_') {
|
|
148
|
+
d++;
|
|
149
|
+
if (p[d] == '_') {
|
|
150
|
+
return 1;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
} else if (compat && p[i] == '0' && n - i >= 2) {
|
|
154
|
+
/* leading-0 octal (psych): 0[_]*[0-7][0-7_]* — the radix
|
|
155
|
+
* prefixes above never reach this arm */
|
|
156
|
+
base = 8;
|
|
157
|
+
d = i + 1;
|
|
158
|
+
while (d < n && p[d] == '_') {
|
|
159
|
+
d++;
|
|
160
|
+
}
|
|
161
|
+
if (d >= n) {
|
|
162
|
+
*out = 0; /* plain "0" / "000" */
|
|
163
|
+
return 0;
|
|
164
|
+
}
|
|
165
|
+
} else if (compat && p[i] == '0' && n - i == 1) {
|
|
166
|
+
*out = 0;
|
|
167
|
+
return 0;
|
|
168
|
+
} else if (compat && p[i] >= '0' && p[i] <= '9') {
|
|
169
|
+
/* sexagesimal int (compat only): d[d_,]*(:[0-5]?d){1,2} — the
|
|
170
|
+
* fractional form is float-tagged and never reaches here, but
|
|
171
|
+
* a '.' still refuses (the decode must not guess). '_' and ','
|
|
172
|
+
* are the compat separators (psych legacy). */
|
|
173
|
+
uint32_t k = i;
|
|
174
|
+
while (k < n && ((p[k] >= '0' && p[k] <= '9') || p[k] == '_' || p[k] == ',')) {
|
|
175
|
+
if (p[k] != '_' && p[k] != ',') {
|
|
176
|
+
if (acc_digit(&acc, 10, p[k] - '0')) {
|
|
177
|
+
return 1;
|
|
178
|
+
}
|
|
179
|
+
digits = 1;
|
|
180
|
+
}
|
|
181
|
+
k++;
|
|
182
|
+
}
|
|
183
|
+
if (k < n && p[k] == ':') {
|
|
184
|
+
while (k < n && p[k] == ':') {
|
|
185
|
+
k++;
|
|
186
|
+
int gd = 0;
|
|
187
|
+
int g = 0;
|
|
188
|
+
while (k < n && p[k] >= '0' && p[k] <= '9' && gd < 2) {
|
|
189
|
+
g = g * 10 + (p[k] - '0');
|
|
190
|
+
gd++;
|
|
191
|
+
k++;
|
|
192
|
+
}
|
|
193
|
+
if (gd < 1 || g > 59) {
|
|
194
|
+
return 1;
|
|
195
|
+
}
|
|
196
|
+
if (acc_digit(&acc, 60, g)) {
|
|
197
|
+
return 1;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
if (k == n) {
|
|
201
|
+
*out = neg ? -(int64_t)acc : (int64_t)acc;
|
|
202
|
+
return 0;
|
|
203
|
+
}
|
|
204
|
+
return 1;
|
|
205
|
+
}
|
|
206
|
+
/* a ':'-less digit span: the plain decimal path below would
|
|
207
|
+
* re-read it — answer directly */
|
|
208
|
+
if (k == n && digits) {
|
|
209
|
+
*out = neg ? -(int64_t)acc : (int64_t)acc;
|
|
210
|
+
return 0;
|
|
211
|
+
}
|
|
212
|
+
return 1;
|
|
213
|
+
}
|
|
214
|
+
acc = 0;
|
|
215
|
+
digits = 0;
|
|
216
|
+
for (uint32_t k = d; k < n; k++) {
|
|
217
|
+
char c = p[k];
|
|
218
|
+
int dv;
|
|
219
|
+
if (c >= '0' && c <= '9') {
|
|
220
|
+
dv = c - '0';
|
|
221
|
+
} else if (base == 16 && c >= 'a' && c <= 'f') {
|
|
222
|
+
dv = c - 'a' + 10;
|
|
223
|
+
} else if (base == 16 && c >= 'A' && c <= 'F') {
|
|
224
|
+
dv = c - 'A' + 10;
|
|
225
|
+
} else if (compat && (c == '_' || c == ',')) {
|
|
226
|
+
continue;
|
|
227
|
+
} else {
|
|
228
|
+
return 1;
|
|
229
|
+
}
|
|
230
|
+
if (base != 16 && dv >= base) {
|
|
231
|
+
return 1;
|
|
232
|
+
}
|
|
233
|
+
if (acc_digit(&acc, base, dv)) {
|
|
234
|
+
return 1;
|
|
235
|
+
}
|
|
236
|
+
digits = 1;
|
|
237
|
+
}
|
|
238
|
+
if (!digits) {
|
|
239
|
+
return 1;
|
|
240
|
+
}
|
|
241
|
+
if (neg && acc == (uint64_t)INT64_MAX + 1u) {
|
|
242
|
+
*out = INT64_MIN;
|
|
243
|
+
return 0;
|
|
244
|
+
}
|
|
245
|
+
if (acc > (uint64_t)INT64_MAX) {
|
|
246
|
+
return 1;
|
|
247
|
+
}
|
|
248
|
+
*out = neg ? -(int64_t)acc : (int64_t)acc;
|
|
249
|
+
return 0;
|
|
250
|
+
}
|
|
@@ -689,18 +689,33 @@ yep_span yep_scan_plain(const char* p, size_t len, size_t pos, int flow) {
|
|
|
689
689
|
size_t at = (hit < 0) ? len : i + (size_t)hit;
|
|
690
690
|
/* a multibyte break inside the piece ends it like an EOL: the
|
|
691
691
|
* byte stopset cannot see NEL/LS/PS, and the continuation
|
|
692
|
-
* would ride across the break into the next line's tokens
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
692
|
+
* would ride across the break into the next line's tokens.
|
|
693
|
+
* EVERY lead byte in the piece must be tested: the first lead
|
|
694
|
+
* can be an ordinary multibyte character (the r169 yen U+00A5
|
|
695
|
+
* leading a NEL run) while a later one is a break — testing
|
|
696
|
+
* the first lead only declined the check there and rode the
|
|
697
|
+
* break raw into the scalar (the false-lead ride, the r74
|
|
698
|
+
* plain-ends-at-NEL law defeated by the lead's own position). */
|
|
699
|
+
int mb_broken = 0;
|
|
700
|
+
for (size_t scan = i; at > scan;) {
|
|
701
|
+
const char* lead = (const char*)memchr(p + scan, 0xC2, at - scan);
|
|
702
|
+
const char* lead2 = (const char*)memchr(p + scan, 0xE2, at - scan);
|
|
696
703
|
const char* first =
|
|
697
704
|
(lead && lead2) ? (lead < lead2 ? lead : lead2) : (lead ? lead : lead2);
|
|
698
|
-
if (first
|
|
705
|
+
if (first == NULL) {
|
|
706
|
+
break;
|
|
707
|
+
}
|
|
708
|
+
if (yep_scan_mb_break_len(p, len, (size_t)(first - p)) > 0) {
|
|
699
709
|
at = (size_t)(first - p);
|
|
700
|
-
|
|
701
|
-
s.term = YEP_TERM_EOL;
|
|
710
|
+
mb_broken = 1;
|
|
702
711
|
break;
|
|
703
712
|
}
|
|
713
|
+
scan = (size_t)(first - p) + 1; /* a false lead: advance past it */
|
|
714
|
+
}
|
|
715
|
+
if (mb_broken) {
|
|
716
|
+
i = at;
|
|
717
|
+
s.term = YEP_TERM_EOL;
|
|
718
|
+
break;
|
|
704
719
|
}
|
|
705
720
|
unsigned char c = (at < len) ? (unsigned char)p[at] : 0;
|
|
706
721
|
|
|
@@ -1278,13 +1278,32 @@ ldone:
|
|
|
1278
1278
|
* Y79Y#4 error: defer to the engine, whose e_flow_ws owns the law
|
|
1279
1279
|
* -- the walk's whitespace loops treat the tab as separation, which
|
|
1280
1280
|
* accepted exactly the span the marshal drain's engine rejected,
|
|
1281
|
-
* splitting parseable from marshalable (the nightly's round 120)
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1281
|
+
* splitting parseable from marshalable (the nightly's round 120).
|
|
1282
|
+
* clean_only skips the scan: its byte guarantees already rejected
|
|
1283
|
+
* every tab in the span (LWS stops on one, the string c0 sweeps
|
|
1284
|
+
* and the tail reject it), so the pair cannot exist there. The
|
|
1285
|
+
* lenient lane rides memchr — a '\n'-hit vector pass instead of a
|
|
1286
|
+
* two-compare byte loop over the whole span (13% of json-doc). */
|
|
1287
|
+
if (!cl) {
|
|
1288
|
+
size_t k = open + 1;
|
|
1289
|
+
while (k < len) {
|
|
1290
|
+
const char* nl = (const char*)memchr(p + k, '\n', len - k);
|
|
1291
|
+
if (nl == NULL) {
|
|
1292
|
+
break;
|
|
1293
|
+
}
|
|
1294
|
+
k = (size_t)(nl - p) + 1;
|
|
1295
|
+
if (k < len && p[k] == '\t') {
|
|
1296
|
+
yeptris_tape_free(t);
|
|
1297
|
+
return YEPTRIS_ERROR_PARSE;
|
|
1298
|
+
}
|
|
1286
1299
|
}
|
|
1287
1300
|
}
|
|
1301
|
+
/* the >1024 simple-key verdict settles HERE when no key crossed the
|
|
1302
|
+
* raw cap in lmapcolon: chars <= bytes closes the char budget too,
|
|
1303
|
+
* so no key can violate the law — without this, every clean
|
|
1304
|
+
* document paid yep_tape_long_simple_key's full-tape re-walk (16%
|
|
1305
|
+
* of json-doc parse, the #739 residual) */
|
|
1306
|
+
t->_long_key_known = 1;
|
|
1288
1307
|
t->count = count;
|
|
1289
1308
|
t->_src = p;
|
|
1290
1309
|
t->_srclen = len;
|
|
@@ -43,6 +43,7 @@ struct yeptris_schema {
|
|
|
43
43
|
const yep_dom* dom; /* borrowed from doc (yep_doc_dom) */
|
|
44
44
|
uint32_t sroot; /* the schema document's root (docs[0]) */
|
|
45
45
|
yep_re_cache* cache; /* owned: pattern source -> compiled NFA; immutable after compile */
|
|
46
|
+
js_resources* res; /* owned: $id/$anchor/$dynamicAnchor map + ref-site bases */
|
|
46
47
|
};
|
|
47
48
|
|
|
48
49
|
/* ---- the pattern collection (compile-time, eager) ----------------------- */
|
|
@@ -188,8 +189,22 @@ yeptris_schema* yep_schema_compile_st(const char* bytes, size_t n, YeptrisStatus
|
|
|
188
189
|
return NULL;
|
|
189
190
|
}
|
|
190
191
|
|
|
192
|
+
/* the identifier map: $id resources, anchors, ref-site bases —
|
|
193
|
+
* built once by the crawl, read-only afterwards (OOM is loud) */
|
|
194
|
+
js_resources* res = yep_js_resources_crawl(dom, dom->docs[0]);
|
|
195
|
+
if (res == NULL) {
|
|
196
|
+
yep_re_cache_free(cache);
|
|
197
|
+
yeptris_document_free(doc);
|
|
198
|
+
yep_free(sys, copy);
|
|
199
|
+
yep_error_set(yep_error_tls(), YEP_ERR_MEMORY, 0, 0, 0,
|
|
200
|
+
"the schema's identifier map failed to build");
|
|
201
|
+
*st = YEPTRIS_ERROR_MEMORY;
|
|
202
|
+
return NULL;
|
|
203
|
+
}
|
|
204
|
+
|
|
191
205
|
yeptris_schema* s = yep_alloc(sys, sizeof(*s));
|
|
192
206
|
if (s == NULL) {
|
|
207
|
+
yep_js_resources_free(res);
|
|
193
208
|
yep_re_cache_free(cache);
|
|
194
209
|
yeptris_document_free(doc);
|
|
195
210
|
yep_free(sys, copy);
|
|
@@ -201,6 +216,7 @@ yeptris_schema* yep_schema_compile_st(const char* bytes, size_t n, YeptrisStatus
|
|
|
201
216
|
s->dom = dom;
|
|
202
217
|
s->sroot = dom->docs[0];
|
|
203
218
|
s->cache = cache;
|
|
219
|
+
s->res = res;
|
|
204
220
|
return s;
|
|
205
221
|
}
|
|
206
222
|
|
|
@@ -211,11 +227,29 @@ YEPTRIS_API yeptris_schema* yeptris_schema_compile(const char* bytes, size_t n)
|
|
|
211
227
|
return yep_schema_compile_st(bytes, n, &st); /* the error channel carries the why */
|
|
212
228
|
}
|
|
213
229
|
|
|
230
|
+
/* The tag-driven hook's read-only view (internal.h, #906 slice 4):
|
|
231
|
+
* everything the subtree walk reads, borrowed from the handle — the
|
|
232
|
+
* REGISTRY LAW keeps the handle alive underneath it. */
|
|
233
|
+
void yep_schema_view_of(const yeptris_schema* s, yep_schema_view* out) {
|
|
234
|
+
if (out == NULL) {
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
if (s == NULL) {
|
|
238
|
+
memset(out, 0, sizeof(*out));
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
out->dom = s->dom;
|
|
242
|
+
out->sroot = s->sroot;
|
|
243
|
+
out->cache = s->cache;
|
|
244
|
+
out->res = s->res;
|
|
245
|
+
}
|
|
246
|
+
|
|
214
247
|
YEPTRIS_API void yeptris_schema_free(yeptris_schema* s) {
|
|
215
248
|
if (s == NULL) {
|
|
216
249
|
return;
|
|
217
250
|
}
|
|
218
251
|
const yep_allocator* sys = yep_system_allocator();
|
|
252
|
+
yep_js_resources_free(s->res);
|
|
219
253
|
yep_re_cache_free(s->cache);
|
|
220
254
|
yeptris_document_free(s->doc); /* the DOM and every pool under it */
|
|
221
255
|
yep_free(sys, s->bytes); /* the views' home: freed after its readers */
|
|
@@ -257,9 +291,11 @@ YEPTRIS_API YeptrisStatus yeptris_schema_validate(yeptris_schema* s, const char*
|
|
|
257
291
|
yeptris_document_free(idoc);
|
|
258
292
|
return YEPTRIS_ERROR_MEMORY;
|
|
259
293
|
}
|
|
260
|
-
/* the handle is a pure reader here (its cache
|
|
261
|
-
* same walk, the same report shape, the
|
|
262
|
-
|
|
294
|
+
/* the handle is a pure reader here (its cache and identifier map
|
|
295
|
+
* are immutable): the same walk, the same report shape, the
|
|
296
|
+
* one-shot's verdicts */
|
|
297
|
+
int rc =
|
|
298
|
+
yep_jsonschema_run(s->dom, s->sroot, idom, idom->docs, idom->dcount, r, s->cache, s->res);
|
|
263
299
|
yeptris_document_free(idoc);
|
|
264
300
|
if (rc != 0) {
|
|
265
301
|
yeptris_validate_report_free(r);
|