teptris 0.3.21.0 → 0.3.22.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8e81e9a33c578666c740698bbb8e2fb6f26a024171ecb6272b78c5d92d9804ed
4
- data.tar.gz: e8fb35a12bd6b89f514cfbe6c7e0d16cd0bc32c2d4af7803d03343000b7ab7dd
3
+ metadata.gz: f3a85f888be2e47984e4b66493e605e373fc70c190e63327b366ece44dc7e24b
4
+ data.tar.gz: 57ef42093dffdc3384bd08f86fea917b1674b9f5921060e1889584517fc2c1e5
5
5
  SHA512:
6
- metadata.gz: 2184aeb0561d4a659c119717079e215345a9897cd5d5217810c7c16d3bee93fb6b732358e4d0e3f6d98bfcf11ef74499058873bf24f4c44454f19888a88d07e0
7
- data.tar.gz: 6de032131c5af9e6a56f7d36eb6ca373a7dd2dbc0a716e7305f8f0bbbc3ffa75f3165d22254d448e77d6a77c264e029a590cd80f4cc0d43aa52046cfd308e2be
6
+ metadata.gz: 289c71d4b055176a7ec4364d0bcf0684c9cf6ae9192274438fc1d63a6bd989bb37b20d9f9dc1b883de2fd58304f961a76b7ba5ce1263d540d81089c1e6c132cd
7
+ data.tar.gz: a35640d1c16e9d0f420fcd95c6f5c27303e1ff74c5efce2d0787194ea36903a5b872e55d4119b9cf15a23205819738d053202bd5c2f084382836f3516a8a26aa
@@ -1,4 +1,4 @@
1
- # libteptris 0.3.21 — vendored source
1
+ # libteptris 0.3.22 — vendored source
2
2
 
3
3
  This directory carries the COMPLETE C source of the engine this
4
4
  gem's extension was built from (the packaging doctrine: compiled
@@ -3,7 +3,7 @@
3
3
 
4
4
  #define TEPTRIS_VERSION_MAJOR 0
5
5
  #define TEPTRIS_VERSION_MINOR 3
6
- #define TEPTRIS_VERSION_PATCH 21
7
- #define TEPTRIS_VERSION_STRING "0.3.21"
6
+ #define TEPTRIS_VERSION_PATCH 22
7
+ #define TEPTRIS_VERSION_STRING "0.3.22"
8
8
 
9
9
  #endif /* TEPTRIS_VERSION_H */
