yeptris 0.6.26.2-arm-linux-eabihf → 0.6.28.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.
@@ -30,6 +30,7 @@ extern "C" {
30
30
  #endif
31
31
 
32
32
  typedef struct yep_pool yep_pool;
33
+ struct yep_resolver;
33
34
 
34
35
  typedef struct yep_ytape {
35
36
  uint64_t* w;
@@ -42,7 +43,10 @@ typedef struct yep_ytape {
42
43
  int flow_strict; /* mirrors dom->flow_strict (0 everywhere today) */
43
44
  int docs; /* DOCUMENT_START count (the empty-stream check) */
44
45
  int oom;
45
- uint32_t flow_mark; /* record mark for the staged flow build */
46
+ uint32_t flow_mark; /* record mark for the staged flow build */
47
+ struct yep_pool* pool; /* fused block-scalar content (owned by the doc
48
+ * after a successful run; NULL on the engine route) */
49
+ void* flow_scratch; /* the flow classifier's reused json-tape scratch */
46
50
  } yep_ytape;
47
51
 
48
52
  /* Record kinds — byte 7 of a word. */
@@ -62,6 +66,21 @@ enum {
62
66
  /* Recorder lifecycle. Returns 0, or -1 when the word carve fails
63
67
  * (caller answers YEPTRIS_ERROR_MEMORY — bounded-parse law). */
64
68
  int ytap_init(yep_ytape* t, const char* input, size_t len, int max_depth);
69
+
70
+ /* The fused block runner (TODO.restructure/79): ONE sweep per line
71
+ * emitting the same records the engine's sink would. Returns 0 when
72
+ * the document was fully owned; 1 on any bail (the caller resets the
73
+ * tape and runs the engine route). */
74
+ int ytap_fused_run(yep_ytape* t, const struct yep_resolver* resolver);
75
+
76
+ /* The flow-rooted fast path: a document that is exactly one flow
77
+ * collection plus whitespace takes the classification directly —
78
+ * the block runner and the engine never run. Returns 0 when owned;
79
+ * 1 on any fallback. */
80
+ int ytap_flow_rooted(yep_ytape* t);
81
+
82
+ /* Rewind a bailed tape for the engine re-run. */
83
+ void ytap_reset(yep_ytape* t);
65
84
  void ytap_sink(yep_ytape* t, yep_sink* sink);
66
85
  void ytap_free(yep_ytape* t);
67
86
 
@@ -156,7 +156,7 @@ YEPTRIS_API YeptrisDocument yeptris_parse_json(const char* buf, size_t len, Yept
156
156
  st = YEPTRIS_ERROR_MEMORY;
157
157
  goto jfail;
158
158
  }
159
- if (yep_tape_walk_lenient_fused(buf, len, off, t, 1, 1) == YEPTRIS_OK) {
159
+ if (yep_tape_walk_lenient_fused(buf, len, off, t, 1, 1, 0) == YEPTRIS_OK) {
160
160
  /* strict_nums=1: the arms validated the numbers at
161
161
  * record time — the settle pass is gone (the profile's
162
162
  * 10% lane; the spans were cache-warm in the walk) */
@@ -402,7 +402,27 @@ engine_enter:
402
402
  .on_block_open = dom_on_block_open,
403
403
  .on_block_item = dom_on_block_item};
404
404
  }
405
- int rc = yep_engine_run(eng, data, data_len, &sink);
405
+ int rc = 0;
406
+ if (have_tape && ytap_flow_rooted(&yt) == 0) {
407
+ /* a pure flow-rooted document: the classification ran once and
408
+ * the scaffolding landed — neither runner nor engine runs */
409
+ yep_engine_destroy(eng);
410
+ eng = NULL;
411
+ } else if (have_tape &&
412
+ ytap_fused_run(&yt, (opts != NULL && opts->schema == YEPTRIS_SCHEMA_11_COMPAT)
413
+ ? yep_resolver_compat11()
414
+ : yep_resolver_core12()) == 0) {
415
+ /* the fused block runner owned the whole document — the engine
416
+ * never runs (TODO.restructure/79). Its only cost was the parse
417
+ * front-end above; on a bail it unwound and the engine runs. */
418
+ yep_engine_destroy(eng);
419
+ eng = NULL;
420
+ } else {
421
+ if (have_tape) {
422
+ ytap_reset(&yt);
423
+ }
424
+ rc = yep_engine_run(eng, data, data_len, &sink);
425
+ }
406
426
  if (rc != 0) {
407
427
  const yep_error* ee = yep_engine_error(eng);
408
428
  yep_err_code code = ee ? ee->code : YEP_ERR_UNEXPECTED;
@@ -479,6 +499,10 @@ engine_enter:
479
499
  goto fail;
480
500
  }
481
501
  *heap_tape = yt;
502
+ if (yt.pool != NULL && doc->finish_pool == NULL) {
503
+ doc->finish_pool = yt.pool; /* fused block-scalar content: the
504
+ * document owns it until replay copies */
505
+ }
482
506
  doc->dom = NULL;
483
507
  doc->lazy_tape = heap_tape;
484
508
  doc->lazy_kind = 1;
@@ -277,8 +277,8 @@ int yep_json_number_scan(const char* p, size_t len, size_t* i, int* is_float, in
277
277
  /* no more digits and not a float/exponent — settle */
278
278
  if (end < len) {
279
279
  char c = p[end];
280
- if (c != ' ' && c != '\n' && c != '\r' && c != ',' && c != ']' && c != '}' &&
281
- c != ':') {
280
+ if (c != ' ' && c != '\t' && c != '\n' && c != '\r' && c != ',' && c != ']' &&
281
+ c != '}' && c != ':') {
282
282
  return 0; /* "1x" is YAML, not JSON */
283
283
  }
284
284
  }
@@ -299,8 +299,8 @@ int yep_json_number_scan(const char* p, size_t len, size_t* i, int* is_float, in
299
299
  (p[end] < '0' || p[end] > '9'))) {
300
300
  if (end < len) {
301
301
  char c = p[end];
302
- if (c != ' ' && c != '\n' && c != '\r' && c != ',' && c != ']' && c != '}' &&
303
- c != ':') {
302
+ if (c != ' ' && c != '\t' && c != '\n' && c != '\r' && c != ',' && c != ']' &&
303
+ c != '}' && c != ':') {
304
304
  return 0;
305
305
  }
306
306
  }
@@ -387,7 +387,8 @@ int yep_json_number_scan(const char* p, size_t len, size_t* i, int* is_float, in
387
387
  }
388
388
  if (k < len) {
389
389
  char c = p[k];
390
- if (c != ' ' && c != '\n' && c != '\r' && c != ',' && c != ']' && c != '}' && c != ':') {
390
+ if (c != ' ' && c != '\t' && c != '\n' && c != '\r' && c != ',' && c != ']' && c != '}' &&
391
+ c != ':') {
391
392
  return 0; /* "1x" is YAML, not JSON */
392
393
  }
393
394
  }
@@ -477,7 +478,8 @@ int yep_json_number_shape(const char* p, size_t len, size_t* i, int* is_float) {
477
478
  }
478
479
  if (k < len) {
479
480
  char c = p[k];
480
- if (c != ' ' && c != '\n' && c != '\r' && c != ',' && c != ']' && c != '}' && c != ':') {
481
+ if (c != ' ' && c != '\t' && c != '\n' && c != '\r' && c != ',' && c != ']' && c != '}' &&
482
+ c != ':') {
481
483
  return 0; /* "1x" is YAML, not JSON */
482
484
  }
483
485
  }
@@ -497,7 +499,8 @@ int yep_json_literal(const char* p, size_t len, size_t* i, const char* word) {
497
499
  *i += w;
498
500
  if (*i < len) {
499
501
  char c = p[*i];
500
- if (c != ' ' && c != '\n' && c != '\r' && c != ',' && c != ']' && c != '}' && c != ':') {
502
+ if (c != ' ' && c != '\t' && c != '\n' && c != '\r' && c != ',' && c != ']' && c != '}' &&
503
+ c != ':') {
501
504
  return 0; /* "truex" is a YAML plain, not JSON */
502
505
  }
503
506
  }