@@ -611,6 +611,24 @@ bool sch_format_string_check(int format, const char *s, size_t len,
611
611
  switch (format) {
612
612
  case FMT_DATE: return check_date(s, len);
613
613
  case FMT_DATETIME: return check_datetime(s, len);
614
+ case FMT_DATETIME_LOCAL: {
615
+ /* the local shape: full-date T HH:MM:SS[.frac], no offset */
616
+ if (len < 19 || !check_date(s, 10)) return false;
617
+ if (s[10] != 'T' && s[10] != 't') return false;
618
+ size_t used = check_hms(s + 11, len - 11);
619
+ if (used == 0) return false;
620
+ size_t pos = 11 + used;
621
+ if (pos < len && s[pos] == '.') {
622
+ size_t frac = 0;
623
+ pos++;
624
+ while (pos < len && is_digit(s[pos])) {
625
+ pos++;
626
+ frac++;
627
+ }
628
+ if (frac == 0) return false;
629
+ }
630
+ return pos == len;
631
+ }
614
632
  case FMT_TIME: {
615
633
  size_t used = check_hms(s, len);
616
634
  if (used == 0) return false;
@@ -626,6 +644,22 @@ bool sch_format_string_check(int format, const char *s, size_t len,
626
644
  }
627
645
  return len > pos && check_offset(s + pos, len - pos) == len - pos;
628
646
  }
647
+ case FMT_TIME_LOCAL: {
648
+ /* HH:MM:SS[.frac] with no offset (TOML's local time) */
649
+ size_t used = check_hms(s, len);
650
+ if (used == 0) return false;
651
+ size_t pos = used;
652
+ if (pos < len && s[pos] == '.') {
653
+ size_t frac = 0;
654
+ pos++;
655
+ while (pos < len && is_digit(s[pos])) {
656
+ pos++;
657
+ frac++;
658
+ }
659
+ if (frac == 0) return false;
660
+ }
661
+ return pos == len;
662
+ }
629
663
  case FMT_EMAIL:
630
664
  case FMT_IDN_EMAIL: return check_email(s, len);
631
665
  case FMT_HOSTNAME:
@@ -185,10 +185,13 @@ static const char *jstring(jctx *c, size_t *out_len) {
185
185
  c->pos++; /* closing quote */
186
186
  return s;
187
187
  }
188
- /* escaped string: rebuild into arena memory */
188
+ /* escaped string: rebuild into arena memory, carrying the plain
189
+ * prefix the fast scan already stepped over */
190
+ size_t plain_len = c->pos - start;
189
191
  size_t cap = (c->pos - start) * 4 + 16;
190
192
  char *out = teptris_arena_alloc(c->a, cap);
191
- size_t n = 0;
193
+ size_t n = plain_len;
194
+ memcpy(out, c->src + start, plain_len);
192
195
  for (;;) {
193
196
  if (c->pos >= c->len) {
194
197
  jfail(c, "unterminated string");
@@ -95,12 +95,18 @@ static jv *resolve_local(sctx *c, const char *ref) {
95
95
  }
96
96
  return cur;
97
97
  }
98
- /* plain-name fragment: an $anchor */
98
+ /* plain-name fragment: an $anchor or a $dynamicAnchor (a plain
99
+ * $ref to either behaves the same way) */
99
100
  for (size_t i = 0; i < c->n_anchors; i++) {
100
101
  if (strcmp(c->anchors[i].name, ref + 1) == 0) {
101
102
  return c->anchors[i].target;
102
103
  }
103
104
  }
105
+ for (size_t i = 0; i < c->n_dyn_anchors; i++) {
106
+ if (strcmp(c->dyn_anchors[i].name, ref + 1) == 0) {
107
+ return c->dyn_anchors[i].target;
108
+ }
109
+ }
104
110
  return NULL;
105
111
  }
106
112
 
@@ -132,6 +138,26 @@ static void collect_anchors(sctx *c, jv *v) {
132
138
  c->anchors[c->n_anchors].target = v;
133
139
  c->n_anchors++;
134
140
  }
141
+ if (strcmp(k, "$dynamicAnchor") == 0 && jv_kind_of(val) == JV_STRING) {
142
+ if (c->n_dyn_anchors == c->cap_dyn_anchors) {
143
+ c->cap_dyn_anchors =
144
+ c->cap_dyn_anchors == 0 ? 8 : c->cap_dyn_anchors * 2;
145
+ void *na = teptris_arena_alloc(
146
+ c->a, c->cap_dyn_anchors * sizeof(*c->dyn_anchors));
147
+ if (c->n_dyn_anchors > 0) {
148
+ memcpy(na, c->dyn_anchors,
149
+ c->n_dyn_anchors * sizeof(*c->dyn_anchors));
150
+ }
151
+ c->dyn_anchors = na;
152
+ }
153
+ c->dyn_anchors[c->n_dyn_anchors].name = jv_str(val);
154
+ c->dyn_anchors[c->n_dyn_anchors].target = v;
155
+ c->n_dyn_anchors++;
156
+ }
157
+ if (strcmp(k, "$recursiveAnchor") == 0 && jv_kind_of(val) == JV_BOOL &&
158
+ jv_bool(val) && c->rec_anchor_target == NULL) {
159
+ c->rec_anchor_target = v;
160
+ }
135
161
  collect_anchors(c, val);
136
162
  }
137
163
  } else if (jv_kind_of(v) == JV_ARRAY) {
@@ -157,6 +183,14 @@ static int format_kind(const char *name) {
157
183
  if (strcmp(name, "date-time") == 0) return FMT_DATETIME;
158
184
  if (strcmp(name, "date") == 0) return FMT_DATE;
159
185
  if (strcmp(name, "time") == 0) return FMT_TIME;
186
+ if (strcmp(name, "date-time-local") == 0 ||
187
+ strcmp(name, "partial-date-time") == 0) {
188
+ return FMT_DATETIME_LOCAL;
189
+ }
190
+ if (strcmp(name, "time-local") == 0 ||
191
+ strcmp(name, "partial-time") == 0) {
192
+ return FMT_TIME_LOCAL;
193
+ }
160
194
  if (strcmp(name, "email") == 0) return FMT_EMAIL;
161
195
  if (strcmp(name, "idn-email") == 0) return FMT_IDN_EMAIL;
162
196
  if (strcmp(name, "hostname") == 0) return FMT_HOSTNAME;
@@ -219,6 +253,28 @@ static bool compile_type(sctx *c, sch_node *n, jv *tv, const char *where) {
219
253
  return false;
220
254
  }
221
255
 
256
+ /* the suite writes count constraints as decimals ("maxLength": 3.0):
257
+ * a JSON number is valid there, so accept float tokens whose value is
258
+ * integral (a non-integral count cannot be satisfied; ignore it like
259
+ * an annotation would lie - reject the schema instead) */
260
+ static bool count_value(sctx *c, jv *val, long *out) {
261
+ if (jv_kind_of(val) == JV_INT) {
262
+ *out = (long)jv_int(val);
263
+ return true;
264
+ }
265
+ if (jv_kind_of(val) == JV_NUM) {
266
+ double d = jv_num(val);
267
+ if (d != d || d != (double)(long)d) {
268
+ sfail(c, "count constraint must be an integer", NULL);
269
+ return false;
270
+ }
271
+ *out = (long)d;
272
+ return true;
273
+ }
274
+ sfail(c, "count constraint must be an integer", NULL);
275
+ return false;
276
+ }
277
+
222
278
  static bool grow_dep_list(sctx *c, sch_kschema **list, size_t *n, size_t *cap) {
223
279
  if (*n == *cap) {
224
280
  *cap = *cap == 0 ? 4 : *cap * 2;
@@ -293,24 +349,10 @@ sch_node *sch_compile_node(sctx *c, const jv *v) {
293
349
  sch_node *n = sch_node_new(c);
294
350
  memo_put(c, v, n);
295
351
 
296
- const char *unsupported[] = {
297
- "unevaluatedProperties", "unevaluatedItems", "$dynamicRef",
298
- "$dynamicAnchor", "$recursiveRef", "$recursiveAnchor", NULL
299
- };
300
-
301
352
  for (size_t i = 0; i < jv_member_count(v); i++) {
302
353
  const char *k = jv_member_key(v, i);
303
354
  jv *val = jv_member_val(v, i);
304
355
 
305
- /* unsupported KNOWN keywords: reject (ignoring them would
306
- * silently accept documents that should fail) */
307
- for (int u = 0; unsupported[u] != NULL; u++) {
308
- if (strcmp(k, unsupported[u]) == 0) {
309
- sfail(c, "unsupported keyword", k);
310
- return NULL;
311
- }
312
- }
313
-
314
356
  if (strcmp(k, "type") == 0) {
315
357
  if (!compile_type(c, n, val, k)) return NULL;
316
358
  } else if (strcmp(k, "$ref") == 0) {
@@ -374,6 +416,75 @@ sch_node *sch_compile_node(sctx *c, const jv *v) {
374
416
  n->additional = sch_compile_node(c, val);
375
417
  if (n->additional == NULL && c->err[0] != '\0') return NULL;
376
418
  n->additional_set = true;
419
+ } else if (strcmp(k, "unevaluatedProperties") == 0) {
420
+ n->uneval_props = sch_compile_node(c, val);
421
+ if (n->uneval_props == NULL && c->err[0] != '\0') return NULL;
422
+ } else if (strcmp(k, "unevaluatedItems") == 0) {
423
+ n->uneval_items = sch_compile_node(c, val);
424
+ if (n->uneval_items == NULL && c->err[0] != '\0') return NULL;
425
+ } else if (strcmp(k, "$dynamicAnchor") == 0 &&
426
+ jv_kind_of(val) == JV_STRING) {
427
+ n->dynamic_anchor = jv_str(val);
428
+ } else if (strcmp(k, "$recursiveAnchor") == 0 &&
429
+ jv_kind_of(val) == JV_BOOL && jv_bool(val)) {
430
+ n->recursive_anchor = "$";
431
+ } else if (strcmp(k, "$dynamicRef") == 0 ||
432
+ strcmp(k, "$recursiveRef") == 0) {
433
+ if (jv_kind_of(val) != JV_STRING) {
434
+ sfail(c, "$dynamicRef/$recursiveRef must be a string", k);
435
+ return NULL;
436
+ }
437
+ const char *r = jv_str(val);
438
+ bool recursive = strcmp(k, "$recursiveRef") == 0;
439
+ /* $recursiveRef is always the bare "#"; a pointer-form
440
+ * $dynamicRef ("#/pointer") does not participate in
441
+ * dynamic scope resolution - the spec and the suite both
442
+ * read it exactly like a plain $ref - so only the
443
+ * plain-name fragment form reaches the scope machinery */
444
+ if (r[0] != '#' || (recursive && r[1] != '\0') ||
445
+ (!recursive && r[1] == '\0')) {
446
+ sfail(c,
447
+ "dynamic $refs are plain-name fragments "
448
+ "(\"#anchor\") or pointers (\"#/a/b\")",
449
+ r);
450
+ return NULL;
451
+ }
452
+ if (!recursive && strchr(r + 1, '/') != NULL) {
453
+ n->ref = sch_resolve_pointer(c, r);
454
+ if (n->ref == NULL) {
455
+ sfail(c, "unresolvable $dynamicRef", r);
456
+ return NULL;
457
+ }
458
+ continue;
459
+ }
460
+ /* the static fallback: the doc-wide anchor collection;
461
+ * the innermost scope wins at validation time */
462
+ jv *target = NULL;
463
+ if (recursive) {
464
+ target = c->rec_anchor_target != NULL
465
+ ? c->rec_anchor_target
466
+ : c->root;
467
+ } else {
468
+ for (size_t d = 0; d < c->n_dyn_anchors && target == NULL; d++) {
469
+ if (strcmp(c->dyn_anchors[d].name, r + 1) == 0) {
470
+ target = c->dyn_anchors[d].target;
471
+ }
472
+ }
473
+ if (target == NULL) {
474
+ sfail(c, "unresolvable $dynamicRef (no matching "
475
+ "$dynamicAnchor)",
476
+ r);
477
+ return NULL;
478
+ }
479
+ }
480
+ n->dynamic_ref = jv_str(val);
481
+ n->dynamic_ref_target = sch_compile_node(c, target);
482
+ if (n->dynamic_ref_target == NULL && c->err[0] != '\0') {
483
+ return NULL;
484
+ }
485
+ } else if (strcmp(k, "contentSchema") == 0) {
486
+ n->content_schema = sch_compile_node(c, val);
487
+ if (n->content_schema == NULL && c->err[0] != '\0') return NULL;
377
488
  } else if (strcmp(k, "required") == 0 &&
378
489
  jv_kind_of(val) == JV_ARRAY) {
379
490
  size_t cnt = jv_item_count(val);
@@ -395,13 +506,11 @@ sch_node *sch_compile_node(sctx *c, const jv *v) {
395
506
  } else if (strcmp(k, "propertyNames") == 0) {
396
507
  n->prop_names = sch_compile_node(c, val);
397
508
  if (n->prop_names == NULL && c->err[0] != '\0') return NULL;
398
- } else if (strcmp(k, "minProperties") == 0 &&
399
- jv_kind_of(val) == JV_INT) {
400
- n->min_props = (long)jv_int(val);
509
+ } else if (strcmp(k, "minProperties") == 0) {
510
+ if (!count_value(c, val, &n->min_props)) return NULL;
401
511
  n->has_min_props = true;
402
- } else if (strcmp(k, "maxProperties") == 0 &&
403
- jv_kind_of(val) == JV_INT) {
404
- n->max_props = (long)jv_int(val);
512
+ } else if (strcmp(k, "maxProperties") == 0) {
513
+ if (!count_value(c, val, &n->max_props)) return NULL;
405
514
  n->has_max_props = true;
406
515
  } else if (strcmp(k, "dependencies") == 0 &&
407
516
  jv_kind_of(val) == JV_OBJECT) {
@@ -493,20 +602,20 @@ sch_node *sch_compile_node(sctx *c, const jv *v) {
493
602
  n->contains = sch_compile_node(c, val);
494
603
  if (n->contains == NULL && c->err[0] != '\0') return NULL;
495
604
  n->has_contains = true;
496
- } else if (strcmp(k, "minContains") == 0 && jv_kind_of(val) == JV_INT) {
497
- n->min_contains = (long)jv_int(val);
605
+ } else if (strcmp(k, "minContains") == 0) {
606
+ if (!count_value(c, val, &n->min_contains)) return NULL;
498
607
  n->has_min_contains = true;
499
- } else if (strcmp(k, "maxContains") == 0 && jv_kind_of(val) == JV_INT) {
500
- n->max_contains = (long)jv_int(val);
608
+ } else if (strcmp(k, "maxContains") == 0) {
609
+ if (!count_value(c, val, &n->max_contains)) return NULL;
501
610
  n->has_max_contains = true;
502
611
  } else if (strcmp(k, "uniqueItems") == 0 && jv_kind_of(val) == JV_BOOL) {
503
612
  n->unique_items = jv_bool(val);
504
613
  n->has_unique = true;
505
- } else if (strcmp(k, "minItems") == 0 && jv_kind_of(val) == JV_INT) {
506
- n->min_items = (long)jv_int(val);
614
+ } else if (strcmp(k, "minItems") == 0) {
615
+ if (!count_value(c, val, &n->min_items)) return NULL;
507
616
  n->has_min_items = true;
508
- } else if (strcmp(k, "maxItems") == 0 && jv_kind_of(val) == JV_INT) {
509
- n->max_items = (long)jv_int(val);
617
+ } else if (strcmp(k, "maxItems") == 0) {
618
+ if (!count_value(c, val, &n->max_items)) return NULL;
510
619
  n->has_max_items = true;
511
620
  } else if (strcmp(k, "pattern") == 0 && jv_kind_of(val) == JV_STRING) {
512
621
  char rerr[128] = {0};
@@ -516,11 +625,11 @@ sch_node *sch_compile_node(sctx *c, const jv *v) {
516
625
  sfail(c, rerr[0] != '\0' ? rerr : "invalid pattern", k);
517
626
  return NULL;
518
627
  }
519
- } else if (strcmp(k, "minLength") == 0 && jv_kind_of(val) == JV_INT) {
520
- n->min_length = (long)jv_int(val);
628
+ } else if (strcmp(k, "minLength") == 0) {
629
+ if (!count_value(c, val, &n->min_length)) return NULL;
521
630
  n->has_min_length = true;
522
- } else if (strcmp(k, "maxLength") == 0 && jv_kind_of(val) == JV_INT) {
523
- n->max_length = (long)jv_int(val);
631
+ } else if (strcmp(k, "maxLength") == 0) {
632
+ if (!count_value(c, val, &n->max_length)) return NULL;
524
633
  n->has_max_length = true;
525
634
  } else if (strcmp(k, "format") == 0 && jv_kind_of(val) == JV_STRING) {
526
635
  n->format = format_kind(jv_str(val));
@@ -28,6 +28,8 @@ enum {
28
28
  FMT_DATETIME,
29
29
  FMT_DATE,
30
30
  FMT_TIME,
31
+ FMT_DATETIME_LOCAL,
32
+ FMT_TIME_LOCAL,
31
33
  /* the taplo parity set: every format the jsonschema crate (the
32
34
  * engine behind taplo) asserts on; names outside this set are
33
35
  * annotations on both sides */
@@ -104,6 +106,14 @@ struct sch_node {
104
106
  bool items_set;
105
107
  sch_node *add_items; /* additionalItems: applies beyond prefix */
106
108
  bool add_items_set;
109
+ sch_node *uneval_props; /* unevaluatedProperties: frame-local */
110
+ sch_node *uneval_items; /* unevaluatedItems: frame-local */
111
+ sch_node *content_schema; /* contentSchema: asserts decoded content */
112
+ const char *dynamic_anchor; /* $dynamicAnchor name carried here */
113
+ const char *recursive_anchor; /* "$" when $recursiveAnchor is true */
114
+ const char *dynamic_ref; /* "#name" fragment for
115
+ * $dynamicRef / $recursiveRef */
116
+ sch_node *dynamic_ref_target; /* compile-resolved static fallback */
107
117
  sch_node *contains;
108
118
  long min_contains, max_contains;
109
119
  bool has_contains, has_min_contains, has_max_contains;
@@ -166,6 +176,14 @@ typedef struct {
166
176
  jv *target;
167
177
  } *anchors;
168
178
  size_t n_anchors, cap_anchors;
179
+ /* $dynamicAnchor / $recursiveAnchor:true targets (the static
180
+ * fallback for $dynamicRef / $recursiveRef) */
181
+ struct {
182
+ const char *name;
183
+ jv *target;
184
+ } *dyn_anchors;
185
+ size_t n_dyn_anchors, cap_dyn_anchors;
186
+ jv *rec_anchor_target;
169
187
  char *err;
170
188
  size_t err_cap;
171
189
  } sctx;
@@ -203,6 +221,7 @@ struct sch_svalue {
203
221
  size_t n_members;
204
222
  sch_svalue **items;
205
223
  size_t n_items;
224
+ bool has_offset; /* offset datetimes only (kind rules for formats) */
206
225
  };
207
226
 
208
227
  /* schema.c */
@@ -30,6 +30,26 @@ typedef struct {
30
30
  char sseg_buf[64][64];
31
31
  int sdepth;
32
32
  int truncated;
33
+ /* annotation frames (2020-12 unevaluated* semantics): one per
34
+ * schema-object application; a child application on the SAME
35
+ * instance merges up into its parent at exit (in-place
36
+ * applicators), cousins and different-instance children never
37
+ * do; trials restore the merge target on failure */
38
+ struct eval_frame {
39
+ const sch_svalue *inst;
40
+ const char **keys;
41
+ size_t n_keys, cap_keys;
42
+ size_t *idx;
43
+ size_t n_idx, cap_idx;
44
+ } *frames;
45
+ int n_frames, cap_frames;
46
+ /* dynamic-scope stack for $dynamicRef / $recursiveRef: the
47
+ * innermost anchor on the evaluation path wins */
48
+ struct dyn_scope {
49
+ const char *name;
50
+ sch_node *node;
51
+ } *scopes;
52
+ int n_scopes, cap_scopes;
33
53
  } vctx;
34
54
 
35
55
  /* ---------------------------------------------------------- output -- */
@@ -168,6 +188,153 @@ static void verr(vctx *vc, const char *fmt, ...) {
168
188
  vc->n_errors++;
169
189
  }
170
190
 
191
+ /* ------------------------------------------- annotation frames (2020-12) */
192
+
193
+ static bool frame_grow(vctx *vc) {
194
+ if (vc->n_frames == vc->cap_frames) {
195
+ vc->cap_frames = vc->cap_frames == 0 ? 16 : vc->cap_frames * 2;
196
+ void *nf = realloc(vc->frames, vc->cap_frames * sizeof(*vc->frames));
197
+ if (nf == NULL) return false;
198
+ vc->frames = nf;
199
+ }
200
+ return true;
201
+ }
202
+
203
+ static bool frame_push(vctx *vc, const sch_svalue *v) {
204
+ if (!frame_grow(vc)) return false;
205
+ struct eval_frame *f = &vc->frames[vc->n_frames++];
206
+ memset(f, 0, sizeof(*f));
207
+ f->inst = v;
208
+ return true;
209
+ }
210
+
211
+ /* merge this frame's annotations into the parent (bubbling up through
212
+ * an in-place applicator); answers false when there is no parent or
213
+ * the parent annotated a different instance (cousins/descendants) */
214
+ static void frame_merge_up(vctx *vc) {
215
+ if (vc->n_frames < 2) return;
216
+ struct eval_frame *f = &vc->frames[vc->n_frames - 1];
217
+ struct eval_frame *p = &vc->frames[vc->n_frames - 2];
218
+ if (p->inst != f->inst) return;
219
+ if (f->n_keys > 0) {
220
+ if (p->n_keys + f->n_keys > p->cap_keys) {
221
+ size_t want = p->cap_keys == 0 ? 8 : p->cap_keys;
222
+ while (want < p->n_keys + f->n_keys) want *= 2;
223
+ void *nk = realloc(p->keys, want * sizeof(*p->keys));
224
+ if (nk == NULL) return;
225
+ p->keys = nk;
226
+ p->cap_keys = want;
227
+ }
228
+ memcpy(p->keys + p->n_keys, f->keys, f->n_keys * sizeof(*f->keys));
229
+ p->n_keys += f->n_keys;
230
+ }
231
+ if (f->n_idx > 0) {
232
+ if (p->n_idx + f->n_idx > p->cap_idx) {
233
+ size_t want = p->cap_idx == 0 ? 8 : p->cap_idx;
234
+ while (want < p->n_idx + f->n_idx) want *= 2;
235
+ void *ni = realloc(p->idx, want * sizeof(*p->idx));
236
+ if (ni == NULL) return;
237
+ p->idx = ni;
238
+ p->cap_idx = want;
239
+ }
240
+ memcpy(p->idx + p->n_idx, f->idx, f->n_idx * sizeof(*f->idx));
241
+ p->n_idx += f->n_idx;
242
+ }
243
+ }
244
+
245
+ /* pop the top frame: bubble its annotations into the parent, then
246
+ * release its arrays (a slot above n_frames would never be revisited
247
+ * by frames_free) */
248
+ static void frame_pop(vctx *vc) {
249
+ frame_merge_up(vc);
250
+ struct eval_frame *f = &vc->frames[vc->n_frames - 1];
251
+ free(f->keys);
252
+ free(f->idx);
253
+ vc->n_frames--;
254
+ }
255
+
256
+ static bool frame_key_seen(const struct eval_frame *f, const char *key) {
257
+ for (size_t i = 0; i < f->n_keys; i++) {
258
+ if (strcmp(f->keys[i], key) == 0) return true;
259
+ }
260
+ return false;
261
+ }
262
+
263
+ static bool frame_idx_seen(const struct eval_frame *f, size_t idx) {
264
+ for (size_t i = 0; i < f->n_idx; i++) {
265
+ if (f->idx[i] == idx) return true;
266
+ }
267
+ return false;
268
+ }
269
+
270
+ static void frame_add_key(vctx *vc, const char *key) {
271
+ if (vc->n_frames == 0) return;
272
+ struct eval_frame *f = &vc->frames[vc->n_frames - 1];
273
+ if (frame_key_seen(f, key)) return;
274
+ if (f->n_keys == f->cap_keys) {
275
+ f->cap_keys = f->cap_keys == 0 ? 8 : f->cap_keys * 2;
276
+ void *nk = realloc(f->keys, f->cap_keys * sizeof(*f->keys));
277
+ if (nk == NULL) return;
278
+ f->keys = nk;
279
+ }
280
+ f->keys[f->n_keys++] = key;
281
+ }
282
+
283
+ static void frame_add_idx(vctx *vc, size_t idx) {
284
+ if (vc->n_frames == 0) return;
285
+ struct eval_frame *f = &vc->frames[vc->n_frames - 1];
286
+ if (frame_idx_seen(f, idx)) return;
287
+ if (f->n_idx == f->cap_idx) {
288
+ f->cap_idx = f->cap_idx == 0 ? 8 : f->cap_idx * 2;
289
+ void *ni = realloc(f->idx, f->cap_idx * sizeof(*f->idx));
290
+ if (ni == NULL) return;
291
+ f->idx = ni;
292
+ }
293
+ f->idx[f->n_idx++] = idx;
294
+ }
295
+
296
+ /* drop the annotations a trial contributed to its merge target (the
297
+ * parent frame): failed anyOf/oneOf branches and the not/if trials
298
+ * annotate nothing */
299
+ static void frame_truncate_to(vctx *vc, size_t n_keys, size_t n_idx) {
300
+ if (vc->n_frames < 1) return;
301
+ struct eval_frame *f = &vc->frames[vc->n_frames - 1];
302
+ if (f->n_keys > n_keys) f->n_keys = n_keys;
303
+ if (f->n_idx > n_idx) f->n_idx = n_idx;
304
+ }
305
+
306
+ static void frames_free(vctx *vc) {
307
+ for (int i = 0; i < vc->n_frames; i++) {
308
+ free(vc->frames[i].keys);
309
+ free(vc->frames[i].idx);
310
+ }
311
+ free(vc->frames);
312
+ }
313
+
314
+ /* ------------------------------------------------- dynamic scopes -- */
315
+
316
+ static bool scope_push(vctx *vc, const char *name, sch_node *node) {
317
+ if (name == NULL || node == NULL) return true;
318
+ if (vc->n_scopes == vc->cap_scopes) {
319
+ vc->cap_scopes = vc->cap_scopes == 0 ? 16 : vc->cap_scopes * 2;
320
+ void *ns = realloc(vc->scopes, vc->cap_scopes * sizeof(*vc->scopes));
321
+ if (ns == NULL) return false;
322
+ vc->scopes = ns;
323
+ }
324
+ vc->scopes[vc->n_scopes].name = name;
325
+ vc->scopes[vc->n_scopes].node = node;
326
+ vc->n_scopes++;
327
+ return true;
328
+ }
329
+
330
+ /* the innermost dynamic anchor for a name on the evaluation path */
331
+ static sch_node *scope_resolve(vctx *vc, const char *name) {
332
+ for (int i = vc->n_scopes - 1; i >= 0; i--) {
333
+ if (strcmp(vc->scopes[i].name, name) == 0) return vc->scopes[i].node;
334
+ }
335
+ return NULL;
336
+ }
337
+
171
338
  /* --------------------------------------------------- value equality -- */
172
339
 
173
340
  static bool sv_equal(const sch_svalue *a, const sch_svalue *b) {
@@ -239,21 +406,57 @@ static bool sv_equal(const sch_svalue *a, const sch_svalue *b) {
239
406
  static sch_svalue *jv_to_sv(vctx *vc, jv *v);
240
407
  static void val(vctx *vc, sch_node *n, const sch_svalue *v);
241
408
 
409
+ /* trial: does n accept v? Failed trials contribute no errors AND no
410
+ * annotations; successful anyOf/oneOf branches bubble theirs up */
242
411
  static bool passes(vctx *vc, sch_node *n, const sch_svalue *v) {
243
412
  int save_pings = vc->pings;
244
413
  size_t save_n = vc->n;
245
414
  int save_depth = vc->sdepth;
415
+ size_t keys_before = 0, idx_before = 0;
416
+ if (vc->n_frames > 0) {
417
+ keys_before = vc->frames[vc->n_frames - 1].n_keys;
418
+ idx_before = vc->frames[vc->n_frames - 1].n_idx;
419
+ }
246
420
  vc->mute++;
247
421
  val(vc, n, v);
248
422
  vc->mute--;
249
- if (vc->pings == save_pings) {
250
- return true;
423
+ bool ok = vc->pings == save_pings;
424
+ /* the trial's pings were its own private signal: nested oneOf/
425
+ * anyOf/not/if trials legitimately produced some without the
426
+ * branch failing - consume them so an OUTER trial sees only what
427
+ * this branch really contributed */
428
+ vc->pings = save_pings;
429
+ if (!ok) {
430
+ /* discard the trial's errors and its annotations */
431
+ vc->n = save_n;
432
+ if (vc->buf != NULL) vc->buf[vc->n] = '\0';
433
+ vc->sdepth = save_depth;
434
+ frame_truncate_to(vc, keys_before, idx_before);
435
+ }
436
+ return ok;
437
+ }
438
+
439
+ /* not/if trials: the branch runs for the verdict only - its
440
+ * annotations are discarded whether it passed or failed */
441
+ static bool passes_annot_free(vctx *vc, sch_node *n, const sch_svalue *v) {
442
+ int save_pings = vc->pings;
443
+ size_t save_n = vc->n;
444
+ int save_depth = vc->sdepth;
445
+ size_t keys_before = 0, idx_before = 0;
446
+ if (vc->n_frames > 0) {
447
+ keys_before = vc->frames[vc->n_frames - 1].n_keys;
448
+ idx_before = vc->frames[vc->n_frames - 1].n_idx;
251
449
  }
252
- /* discard the trial's errors: rewind the buffer to save_n */
450
+ bool ok;
451
+ vc->mute++;
452
+ ok = (val(vc, n, v), vc->pings == save_pings);
453
+ vc->mute--;
454
+ vc->pings = save_pings; /* consumed: the signal was private */
253
455
  vc->n = save_n;
254
456
  if (vc->buf != NULL) vc->buf[vc->n] = '\0';
255
457
  vc->sdepth = save_depth;
256
- return false;
458
+ frame_truncate_to(vc, keys_before, idx_before);
459
+ return ok;
257
460
  }
258
461
 
259
462
  static size_t cp_count(const char *s, size_t len) {
@@ -271,14 +474,18 @@ static size_t cp_count(const char *s, size_t len) {
271
474
  return count;
272
475
  }
273
476
 
274
- /* RFC 3339 shapes for the TOML datetime kinds live in formats.c; the
275
- * walk only decides whether a kind participates in a format (policy
276
- * 3) and hands plain strings to the format battery */
477
+ /* the TOML-native kind table (tombi's named formats made explicit):
478
+ * an offset datetime satisfies date-time and only date-time; a local
479
+ * datetime satisfies date-time-local; a local time satisfies
480
+ * time-local (TOML has no offset time); a date satisfies date */
277
481
  static bool format_ok(vctx *vc, int format, const sch_svalue *v) {
278
482
  if (format == FMT_NONE) return true;
279
483
  if (v->kind == SV_DATE) return format == FMT_DATE;
280
- if (v->kind == SV_TIME) return format == FMT_TIME;
281
- if (v->kind == SV_DATETIME) return format == FMT_DATETIME;
484
+ if (v->kind == SV_TIME) return format == FMT_TIME_LOCAL;
485
+ if (v->kind == SV_DATETIME) {
486
+ return v->has_offset ? format == FMT_DATETIME
487
+ : format == FMT_DATETIME_LOCAL;
488
+ }
282
489
  if (v->kind != SV_STRING) return format == FMT_NONE;
283
490
  return sch_format_string_check(format, v->str, v->str_len, vc->scratch);
284
491
  }
@@ -312,6 +519,33 @@ static int b64_val(char c) {
312
519
  return -1;
313
520
  }
314
521
 
522
+ /* decode base64 text into the scratch arena; answers the length and
523
+ * NULL when the text is not valid base64 */
524
+ static char *b64_decode(vctx *vc, const char *text, size_t tlen,
525
+ size_t *out_len) {
526
+ if (!str_is_base64(text, tlen)) return NULL;
527
+ size_t dn = tlen / 4 * 3;
528
+ if (tlen > 0 && text[tlen - 1] == '=') dn--;
529
+ if (tlen > 1 && text[tlen - 2] == '=') dn--;
530
+ char *out = teptris_arena_alloc(vc->scratch, dn + 1);
531
+ size_t o = 0;
532
+ int acc = 0, bits = 0;
533
+ for (size_t i = 0; i < tlen && o < dn; i++) {
534
+ if (text[i] == '=') break;
535
+ int d = b64_val(text[i]);
536
+ if (d < 0) break;
537
+ acc = (acc << 6) | d;
538
+ bits += 6;
539
+ if (bits >= 8) {
540
+ bits -= 8;
541
+ out[o++] = (char)((acc >> bits) & 0xFF);
542
+ }
543
+ }
544
+ out[o] = '\0';
545
+ *out_len = o;
546
+ return out;
547
+ }
548
+
315
549
  /* contentEncoding/contentMediaType, the taplo parity pair: base64 is
316
550
  * the one encoding checked (and decoded for the media step),
317
551
  * application/json the one media type parsed; unknown names on either
@@ -328,49 +562,49 @@ static void check_content(vctx *vc, const sch_node *n, const sch_svalue *v) {
328
562
  }
329
563
  if (n->content_media_type == NULL ||
330
564
  strcmp(n->content_media_type, "application/json") != 0) {
565
+ /* no media interpretation: contentSchema sees the decoded
566
+ * text when an encoding was applied, the raw string when not */
567
+ if (n->content_schema != NULL) {
568
+ const char *payload = text;
569
+ size_t plen = tlen;
570
+ char *out = NULL;
571
+ if (b64 && str_is_base64(text, tlen)) {
572
+ out = b64_decode(vc, text, tlen, &plen);
573
+ payload = out;
574
+ }
575
+ if (payload != NULL) {
576
+ sch_svalue sv;
577
+ memset(&sv, 0, sizeof sv);
578
+ sv.kind = SV_STRING;
579
+ sv.str = payload;
580
+ sv.str_len = plen;
581
+ spush(vc, "contentSchema");
582
+ val(vc, n->content_schema, &sv);
583
+ spop(vc);
584
+ }
585
+ }
331
586
  return; /* unknown media names: annotation */
332
587
  }
333
588
  const char *payload = text;
334
589
  size_t plen = tlen;
335
590
  if (b64) {
336
- size_t dn = tlen / 4 * 3;
337
- if (tlen > 0 && text[tlen - 1] == '=') dn--;
338
- if (tlen > 1 && text[tlen - 2] == '=') dn--;
339
- char *out = teptris_arena_alloc(vc->scratch, dn + 1);
340
- size_t o = 0;
341
- int acc = 0, bits = 0;
342
- for (size_t i = 0; i < tlen && o < dn; i++) {
343
- if (text[i] == '=') break;
344
- int d = b64_val(text[i]);
345
- if (d < 0) break;
346
- acc = (acc << 6) | d;
347
- bits += 6;
348
- if (bits >= 8) {
349
- bits -= 8;
350
- out[o++] = (char)((acc >> bits) & 0xFF);
351
- }
352
- }
353
- /* the media check runs on the decoded text only when it is
354
- * UTF-8 (the crate skips the check otherwise) */
355
- bool utf8 = true;
356
- for (size_t i = 0; i < o && utf8; i++) {
357
- unsigned char b = (unsigned char)out[i];
358
- if (b < 0x80) continue;
359
- int need = b < 0xE0 ? 1 : b < 0xF0 ? 2 : 3;
360
- if (i + need >= o || (b & 0xC0) != 0xC0) utf8 = false;
361
- for (int k = 1; k <= need && utf8; k++) {
362
- if (((unsigned char)out[i + k] & 0xC0) != 0x80) utf8 = false;
363
- }
364
- i += need;
365
- }
366
- if (!utf8) return;
367
- out[o] = '\0';
368
- payload = out;
369
- plen = o;
591
+ /* the media check runs on the decoded text only when it
592
+ * decodes (the crate skips the check otherwise) */
593
+ payload = b64_decode(vc, text, tlen, &plen);
594
+ if (payload == NULL) return;
370
595
  }
371
596
  char jerr[64] = {0};
372
- if (json_read(vc->scratch, payload, plen, jerr, sizeof jerr) == NULL) {
597
+ jv *parsed = json_read(vc->scratch, payload, plen, jerr, sizeof jerr);
598
+ if (parsed == NULL) {
373
599
  verr(vc, "string is not valid JSON (contentMediaType)");
600
+ return;
601
+ }
602
+ if (n->content_schema != NULL) {
603
+ /* contentSchema asserts the parsed value (the media type's
604
+ * interpretation of the decoded content) */
605
+ spush(vc, "contentSchema");
606
+ val(vc, n->content_schema, jv_to_sv(vc, parsed));
607
+ spop(vc);
374
608
  }
375
609
  }
376
610
 
@@ -458,6 +692,35 @@ static void val(vctx *vc, sch_node *n, const sch_svalue *v) {
458
692
  return;
459
693
  }
460
694
 
695
+ /* one annotation frame per application; a $dynamicAnchor /
696
+ * $recursiveAnchor on this schema object enters the dynamic
697
+ * scope for the instance path below it */
698
+ frame_push(vc, v);
699
+ int scopes_base = vc->n_scopes;
700
+ scope_push(vc, n->dynamic_anchor, n);
701
+ scope_push(vc, n->recursive_anchor, n);
702
+
703
+ /* a dynamic $ref resolves through the innermost scope entered on
704
+ * the evaluation path; the compile-resolved target is the static
705
+ * fallback */
706
+ if (n->dynamic_ref != NULL) {
707
+ const char *name = n->dynamic_ref[0] == '#' ? n->dynamic_ref + 1
708
+ : n->dynamic_ref;
709
+ sch_node *target = scope_resolve(vc, name);
710
+ if (target == NULL) target = n->dynamic_ref_target;
711
+ if (target != NULL) {
712
+ if (vc->ref_depth >= MAX_DEPTH) {
713
+ verr(vc, "cyclic dynamic $ref recursion");
714
+ } else {
715
+ vc->ref_depth++;
716
+ spush(vc, "$dynamicRef");
717
+ val(vc, target, v);
718
+ spop(vc);
719
+ vc->ref_depth--;
720
+ }
721
+ }
722
+ }
723
+
461
724
  if (n->ref != NULL) {
462
725
  /* a $ref cycle that consumes no document structure (a schema
463
726
  * that is its own ref target) would loop forever; legal
@@ -475,6 +738,8 @@ static void val(vctx *vc, sch_node *n, const sch_svalue *v) {
475
738
 
476
739
  if (n->is_false) {
477
740
  verr(vc, "no value is allowed here (the false schema)");
741
+ vc->n_scopes = scopes_base;
742
+ frame_pop(vc);
478
743
  return;
479
744
  }
480
745
 
@@ -594,7 +859,9 @@ static void val(vctx *vc, sch_node *n, const sch_svalue *v) {
594
859
  matched_known = true;
595
860
  spush_named(vc, "properties", key);
596
861
  path_push(vc, key);
862
+ int p0 = vc->pings;
597
863
  val(vc, n->props[p].schema, mv);
864
+ if (vc->pings == p0) frame_add_key(vc, key);
598
865
  path_pop(vc);
599
866
  spop(vc);
600
867
  break;
@@ -606,7 +873,9 @@ static void val(vctx *vc, sch_node *n, const sch_svalue *v) {
606
873
  matched_known = true;
607
874
  spush(vc, "patternProperties");
608
875
  path_push(vc, key);
876
+ int p0 = vc->pings;
609
877
  val(vc, n->pprops[p].schema, mv);
878
+ if (vc->pings == p0) frame_add_key(vc, key);
610
879
  path_pop(vc);
611
880
  spop(vc);
612
881
  }
@@ -618,7 +887,9 @@ static void val(vctx *vc, sch_node *n, const sch_svalue *v) {
618
887
  verr(vc, "unknown property '%s' (additionalProperties is false)",
619
888
  key);
620
889
  } else {
890
+ int p0 = vc->pings;
621
891
  val(vc, n->additional, mv);
892
+ if (vc->pings == p0) frame_add_key(vc, key);
622
893
  }
623
894
  path_pop(vc);
624
895
  spop(vc);
@@ -697,13 +968,17 @@ static void val(vctx *vc, sch_node *n, const sch_svalue *v) {
697
968
  if (i < n->n_prefix) {
698
969
  spush(vc, "prefixItems");
699
970
  path_push_idx(vc, (long)i);
971
+ int p0 = vc->pings;
700
972
  val(vc, n->prefix[i], v->items[i]);
973
+ if (vc->pings == p0) frame_add_idx(vc, i);
701
974
  path_pop(vc);
702
975
  spop(vc);
703
976
  } else if (n->items != NULL) {
704
977
  spush(vc, "items");
705
978
  path_push_idx(vc, (long)i);
979
+ int p0 = vc->pings;
706
980
  val(vc, n->items, v->items[i]);
981
+ if (vc->pings == p0) frame_add_idx(vc, i);
707
982
  path_pop(vc);
708
983
  spop(vc);
709
984
  } else if (n->add_items != NULL) {
@@ -713,7 +988,9 @@ static void val(vctx *vc, sch_node *n, const sch_svalue *v) {
713
988
  verr(vc, "array has items beyond the tuple "
714
989
  "(additionalItems is false)");
715
990
  } else {
991
+ int p0 = vc->pings;
716
992
  val(vc, n->add_items, v->items[i]);
993
+ if (vc->pings == p0) frame_add_idx(vc, i);
717
994
  }
718
995
  path_pop(vc);
719
996
  spop(vc);
@@ -728,7 +1005,9 @@ static void val(vctx *vc, sch_node *n, const sch_svalue *v) {
728
1005
  verr(vc, "array has items beyond the tuple "
729
1006
  "(additionalItems is false)");
730
1007
  } else {
1008
+ int p0 = vc->pings;
731
1009
  val(vc, n->add_items, v->items[i]);
1010
+ if (vc->pings == p0) frame_add_idx(vc, i);
732
1011
  }
733
1012
  path_pop(vc);
734
1013
  spop(vc);
@@ -737,12 +1016,22 @@ static void val(vctx *vc, sch_node *n, const sch_svalue *v) {
737
1016
  if (n->has_contains && n->contains != NULL) {
738
1017
  long hits = 0;
739
1018
  for (size_t i = 0; i < v->n_items; i++) {
740
- if (passes(vc, n->contains, v->items[i])) hits++;
1019
+ if (passes(vc, n->contains, v->items[i])) {
1020
+ hits++;
1021
+ }
741
1022
  }
742
1023
  long min = n->has_min_contains ? n->min_contains : 1;
743
1024
  long max = n->has_max_contains ? n->max_contains : (long)v->n_items;
744
1025
  if (hits < min) verr(vc, "fewer matching items than minContains");
745
1026
  if (hits > max) verr(vc, "more matching items than maxContains");
1027
+ /* a successful contains annotates the matching indices */
1028
+ if (hits >= min && hits <= max) {
1029
+ for (size_t i = 0; i < v->n_items; i++) {
1030
+ if (passes(vc, n->contains, v->items[i])) {
1031
+ frame_add_idx(vc, i);
1032
+ }
1033
+ }
1034
+ }
746
1035
  }
747
1036
  }
748
1037
 
@@ -756,7 +1045,9 @@ static void val(vctx *vc, sch_node *n, const sch_svalue *v) {
756
1045
  }
757
1046
  if (n->n_any > 0) {
758
1047
  bool ok = false;
759
- for (size_t i = 0; i < n->n_any && !ok; i++) {
1048
+ /* every branch is tried: a successful branch's annotations
1049
+ * bubble up even when an earlier branch already passed */
1050
+ for (size_t i = 0; i < n->n_any; i++) {
760
1051
  if (passes(vc, n->any_of[i], v)) ok = true;
761
1052
  }
762
1053
  if (!ok) verr(vc, "does not match any of the %zu anyOf schemas",
@@ -773,11 +1064,13 @@ static void val(vctx *vc, sch_node *n, const sch_svalue *v) {
773
1064
  }
774
1065
  }
775
1066
  if (n->_not != NULL) {
776
- if (passes(vc, n->_not, v)) {
1067
+ if (passes_annot_free(vc, n->_not, v)) {
777
1068
  verr(vc, "must not match the not-schema");
778
1069
  }
779
1070
  }
780
1071
  if (n->if_s != NULL) {
1072
+ /* the if-trial's annotations are retained (the suite: an if
1073
+ * without then/else still evaluates what it matched) */
781
1074
  bool cond = passes(vc, n->if_s, v);
782
1075
  if (cond && n->then_s != NULL) {
783
1076
  spush(vc, "then");
@@ -789,6 +1082,49 @@ static void val(vctx *vc, sch_node *n, const sch_svalue *v) {
789
1082
  spop(vc);
790
1083
  }
791
1084
  }
1085
+
1086
+ /* unevaluatedProperties/Items: evaluated LAST against this
1087
+ * application's own frame (adjacent keywords plus what bubbled
1088
+ * up through in-place applicators); what they apply to then
1089
+ * annotates the frame for any enclosing unevaluated* */
1090
+ if (n->uneval_props != NULL && v->kind == SV_TABLE) {
1091
+ struct eval_frame *f = &vc->frames[vc->n_frames - 1];
1092
+ for (size_t m = 0; m < v->n_members; m++) {
1093
+ const char *key = v->members[m].key;
1094
+ if (frame_key_seen(f, key)) continue;
1095
+ spush(vc, "unevaluatedProperties");
1096
+ path_push(vc, key);
1097
+ if (n->uneval_props->is_false) {
1098
+ verr(vc, "unevaluated property '%s' is not allowed", key);
1099
+ } else {
1100
+ int p0 = vc->pings;
1101
+ val(vc, n->uneval_props, v->members[m].val);
1102
+ if (vc->pings == p0) frame_add_key(vc, key);
1103
+ }
1104
+ path_pop(vc);
1105
+ spop(vc);
1106
+ }
1107
+ }
1108
+ if (n->uneval_items != NULL && v->kind == SV_ARRAY) {
1109
+ struct eval_frame *f = &vc->frames[vc->n_frames - 1];
1110
+ for (size_t i = 0; i < v->n_items; i++) {
1111
+ if (frame_idx_seen(f, i)) continue;
1112
+ spush(vc, "unevaluatedItems");
1113
+ path_push_idx(vc, (long)i);
1114
+ if (n->uneval_items->is_false) {
1115
+ verr(vc, "array has an unevaluated item at index %zu", i);
1116
+ } else {
1117
+ int p0 = vc->pings;
1118
+ val(vc, n->uneval_items, v->items[i]);
1119
+ if (vc->pings == p0) frame_add_idx(vc, i);
1120
+ }
1121
+ path_pop(vc);
1122
+ spop(vc);
1123
+ }
1124
+ }
1125
+
1126
+ vc->n_scopes = scopes_base;
1127
+ frame_pop(vc);
792
1128
  }
793
1129
 
794
1130
  /* -------------------------------------------------- DOM conversion -- */
@@ -833,6 +1169,7 @@ static sch_svalue *node_to_sv(teptris_arena *scratch, const teptris_node *node)
833
1169
  sch_svalue *v = sv_new(scratch, SV_DATETIME);
834
1170
  teptris_datetime dt;
835
1171
  teptris_node_datetime(node, &dt);
1172
+ v->has_offset = kind == TEPTRIS_DATETIME_OFFSET;
836
1173
  /* the RFC 3339 text: equality + format checks run on the
837
1174
  * canonical text the emitter would produce */
838
1175
  char *buf = teptris_arena_alloc(scratch, 64);
@@ -1012,6 +1349,8 @@ TEPTRIS_API teptris_status teptris_schema_validate_doc(
1012
1349
  *out_len = out_n;
1013
1350
  }
1014
1351
  if (vc.buf != NULL) free(vc.buf);
1352
+ frames_free(&vc);
1353
+ free(vc.scopes);
1015
1354
  teptris_arena_destroy(&scratch);
1016
1355
  return st;
1017
1356
  }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Teptris
4
- VERSION = "0.3.21.0"
4
+ VERSION = "0.3.22.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: teptris
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.21.0
4
+ version: 0.3.22.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - teptris contributors