yeptris 0.6.75.0-arm-linux-eabihf → 0.6.76.0-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.3/native.so +0 -0
- data/lib/yeptris/psych/drop_in.rb +11 -1
- data/lib/yeptris.rb +1 -1
- data/libyeptris.so +0 -0
- data/vendor/libyeptris/CMakeLists.txt +1 -1
- data/vendor/libyeptris/src/yeptris/cbor/decode.c +3 -1
- data/vendor/libyeptris/src/yeptris/doc.h +5 -0
- data/vendor/libyeptris/src/yeptris/dom/dom.h +9 -0
- data/vendor/libyeptris/src/yeptris/emit/emit.c +8 -0
- data/vendor/libyeptris/src/yeptris/emit/writer.c +278 -17
- data/vendor/libyeptris/src/yeptris/emit/writer.h +10 -0
- data/vendor/libyeptris/src/yeptris/marshal/to_json.c +3 -0
- data/vendor/libyeptris/src/yeptris/parse.c +35 -3
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b3f9d48a8908d8a0aa4f647d8cd29ef272eb013afaafb73eeb162e21216444bb
|
|
4
|
+
data.tar.gz: 2fa76a23db1faac4b0e114870fa6f8d3be287aeda1f66462047b5f6b70e4813c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 793742c1dfa3e997f33f492c77f019fd19e37359b76a6eca2d05236a64a73d21d13f8a93d2981f6539b9760448d412b54e7707f0c72233f54aa8a50d2d2ce82e
|
|
7
|
+
data.tar.gz: d904832c93cfb2f0bc474e9bd32ebeb4fb084019959ec994b7a84b1f5968b4b7901450c4034a366cbee96e7b831a4153a8a1368cea02f5ce5ca16590a198d727
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
|
|
12
12
|
#define YEPTRIS_VERSION_MAJOR 0
|
|
13
13
|
#define YEPTRIS_VERSION_MINOR 6
|
|
14
|
-
#define YEPTRIS_VERSION_PATCH
|
|
15
|
-
#define YEPTRIS_VERSION_STRING "0.6.
|
|
14
|
+
#define YEPTRIS_VERSION_PATCH 76
|
|
15
|
+
#define YEPTRIS_VERSION_STRING "0.6.76"
|
|
16
16
|
|
|
17
17
|
#ifdef __cplusplus
|
|
18
18
|
extern "C" {
|
data/lib/yeptris/3.3/native.so
CHANGED
|
Binary file
|
|
@@ -27,9 +27,19 @@ Object.class_eval { remove_const(:Psych) } if defined?(::Psych) && !::Psych.equa
|
|
|
27
27
|
# face reports the STDLIB version it replaces: ORIGINAL's when psych
|
|
28
28
|
# was preloaded, else the default-gem spec's version (local lookup —
|
|
29
29
|
# requiring stdlib psych post-rebind is censored by the header).
|
|
30
|
+
# ORIGINAL is guarded before the read: the ::Psych captured by the
|
|
31
|
+
# rebind can sit WITHOUT a VERSION constant — the windows CI children
|
|
32
|
+
# hit a boot that defines the name first with a bare module (the
|
|
33
|
+
# bundler-setup boot path on the runner), and the blind ORIGINAL
|
|
34
|
+
# read raised NameError at drop-in require time (run 44698420284,
|
|
35
|
+
# psych_compat_spec:111 + psych/version_spec:15). A VERSION-less
|
|
36
|
+
# ORIGINAL reports through the same default-gem spec lookup the
|
|
37
|
+
# not-preloaded path uses — the honest version for the psych the
|
|
38
|
+
# boot had half-formed.
|
|
30
39
|
unless Yeptris::Psych.const_defined?(:VERSION, false)
|
|
31
40
|
version =
|
|
32
|
-
if Yeptris::Psych.const_defined?(:ORIGINAL, false)
|
|
41
|
+
if Yeptris::Psych.const_defined?(:ORIGINAL, false) &&
|
|
42
|
+
Yeptris::Psych::ORIGINAL.const_defined?(:VERSION)
|
|
33
43
|
Yeptris::Psych::ORIGINAL::VERSION
|
|
34
44
|
else
|
|
35
45
|
spec = begin
|
data/lib/yeptris.rb
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
module Yeptris
|
|
4
4
|
# The gem's version lives in the parent namespace's file — the last
|
|
5
5
|
# internal require (yeptris/version) retired with it.
|
|
6
|
-
VERSION = "0.6.
|
|
6
|
+
VERSION = "0.6.76.0".freeze
|
|
7
7
|
|
|
8
8
|
# Informational notices are OPT-IN (yeptris-ruby#217): consumers
|
|
9
9
|
# embed yeptris inside CLIs that assert clean stderr, and a
|
data/libyeptris.so
CHANGED
|
Binary file
|
|
@@ -954,6 +954,7 @@ static YeptrisDocument cbor_wrap(yep_dom* dom, const void* buf, const yep_alloca
|
|
|
954
954
|
d->finish_pool = NULL;
|
|
955
955
|
d->lazy_tape = NULL; /* field-by-field ctor: no garbage for free */
|
|
956
956
|
d->lazy_kind = 0;
|
|
957
|
+
d->lazy_input_ascii = 0; /* #1490: CBOR doms keep the gates armed */
|
|
957
958
|
return (YeptrisDocument)d;
|
|
958
959
|
}
|
|
959
960
|
|
|
@@ -1060,7 +1061,8 @@ YEPTRIS_API YeptrisDocument yeptris_cbor_decode(const void* buf, size_t len, uin
|
|
|
1060
1061
|
doc->transcoded_len = 0;
|
|
1061
1062
|
doc->input = (const char*)buf;
|
|
1062
1063
|
doc->finish_pool = NULL;
|
|
1063
|
-
doc->lazy_tape = NULL;
|
|
1064
|
+
doc->lazy_tape = NULL; /* field-by-field ctor: no garbage for free */
|
|
1065
|
+
doc->lazy_input_ascii = 0; /* #1490: CBOR doms keep the gates armed */
|
|
1064
1066
|
if (status != NULL) {
|
|
1065
1067
|
*status = YEPTRIS_OK;
|
|
1066
1068
|
}
|
|
@@ -40,6 +40,11 @@ typedef struct yeptris_document {
|
|
|
40
40
|
* wait (read-only sharing stays lock-free
|
|
41
41
|
* once dom is set — every constructor must
|
|
42
42
|
* yep_mutex_init it, the ctor trap) */
|
|
43
|
+
int lazy_input_ascii; /* #1490: the parse's column fact for the
|
|
44
|
+
* lazy tape, handed to the dom at
|
|
45
|
+
* materialization (parse.c's encoding gate).
|
|
46
|
+
* Every constructor must set it (0 =
|
|
47
|
+
* conservative, like the ctor trap above). */
|
|
43
48
|
} yeptris_document;
|
|
44
49
|
|
|
45
50
|
/* Node handle: a (document, node-id) pair so nodes stay usable even if
|
|
@@ -161,6 +161,15 @@ typedef struct yep_dom {
|
|
|
161
161
|
int map_pending_key[YEP_DOM_MAX_DEPTH]; /* per-frame: key seen, value next */
|
|
162
162
|
uint32_t pending_key_id[YEP_DOM_MAX_DEPTH];
|
|
163
163
|
uint32_t pending_key;
|
|
164
|
+
/* #1490's emitter column fact, derived at parse: 1 = the encoding
|
|
165
|
+
* gate proved every input byte gate-safe (< 0x80) and no
|
|
166
|
+
* transcode/normalize copy ran, so input-region views are pure
|
|
167
|
+
* ASCII and the emitter's columns are byte counts. The arena region
|
|
168
|
+
* (decoded/copied strings) is NOT covered — the writer still scans
|
|
169
|
+
* it once per run. LAST FIELD ON PURPOSE: the hot fields above keep
|
|
170
|
+
* their layout. Defaults to 0 (conservative: per-span gates) via
|
|
171
|
+
* yep_dom_create's memset; builder/schema routes stay 0. */
|
|
172
|
+
int input_ascii;
|
|
164
173
|
} yep_dom;
|
|
165
174
|
|
|
166
175
|
/* Decodes to the pointer view callers use (defined after yep_dom).
|
|
@@ -130,6 +130,7 @@ YEPTRIS_API size_t yeptris_serialize_into_ex(YeptrisDocument handle,
|
|
|
130
130
|
em.w.col = 0;
|
|
131
131
|
em.w.sv_input = handle ? ((const yeptris_document*)handle)->dom->input_base : NULL;
|
|
132
132
|
em.w.sv_arena = handle ? ((const yeptris_document*)handle)->dom->str : NULL;
|
|
133
|
+
em.w.doc_ascii = -1; /* #1490: derived once in yep_emit_run */
|
|
133
134
|
em.w.resolver = handle ? ((const yeptris_document*)handle)->dom->resolver : NULL;
|
|
134
135
|
em.w.sink = NULL;
|
|
135
136
|
em.w.watermark = 0;
|
|
@@ -200,6 +201,7 @@ YEPTRIS_API size_t yeptris_serialize_into_trusted(YeptrisDocument handle,
|
|
|
200
201
|
em.w.col = 0;
|
|
201
202
|
em.w.sv_input = ((const yeptris_document*)handle)->dom->input_base;
|
|
202
203
|
em.w.sv_arena = ((const yeptris_document*)handle)->dom->str;
|
|
204
|
+
em.w.doc_ascii = -1; /* #1490: derived once in yep_emit_run */
|
|
203
205
|
em.w.resolver = ((const yeptris_document*)handle)->dom->resolver;
|
|
204
206
|
em.w.sink = NULL;
|
|
205
207
|
em.w.watermark = 0;
|
|
@@ -269,6 +271,7 @@ YEPTRIS_API char* yeptris_serialize_ex(YeptrisDocument handle, const yeptris_emi
|
|
|
269
271
|
em.w.col = 0;
|
|
270
272
|
em.w.sv_input = handle ? ((const yeptris_document*)handle)->dom->input_base : NULL;
|
|
271
273
|
em.w.sv_arena = handle ? ((const yeptris_document*)handle)->dom->str : NULL;
|
|
274
|
+
em.w.doc_ascii = -1; /* #1490: derived once in yep_emit_run */
|
|
272
275
|
em.w.resolver = handle ? ((const yeptris_document*)handle)->dom->resolver : NULL;
|
|
273
276
|
em.w.sink = NULL;
|
|
274
277
|
em.w.watermark = 0;
|
|
@@ -411,6 +414,7 @@ YEPTRIS_API char* yeptris_serialize_json(YeptrisDocument handle, size_t* len) {
|
|
|
411
414
|
em.w.col = 0;
|
|
412
415
|
em.w.sv_input = handle ? ((const yeptris_document*)handle)->dom->input_base : NULL;
|
|
413
416
|
em.w.sv_arena = handle ? ((const yeptris_document*)handle)->dom->str : NULL;
|
|
417
|
+
em.w.doc_ascii = -1; /* #1490: derived once in yep_emit_run */
|
|
414
418
|
em.w.resolver = handle ? ((const yeptris_document*)handle)->dom->resolver : NULL;
|
|
415
419
|
em.w.sink = NULL;
|
|
416
420
|
em.w.watermark = 0;
|
|
@@ -456,6 +460,7 @@ YEPTRIS_API char* yeptris_serialize_json_ex(YeptrisDocument handle, size_t* len,
|
|
|
456
460
|
em.w.col = 0;
|
|
457
461
|
em.w.sv_input = handle ? ((const yeptris_document*)handle)->dom->input_base : NULL;
|
|
458
462
|
em.w.sv_arena = handle ? ((const yeptris_document*)handle)->dom->str : NULL;
|
|
463
|
+
em.w.doc_ascii = -1; /* #1490: derived once in yep_emit_run */
|
|
459
464
|
em.w.resolver = handle ? ((const yeptris_document*)handle)->dom->resolver : NULL;
|
|
460
465
|
em.w.sink = NULL;
|
|
461
466
|
em.w.watermark = 0;
|
|
@@ -503,6 +508,7 @@ char* yep_serialize_json_compact(const yeptris_document* doc, size_t* len) {
|
|
|
503
508
|
em.w.col = 0;
|
|
504
509
|
em.w.sv_input = doc->dom->input_base;
|
|
505
510
|
em.w.sv_arena = doc->dom->str;
|
|
511
|
+
em.w.doc_ascii = -1; /* #1490: derived once in yep_emit_run */
|
|
506
512
|
em.w.resolver = doc->dom->resolver;
|
|
507
513
|
em.w.sink = NULL;
|
|
508
514
|
em.w.watermark = 0;
|
|
@@ -552,6 +558,7 @@ char* yep_serialize_json_pretty_ex(const yeptris_document* doc, size_t* len, con
|
|
|
552
558
|
em.w.col = 0;
|
|
553
559
|
em.w.sv_input = doc->dom->input_base;
|
|
554
560
|
em.w.sv_arena = doc->dom->str;
|
|
561
|
+
em.w.doc_ascii = -1; /* #1490: derived once in yep_emit_run */
|
|
555
562
|
em.w.resolver = doc->dom->resolver;
|
|
556
563
|
em.w.sink = NULL;
|
|
557
564
|
em.w.watermark = 0;
|
|
@@ -629,6 +636,7 @@ YEPTRIS_API size_t yeptris_serialize_stream(YeptrisDocument handle,
|
|
|
629
636
|
em.w.col = 0;
|
|
630
637
|
em.w.sv_input = handle ? ((const yeptris_document*)handle)->dom->input_base : NULL;
|
|
631
638
|
em.w.sv_arena = handle ? ((const yeptris_document*)handle)->dom->str : NULL;
|
|
639
|
+
em.w.doc_ascii = -1; /* #1490: derived once in yep_emit_run */
|
|
632
640
|
em.w.resolver = handle ? ((const yeptris_document*)handle)->dom->resolver : NULL;
|
|
633
641
|
em.w.sink = sink;
|
|
634
642
|
em.w.sink_ctx = ctx;
|
|
@@ -60,17 +60,65 @@ static void wr_maybe_flush(yep_writer* w) {
|
|
|
60
60
|
/* the write primitives below are writer.h-visible: the marshal reader
|
|
61
61
|
* (marshal/to_json.c) writes through the same engine (#904 item 5's
|
|
62
62
|
* move kept ONE writer). */
|
|
63
|
+
|
|
64
|
+
/* The out-of-line gate on the #1490 helpers: inlined, the purity scans
|
|
65
|
+
* bloated every hot caller's frame (the auto-vectorizer spills). MSVC
|
|
66
|
+
* has no GNU attributes — __declspec(noinline) is the same switch
|
|
67
|
+
* (port.h's popcount/ctz branches are the idiom). */
|
|
68
|
+
#if defined(_MSC_VER) && !defined(__clang__)
|
|
69
|
+
#define WR_NOINLINE __declspec(noinline)
|
|
70
|
+
#elif defined(__GNUC__)
|
|
71
|
+
#define WR_NOINLINE __attribute__((noinline))
|
|
72
|
+
#else
|
|
73
|
+
#define WR_NOINLINE
|
|
74
|
+
#endif
|
|
75
|
+
|
|
76
|
+
/* The column is in CHARACTERS (code points) wherever a span carries
|
|
77
|
+
* multi-byte text (#1490: libyaml's emitter->column counts characters);
|
|
78
|
+
* a UTF-8 continuation byte (10xxxxxx) adds nothing. */
|
|
79
|
+
static inline int wr_char_cols(const char* p, uint32_t n) {
|
|
80
|
+
int cols = 0;
|
|
81
|
+
for (uint32_t i = 0; i < n; i++) {
|
|
82
|
+
cols += ((unsigned char)p[i] & 0xC0u) != 0x80u;
|
|
83
|
+
}
|
|
84
|
+
return cols;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
static void WR_NOINLINE wr_col_update_mb(yep_writer* w, const char* p, uint32_t n);
|
|
88
|
+
|
|
63
89
|
void wr_col_update(yep_writer* w, const char* p, uint32_t n) {
|
|
64
90
|
if (w->skip_col) {
|
|
65
91
|
return; /* the non-pretty JSON lanes never read col (#739) */
|
|
66
92
|
}
|
|
93
|
+
if (w->doc_ascii == 1) { /* the run's purity fact: bytes are columns */
|
|
94
|
+
for (uint32_t i = n; i > 0; i--) { /* last newline wins */
|
|
95
|
+
if (p[i - 1] == '\n') {
|
|
96
|
+
w->col = (int)(n - i);
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
w->col += (int)n;
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
wr_col_update_mb(w, p, n);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/* The dirty-document twin: the same backward pass, OR-riding the
|
|
107
|
+
* bytes' high bits — purity falls out of the scan the newline search
|
|
108
|
+
* already is (no second pass). Out of line ON PURPOSE: inlined into
|
|
109
|
+
* wr_put, the dual loop re-bloated the hot frame and the walk lanes
|
|
110
|
+
* paid it per scalar (the #1490 restoration's measured lesson). */
|
|
111
|
+
static void WR_NOINLINE wr_col_update_mb(yep_writer* w, const char* p, uint32_t n) {
|
|
112
|
+
unsigned hi = 0;
|
|
67
113
|
for (uint32_t i = n; i > 0; i--) { /* last newline wins */
|
|
68
|
-
|
|
69
|
-
|
|
114
|
+
unsigned char c = (unsigned char)p[i - 1];
|
|
115
|
+
hi |= c;
|
|
116
|
+
if (c == '\n') {
|
|
117
|
+
w->col = (hi & 0x80u) ? wr_char_cols(p + i, n - i) : (int)(n - i);
|
|
70
118
|
return;
|
|
71
119
|
}
|
|
72
120
|
}
|
|
73
|
-
w->col += (int)n;
|
|
121
|
+
w->col += (hi & 0x80u) ? wr_char_cols(p, n) : (int)n;
|
|
74
122
|
}
|
|
75
123
|
|
|
76
124
|
void wr_reserve(yep_writer* w, size_t need);
|
|
@@ -199,8 +247,10 @@ void wr_byte(yep_writer* w, char c) {
|
|
|
199
247
|
if (!w->skip_col) {
|
|
200
248
|
if (c == '\n') {
|
|
201
249
|
w->col = 0;
|
|
202
|
-
} else {
|
|
250
|
+
} else if (w->doc_ascii == 1) {
|
|
203
251
|
w->col++;
|
|
252
|
+
} else {
|
|
253
|
+
w->col += ((unsigned char)c >> 6) != 2u;
|
|
204
254
|
}
|
|
205
255
|
}
|
|
206
256
|
if (w->dry) {
|
|
@@ -369,6 +419,57 @@ static void emit_sq(yep_writer* w, const char* p, uint32_t n) {
|
|
|
369
419
|
wr_byte(w, '\'');
|
|
370
420
|
}
|
|
371
421
|
|
|
422
|
+
/* 1 iff EVERY byte of [p, p+n) is ASCII (< 0x80): the per-span purity
|
|
423
|
+
* gate for dirty documents (the doc-level fact covers clean ones).
|
|
424
|
+
* SWAR: eight bytes OR'd per step, the high bits inspected once.
|
|
425
|
+
* OUT OF LINE ON PURPOSE: inlined, the auto-vectorizer turned this
|
|
426
|
+
* reduction into a NEON block that dragged ten callee-saved vector
|
|
427
|
+
* registers into every caller's prologue — the fold walks paid the
|
|
428
|
+
* spill/cleanup per scalar (the -6% the lanes caught). A real call per
|
|
429
|
+
* span on the dirty paths is cheaper than the prologue everywhere. */
|
|
430
|
+
static int WR_NOINLINE wr_span_ascii(const char* p, uint32_t n) {
|
|
431
|
+
uint32_t i = 0;
|
|
432
|
+
uint64_t acc = 0;
|
|
433
|
+
for (; i + 8 <= n; i += 8) {
|
|
434
|
+
uint64_t x;
|
|
435
|
+
memcpy(&x, p + i, 8);
|
|
436
|
+
acc |= x;
|
|
437
|
+
}
|
|
438
|
+
for (; i < n; i++) {
|
|
439
|
+
acc |= (unsigned char)p[i];
|
|
440
|
+
}
|
|
441
|
+
return (acc & YEP_SWAR_FLAGS) == 0;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
/* Both span facts the dirty-document fused arm needs, in ONE pass:
|
|
445
|
+
* ascii (the column gate) and space (the #903 fold-candidate byte —
|
|
446
|
+
* the arm's inertness probe, standing in for its memchr so purity
|
|
447
|
+
* rides the scan the arm already paid for). */
|
|
448
|
+
typedef struct wr_span_scan {
|
|
449
|
+
int ascii;
|
|
450
|
+
int space;
|
|
451
|
+
} wr_span_scan;
|
|
452
|
+
|
|
453
|
+
static wr_span_scan WR_NOINLINE wr_span_facts(const char* p, uint32_t n) {
|
|
454
|
+
uint64_t hi = 0, sp = 0;
|
|
455
|
+
uint32_t i = 0;
|
|
456
|
+
for (; i + 8 <= n; i += 8) {
|
|
457
|
+
uint64_t x;
|
|
458
|
+
memcpy(&x, p + i, 8);
|
|
459
|
+
hi |= x;
|
|
460
|
+
sp |= yep_swar_eq8(x, 0x2020202020202020ull); /* ' ' splat */
|
|
461
|
+
}
|
|
462
|
+
for (; i < n; i++) {
|
|
463
|
+
unsigned char c = (unsigned char)p[i];
|
|
464
|
+
hi |= c;
|
|
465
|
+
sp |= (uint64_t)(c == ' ');
|
|
466
|
+
}
|
|
467
|
+
wr_span_scan f;
|
|
468
|
+
f.ascii = (hi & YEP_SWAR_FLAGS) == 0;
|
|
469
|
+
f.space = sp != 0;
|
|
470
|
+
return f;
|
|
471
|
+
}
|
|
472
|
+
|
|
372
473
|
/* Block-side width folding (#903): libyaml's plain/single-quoted fold
|
|
373
474
|
* walk. At an INTERIOR single space (not the value's first or last
|
|
374
475
|
* byte, no adjacent spaces) with the column past best_width, the break
|
|
@@ -392,10 +493,17 @@ static void wr_fold_break(yep_writer* w, int fold_col) {
|
|
|
392
493
|
wr_indent(w, fold_col);
|
|
393
494
|
}
|
|
394
495
|
|
|
395
|
-
/* The
|
|
396
|
-
* decision prices the PENDING run in (it flushes
|
|
397
|
-
* live column at the candidate space is
|
|
398
|
-
* libyaml's emitter->column at the same byte.
|
|
496
|
+
/* The fold walks (#903, dispatched per scalar on the run's purity
|
|
497
|
+
* fact #1490): the fold decision prices the PENDING run in (it flushes
|
|
498
|
+
* only at a fold), so the live column at the candidate space is
|
|
499
|
+
* w->col + run — exactly libyaml's emitter->column at the same byte.
|
|
500
|
+
* An all-ASCII document folds byte-priced (columns ARE byte counts;
|
|
501
|
+
* the loop is the original verbatim); a dirty document rides the
|
|
502
|
+
* character-priced twin. The twins are separate functions ON PURPOSE:
|
|
503
|
+
* one gated body made every caller's frame pay for both loops and the
|
|
504
|
+
* auto-vectorizer's prologue spills (the -6% the lanes caught). On a
|
|
505
|
+
* pure span of a dirty document the dispatch still gates per span
|
|
506
|
+
* (wr_span_ascii) and keeps the byte walk. */
|
|
399
507
|
static void emit_plain_folded(yep_writer* w, const char* p, uint32_t n, int fold_col) {
|
|
400
508
|
uint32_t run = 0; /* pending flush span length */
|
|
401
509
|
uint32_t i = 0;
|
|
@@ -418,6 +526,35 @@ static void emit_plain_folded(yep_writer* w, const char* p, uint32_t n, int fold
|
|
|
418
526
|
}
|
|
419
527
|
}
|
|
420
528
|
|
|
529
|
+
/* The character-priced twin (#1490): the same walk with the pending
|
|
530
|
+
* run priced in code points (run stays in bytes for the write). Only
|
|
531
|
+
* the dispatch below ever calls it — a document that carried a high
|
|
532
|
+
* byte somewhere. */
|
|
533
|
+
static void emit_plain_folded_mb(yep_writer* w, const char* p, uint32_t n, int fold_col) {
|
|
534
|
+
uint32_t run = 0; /* pending flush span length (bytes) */
|
|
535
|
+
int run_cols = 0; /* the same span in characters */
|
|
536
|
+
uint32_t i = 0;
|
|
537
|
+
while (i < n) {
|
|
538
|
+
if (p[i] == ' ' && i > 0 && i + 1 < n && w->col + run_cols > w->best_width &&
|
|
539
|
+
p[i - 1] != ' ' && p[i + 1] != ' ' && p[i - 1] != '\t' && p[i + 1] != '\t') {
|
|
540
|
+
if (run) {
|
|
541
|
+
wr_put(w, p + i - run, run);
|
|
542
|
+
run = 0;
|
|
543
|
+
run_cols = 0;
|
|
544
|
+
}
|
|
545
|
+
wr_fold_break(w, fold_col);
|
|
546
|
+
i++; /* the fold consumes the space (libyaml: MOVE without WRITE) */
|
|
547
|
+
continue;
|
|
548
|
+
}
|
|
549
|
+
run_cols += ((unsigned char)p[i] & 0xC0u) != 0x80u;
|
|
550
|
+
i++;
|
|
551
|
+
run++;
|
|
552
|
+
}
|
|
553
|
+
if (run) {
|
|
554
|
+
wr_put(w, p + n - run, run);
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
|
|
421
558
|
/* libyaml's single_quoted_allowed predicate (emitter.c analyze):
|
|
422
559
|
* disabled ONLY by special characters, a space immediately before a
|
|
423
560
|
* break (space_break), or a break immediately followed by a space
|
|
@@ -506,6 +643,65 @@ static void emit_sq_folded(yep_writer* w, const char* p, uint32_t n, int fold_co
|
|
|
506
643
|
wr_byte(w, '\'');
|
|
507
644
|
}
|
|
508
645
|
|
|
646
|
+
/* The character-priced twin (#1490) of emit_sq_folded: same law, plus
|
|
647
|
+
* the run reset at every content break. */
|
|
648
|
+
static void emit_sq_folded_mb(yep_writer* w, const char* p, uint32_t n, int fold_col) {
|
|
649
|
+
wr_byte(w, '\'');
|
|
650
|
+
uint32_t run = 0;
|
|
651
|
+
int run_cols = 0;
|
|
652
|
+
uint32_t i = 0;
|
|
653
|
+
int breaks = 0;
|
|
654
|
+
while (i < n) {
|
|
655
|
+
if (p[i] == '\n' || p[i] == '\r') {
|
|
656
|
+
if (run) {
|
|
657
|
+
wr_put(w, p + i - run, run);
|
|
658
|
+
run = 0;
|
|
659
|
+
run_cols = 0;
|
|
660
|
+
}
|
|
661
|
+
if (!breaks && p[i] == '\n') {
|
|
662
|
+
wr_byte(w, '\n');
|
|
663
|
+
}
|
|
664
|
+
wr_byte(w, p[i]);
|
|
665
|
+
breaks = 1;
|
|
666
|
+
i++;
|
|
667
|
+
continue;
|
|
668
|
+
}
|
|
669
|
+
if (breaks) {
|
|
670
|
+
wr_indent(w, fold_col);
|
|
671
|
+
breaks = 0;
|
|
672
|
+
}
|
|
673
|
+
if (p[i] == '\'') {
|
|
674
|
+
if (run) {
|
|
675
|
+
wr_put(w, p + i - run, run);
|
|
676
|
+
run = 0;
|
|
677
|
+
run_cols = 0;
|
|
678
|
+
}
|
|
679
|
+
wr_put(w, "''", 2);
|
|
680
|
+
i++;
|
|
681
|
+
continue;
|
|
682
|
+
}
|
|
683
|
+
if (p[i] == ' ' && i > 0 && i + 1 < n && w->col + run_cols > w->best_width &&
|
|
684
|
+
p[i - 1] != ' ' && p[i + 1] != ' ' && p[i - 1] != '\t' && p[i + 1] != '\t') {
|
|
685
|
+
if (run) {
|
|
686
|
+
wr_put(w, p + i - run, run);
|
|
687
|
+
run = 0;
|
|
688
|
+
run_cols = 0;
|
|
689
|
+
}
|
|
690
|
+
wr_fold_break(w, fold_col);
|
|
691
|
+
i++;
|
|
692
|
+
continue;
|
|
693
|
+
}
|
|
694
|
+
run_cols += ((unsigned char)p[i] & 0xC0u) != 0x80u;
|
|
695
|
+
i++;
|
|
696
|
+
run++;
|
|
697
|
+
}
|
|
698
|
+
if (breaks) {
|
|
699
|
+
wr_indent(w, fold_col);
|
|
700
|
+
} else if (run) {
|
|
701
|
+
wr_put(w, p + n - run, run);
|
|
702
|
+
}
|
|
703
|
+
wr_byte(w, '\'');
|
|
704
|
+
}
|
|
509
705
|
/* JSON string escapes: \" \\ \b \f \n \r \t and \uXXXX for other
|
|
510
706
|
* controls; raw UTF-8 passes through (RFC 8259). */
|
|
511
707
|
void emit_dq_json(yep_writer* w, const char* p, uint32_t n) {
|
|
@@ -559,7 +755,10 @@ static void emit_dq_json_raw(yep_writer* w, const char* p, uint32_t n) {
|
|
|
559
755
|
size_t total = (size_t)n + 2;
|
|
560
756
|
w->last = '"';
|
|
561
757
|
if (!w->skip_col) {
|
|
562
|
-
|
|
758
|
+
/* characters (#1490), gated: an ASCII span's columns are byte
|
|
759
|
+
* counts — the JSON fast path keeps its arithmetic unless a
|
|
760
|
+
* high byte rides */
|
|
761
|
+
w->col += (w->doc_ascii == 1 || wr_span_ascii(p, n)) ? (int)total : 2 + wr_char_cols(p, n);
|
|
563
762
|
}
|
|
564
763
|
if (w->dry) {
|
|
565
764
|
w->len += total;
|
|
@@ -1021,14 +1220,22 @@ static void emit_scalar(yep_writer* w, const yep_dnode* n, int parent_col, int a
|
|
|
1021
1220
|
/* #903: block-context width folding; keys never fold
|
|
1022
1221
|
* (libyaml: allow_breaks = !simple_key_context) and flow
|
|
1023
1222
|
* members keep the flow walk */
|
|
1024
|
-
|
|
1223
|
+
if (w->doc_ascii == 1 || wr_span_ascii(p, len)) {
|
|
1224
|
+
emit_plain_folded(w, p, len, parent_col + w->indent);
|
|
1225
|
+
} else {
|
|
1226
|
+
emit_plain_folded_mb(w, p, len, parent_col + w->indent);
|
|
1227
|
+
}
|
|
1025
1228
|
} else {
|
|
1026
1229
|
wr_put(w, p, len);
|
|
1027
1230
|
}
|
|
1028
1231
|
break;
|
|
1029
1232
|
case YEP_SC_SQ:
|
|
1030
1233
|
if (w->block_fold && !as_key && !w->in_flow && len > 0) {
|
|
1031
|
-
|
|
1234
|
+
if (w->doc_ascii == 1 || wr_span_ascii(p, len)) {
|
|
1235
|
+
emit_sq_folded(w, p, len, parent_col + w->indent);
|
|
1236
|
+
} else {
|
|
1237
|
+
emit_sq_folded_mb(w, p, len, parent_col + w->indent);
|
|
1238
|
+
}
|
|
1032
1239
|
} else {
|
|
1033
1240
|
emit_sq(w, p, len);
|
|
1034
1241
|
}
|
|
@@ -1486,6 +1693,27 @@ static void emit_flow(yep_emitter* em, uint32_t id) {
|
|
|
1486
1693
|
w->in_flow = saved_flow;
|
|
1487
1694
|
}
|
|
1488
1695
|
|
|
1696
|
+
/* The dirty-document column accounting for the fused member write
|
|
1697
|
+
* (#1490): one wr_char_cols walk per high-byte span, byte arithmetic
|
|
1698
|
+
* otherwise. Out of line so emit_block_map's hot loop keeps main's
|
|
1699
|
+
* exact frame on clean documents (the gated body in the loop cost the
|
|
1700
|
+
* wide lane -3%). */
|
|
1701
|
+
static void WR_NOINLINE wr_fused_cols_mb(yep_writer* w, yep_view kv, yep_view vv, uint32_t f_total,
|
|
1702
|
+
uint32_t f_nl) {
|
|
1703
|
+
int cols = (int)f_total;
|
|
1704
|
+
if (!wr_span_ascii(kv.p, kv.len)) {
|
|
1705
|
+
cols += wr_char_cols(kv.p, kv.len) - (int)kv.len;
|
|
1706
|
+
}
|
|
1707
|
+
if (vv.len > 0 && !wr_span_ascii(vv.p, vv.len)) {
|
|
1708
|
+
cols += wr_char_cols(vv.p, vv.len) - (int)vv.len;
|
|
1709
|
+
}
|
|
1710
|
+
if (f_nl) {
|
|
1711
|
+
w->col = cols - 1; /* the break resets, then the line */
|
|
1712
|
+
} else {
|
|
1713
|
+
w->col += cols;
|
|
1714
|
+
}
|
|
1715
|
+
}
|
|
1716
|
+
|
|
1489
1717
|
/* Block map: first key at the cursor (the caller placed it at
|
|
1490
1718
|
* content_col = parent_col+2); following keys on new lines there. */
|
|
1491
1719
|
static void emit_block_map(yep_emitter* em, uint32_t id, int content_col) {
|
|
@@ -1494,6 +1722,9 @@ static void emit_block_map(yep_emitter* em, uint32_t id, int content_col) {
|
|
|
1494
1722
|
const yep_dnode* n = yep_dom_node(d, id);
|
|
1495
1723
|
uint32_t child = n->first_child;
|
|
1496
1724
|
uint32_t pair = 0;
|
|
1725
|
+
/* #1490: the run's purity fact, cached for the loop (fixed for the
|
|
1726
|
+
* whole run by yep_emit_run; the fused arm only rides clean docs) */
|
|
1727
|
+
const int doc_clean = w->doc_ascii == 1;
|
|
1497
1728
|
while (child != UINT32_MAX) {
|
|
1498
1729
|
/* #352: the flat plain member specialist — tiny scalar pairs
|
|
1499
1730
|
* pay dispatch and props checks, not byte work. Strictly
|
|
@@ -1523,10 +1754,14 @@ static void emit_block_map(yep_emitter* em, uint32_t id, int content_col) {
|
|
|
1523
1754
|
* live column (the first member: the caller placed the
|
|
1524
1755
|
* cursor at content_col) */
|
|
1525
1756
|
int m_start = (pair == 0 || w->last == '\n') ? content_col : w->col;
|
|
1526
|
-
/* the empty value's view is {NULL, 0} (wv) —
|
|
1527
|
-
* nonnull contract forbids the
|
|
1757
|
+
/* the empty value's view is {NULL, 0} (wv) — the probe's
|
|
1758
|
+
* nonnull contract forbids the check even at len 0. Clean
|
|
1759
|
+
* documents keep main's exact memchr probe; dirty ones scan
|
|
1760
|
+
* facts instead — the fold-candidate space AND the column
|
|
1761
|
+
* purity (#1490) ride one pass. */
|
|
1528
1762
|
int fold_inert = !w->block_fold || w->best_width == INT_MAX || vv.p == NULL ||
|
|
1529
|
-
memchr(vv.p, ' ', vv.len) == NULL
|
|
1763
|
+
(doc_clean ? memchr(vv.p, ' ', vv.len) == NULL
|
|
1764
|
+
: wr_span_facts(vv.p, vv.len).space == 0) ||
|
|
1530
1765
|
m_start + (int)kv.len + (int)vv.len + 2 <= w->best_width;
|
|
1531
1766
|
uint32_t f_ind = 0, f_nl = 0, f_total = 0;
|
|
1532
1767
|
int fused = fold_inert && kv.len > 0 && !key_written_over_limit(w, kn0) &&
|
|
@@ -1552,10 +1787,18 @@ static void emit_block_map(yep_emitter* em, uint32_t id, int content_col) {
|
|
|
1552
1787
|
}
|
|
1553
1788
|
if (fused) {
|
|
1554
1789
|
w->last = vv.len > 0 ? (char)vv.p[vv.len - 1] : ':';
|
|
1555
|
-
|
|
1556
|
-
|
|
1790
|
+
/* the column in characters (#1490), gated on the run's
|
|
1791
|
+
* fact: a clean document's member is priced in bytes
|
|
1792
|
+
* (one reservation covers the whole member); a dirty one
|
|
1793
|
+
* walks only its high-byte spans, out of line */
|
|
1794
|
+
if (doc_clean) {
|
|
1795
|
+
if (f_nl) {
|
|
1796
|
+
w->col = (int)(f_total - 1u); /* the break resets, then the line */
|
|
1797
|
+
} else {
|
|
1798
|
+
w->col += (int)f_total;
|
|
1799
|
+
}
|
|
1557
1800
|
} else {
|
|
1558
|
-
w
|
|
1801
|
+
wr_fused_cols_mb(w, kv, vv, f_total, f_nl);
|
|
1559
1802
|
}
|
|
1560
1803
|
if (w->dry) {
|
|
1561
1804
|
w->len += f_total;
|
|
@@ -1992,6 +2235,12 @@ static int emit_json_pair_fused(yep_writer* w, const yep_dnode* kn, const yep_dn
|
|
|
1992
2235
|
/* the run-end law reads w->last for the root newline: spell the
|
|
1993
2236
|
* byte that actually lands last (a digit tail for plain tokens) */
|
|
1994
2237
|
w->last = (typed && !vquoted && vtl > 0) ? vt[vtl - 1] : '"';
|
|
2238
|
+
if (!w->skip_col && w->doc_ascii != 1) {
|
|
2239
|
+
/* #1490: the pair's col scan is arithmetic (bytes), so a dirty
|
|
2240
|
+
* document declines to the general pair path, whose wr_put
|
|
2241
|
+
* accounting prices characters exactly */
|
|
2242
|
+
return 0;
|
|
2243
|
+
}
|
|
1995
2244
|
if (!w->skip_col) {
|
|
1996
2245
|
w->col += (int)total;
|
|
1997
2246
|
}
|
|
@@ -2212,6 +2461,18 @@ static void emit_json_node_p(yep_emitter* em, const yep_dnode* n) {
|
|
|
2212
2461
|
size_t yep_emit_run(yep_emitter* em, int dry) {
|
|
2213
2462
|
yep_writer* w = &em->w;
|
|
2214
2463
|
const yep_dom* d = em->doc->dom;
|
|
2464
|
+
/* The doc-level purity fact (#1490's gate, hoisted): an all-ASCII
|
|
2465
|
+
* document keeps the byte arithmetic everywhere (the hot loops stay
|
|
2466
|
+
* byte-priced, no per-span scans); a multibyte document arms the
|
|
2467
|
+
* per-span gates. The INPUT half is the parse-side fact (parse.c's
|
|
2468
|
+
* encoding gate — no added pass); the arena half holds decoded and
|
|
2469
|
+
* copied strings, so it still earns one SWAR pass per run — small
|
|
2470
|
+
* by construction (zero-copy views ride the input region). Derived
|
|
2471
|
+
* once, shared by the dry and wet passes. */
|
|
2472
|
+
if (w->doc_ascii < 0) {
|
|
2473
|
+
w->doc_ascii = d->input_ascii &&
|
|
2474
|
+
(d->str == NULL || d->str_len == 0 || wr_span_ascii(d->str, d->str_len));
|
|
2475
|
+
}
|
|
2215
2476
|
w->dry = dry;
|
|
2216
2477
|
w->len = 0;
|
|
2217
2478
|
w->reserve = 0;
|
|
@@ -85,6 +85,16 @@ typedef struct yep_writer {
|
|
|
85
85
|
const struct yep_resolver* resolver; /* the document's implicit-typing
|
|
86
86
|
family (NULL = core12): the INT arm's decode needs the family's
|
|
87
87
|
own forms (leading-0 is octal in compat, decimal in core) */
|
|
88
|
+
int doc_ascii; /* #1490's span-purity gate, hoisted to the document.
|
|
89
|
+
LAST FIELD ON PURPOSE: the hot fields above keep
|
|
90
|
+
main's exact offsets and cache-line layout. 1 =
|
|
91
|
+
every byte of both DOM regions (input + arena) is
|
|
92
|
+
ASCII, so columns are byte counts everywhere and
|
|
93
|
+
every column site keeps the original arithmetic;
|
|
94
|
+
0 = the document carried a high byte, so each site
|
|
95
|
+
gates per span (wr_span_ascii); -1 = not yet
|
|
96
|
+
computed (yep_emit_run derives it once, shared
|
|
97
|
+
dry/wet) */
|
|
88
98
|
} yep_writer;
|
|
89
99
|
|
|
90
100
|
typedef struct yep_emitter {
|
|
@@ -609,6 +609,9 @@ YEPTRIS_API YeptrisStatus yeptris_json_from_marshal(const char* m, size_t m_len,
|
|
|
609
609
|
* block-indents, but the writer stays fully
|
|
610
610
|
* initialized */
|
|
611
611
|
w->block_fold = 0;
|
|
612
|
+
w->doc_ascii = 0; /* no DOM regions to derive the fact from: the
|
|
613
|
+
* per-span purity gates stay armed (the memset's
|
|
614
|
+
* 0 already means "dirty: gate per span") */
|
|
612
615
|
|
|
613
616
|
mj_ctx c;
|
|
614
617
|
memset(&c, 0, sizeof(c));
|
|
@@ -82,6 +82,7 @@ yep_dom* yep_doc_dom(yeptris_document* doc) {
|
|
|
82
82
|
yep_dom* dom = yep_dom_create(doc->sys);
|
|
83
83
|
if (dom != NULL) {
|
|
84
84
|
dom->resolver = resolver_for_schema(doc->schema);
|
|
85
|
+
dom->input_ascii = doc->lazy_input_ascii; /* #1490 */
|
|
85
86
|
}
|
|
86
87
|
if (dom != NULL && dom_from_ytape(dom, t) == 0) {
|
|
87
88
|
doc->dom = dom;
|
|
@@ -99,6 +100,9 @@ yep_dom* yep_doc_dom(yeptris_document* doc) {
|
|
|
99
100
|
} else {
|
|
100
101
|
yeptris_json_tape* t = (yeptris_json_tape*)doc->lazy_tape;
|
|
101
102
|
yep_dom* dom = yep_dom_create(doc->sys);
|
|
103
|
+
if (dom != NULL) {
|
|
104
|
+
dom->input_ascii = doc->lazy_input_ascii; /* #1490 */
|
|
105
|
+
}
|
|
102
106
|
if (dom != NULL && dom_from_tape(dom, t) == 0) {
|
|
103
107
|
doc->dom = dom;
|
|
104
108
|
yeptris_tape_free(t);
|
|
@@ -135,6 +139,7 @@ static YeptrisDocument yep_json_doc_wrap(yep_dom* dom, const char* buf, size_t l
|
|
|
135
139
|
doc->sys = sys;
|
|
136
140
|
doc->lazy_tape = NULL;
|
|
137
141
|
doc->lazy_kind = 0;
|
|
142
|
+
doc->lazy_input_ascii = 0; /* #1490: the eager dom carries its own fact */
|
|
138
143
|
doc->schema = YEPTRIS_SCHEMA_12_CORE; /* strict JSON is core by construction */
|
|
139
144
|
doc->transcoded = NULL;
|
|
140
145
|
doc->transcoded_len = 0;
|
|
@@ -185,6 +190,9 @@ YEPTRIS_API YeptrisDocument yeptris_parse_json(const char* buf, size_t len, Yept
|
|
|
185
190
|
if (h != NULL) {
|
|
186
191
|
((yeptris_document*)h)->lazy_tape = t;
|
|
187
192
|
((yeptris_document*)h)->lazy_kind = 0;
|
|
193
|
+
((yeptris_document*)h)->lazy_input_ascii =
|
|
194
|
+
1; /* the fused walk is clean_only: a high byte
|
|
195
|
+
* or tab rejected to the strict route below */
|
|
188
196
|
return h;
|
|
189
197
|
}
|
|
190
198
|
yeptris_tape_free(t); /* wrap failed (memory): below */
|
|
@@ -225,6 +233,7 @@ YEPTRIS_API YeptrisDocument yeptris_parse_json(const char* buf, size_t len, Yept
|
|
|
225
233
|
}
|
|
226
234
|
dom->input_base = buf; /* strict JSON is UTF-8 by definition */
|
|
227
235
|
dom->input_len = len;
|
|
236
|
+
dom->input_ascii = !gated; /* #1490: the gate's clean answer is the fact */
|
|
228
237
|
yep_dom_prepare_len(dom, len);
|
|
229
238
|
int brc = yep_dom_build_json(dom, buf, len);
|
|
230
239
|
if (brc == -1) {
|
|
@@ -255,7 +264,7 @@ jfail:
|
|
|
255
264
|
static int parse_frontend(const char* buf, size_t len, const yep_allocator* sys, int json_mode,
|
|
256
265
|
const char** data_out, size_t* data_len_out,
|
|
257
266
|
unsigned char** transcoded_out, size_t* transcoded_len_out,
|
|
258
|
-
int* norm_kept_raw_out, YeptrisStatus* st) {
|
|
267
|
+
int* norm_kept_raw_out, int* data_ascii_out, YeptrisStatus* st) {
|
|
259
268
|
/* a NULL/0-byte stream is a valid empty input: parse it through a
|
|
260
269
|
* non-null base so the BOM arithmetic never computes NULL+0
|
|
261
270
|
* (clang's UBSan flags the zero-offset-null form; gcc's does not —
|
|
@@ -269,6 +278,11 @@ static int parse_frontend(const char* buf, size_t len, const yep_allocator* sys,
|
|
|
269
278
|
int norm_kept_raw = 0; /* raw NEL/LS/PS survived the quote-aware
|
|
270
279
|
* walk: the engine route owns the document
|
|
271
280
|
* (the tape runner predates the cut) */
|
|
281
|
+
int data_ascii = 0; /* #1490: the emitter's column fact — the
|
|
282
|
+
* gate branch's clean answer proves every
|
|
283
|
+
* byte < 0x80 (the writer's byte-priced fast
|
|
284
|
+
* paths may ride); anything else keeps the
|
|
285
|
+
* per-span gates armed */
|
|
272
286
|
|
|
273
287
|
if (json_mode) {
|
|
274
288
|
/* JSON mode validated grammar and UTF-8 well-formedness at the
|
|
@@ -280,6 +294,9 @@ static int parse_frontend(const char* buf, size_t len, const yep_allocator* sys,
|
|
|
280
294
|
*transcoded_out = NULL;
|
|
281
295
|
*transcoded_len_out = 0;
|
|
282
296
|
*norm_kept_raw_out = 0;
|
|
297
|
+
if (data_ascii_out != NULL) {
|
|
298
|
+
*data_ascii_out = yep_text_active()->gate_scan(data, data_len) == 0;
|
|
299
|
+
}
|
|
283
300
|
return 0;
|
|
284
301
|
}
|
|
285
302
|
|
|
@@ -324,6 +341,8 @@ static int parse_frontend(const char* buf, size_t len, const yep_allocator* sys,
|
|
|
324
341
|
*st = YEPTRIS_ERROR_ENCODING;
|
|
325
342
|
return -1;
|
|
326
343
|
}
|
|
344
|
+
} else {
|
|
345
|
+
data_ascii = 1; /* every byte gate-safe: pure ASCII (#1490) */
|
|
327
346
|
}
|
|
328
347
|
}
|
|
329
348
|
|
|
@@ -347,11 +366,18 @@ static int parse_frontend(const char* buf, size_t len, const yep_allocator* sys,
|
|
|
347
366
|
}
|
|
348
367
|
}
|
|
349
368
|
|
|
369
|
+
if (transcoded != NULL) {
|
|
370
|
+
data_ascii = 0; /* a transcode or normalize copy rode: the
|
|
371
|
+
* copied bytes are not gate-proven */
|
|
372
|
+
}
|
|
350
373
|
*data_out = data;
|
|
351
374
|
*data_len_out = data_len;
|
|
352
375
|
*transcoded_out = transcoded;
|
|
353
376
|
*transcoded_len_out = transcoded_len;
|
|
354
377
|
*norm_kept_raw_out = norm_kept_raw;
|
|
378
|
+
if (data_ascii_out != NULL) {
|
|
379
|
+
*data_ascii_out = data_ascii;
|
|
380
|
+
}
|
|
355
381
|
return 0;
|
|
356
382
|
}
|
|
357
383
|
|
|
@@ -378,7 +404,7 @@ YeptrisStatus yep_parse_events(const char* buf, size_t len, YeptrisSchema schema
|
|
|
378
404
|
int norm_kept_raw = 0;
|
|
379
405
|
YeptrisStatus st = YEPTRIS_OK;
|
|
380
406
|
if (parse_frontend(buf, len, sys, 0, &data, &data_len, &transcoded, &transcoded_len,
|
|
381
|
-
&norm_kept_raw, &st) != 0) {
|
|
407
|
+
&norm_kept_raw, NULL, &st) != 0) {
|
|
382
408
|
return st;
|
|
383
409
|
}
|
|
384
410
|
yep_engine* eng = yep_engine_create(sys);
|
|
@@ -464,8 +490,9 @@ static YeptrisDocument parse_impl(const char* buf, size_t len, const YeptrisPars
|
|
|
464
490
|
* finish pool and transcoded */
|
|
465
491
|
size_t nblen = 0;
|
|
466
492
|
|
|
493
|
+
int data_ascii = 0;
|
|
467
494
|
if (parse_frontend(buf, len, sys, json_mode, &data, &data_len, &transcoded, &transcoded_len,
|
|
468
|
-
&norm_kept_raw, &st) != 0) {
|
|
495
|
+
&norm_kept_raw, &data_ascii, &st) != 0) {
|
|
469
496
|
goto fail;
|
|
470
497
|
}
|
|
471
498
|
|
|
@@ -512,6 +539,7 @@ static YeptrisDocument parse_impl(const char* buf, size_t len, const YeptrisPars
|
|
|
512
539
|
* after, every scalar was arena-copied (found 2026-09-10). */
|
|
513
540
|
dom->input_len = data_len;
|
|
514
541
|
dom->input_base = transcoded ? (const char*)transcoded : buf;
|
|
542
|
+
dom->input_ascii = data_ascii; /* #1490: the emitter's column fact */
|
|
515
543
|
yep_dom_prepare_len(dom, data_len);
|
|
516
544
|
}
|
|
517
545
|
if (!json_mode) {
|
|
@@ -648,6 +676,9 @@ static YeptrisDocument parse_impl(const char* buf, size_t len, const YeptrisPars
|
|
|
648
676
|
st = YEPTRIS_ERROR_MEMORY;
|
|
649
677
|
goto fail;
|
|
650
678
|
}
|
|
679
|
+
doc->lazy_input_ascii = 0; /* field-by-field ctor (#1490): set below
|
|
680
|
+
* for the lazy tape (the eager dom carries
|
|
681
|
+
* its own fact) */
|
|
651
682
|
yep_mutex_init(&doc->lazy_mu);
|
|
652
683
|
doc->sys = sys;
|
|
653
684
|
doc->schema = (opts != NULL && opts->schema != YEPTRIS_SCHEMA_12_CORE) ? opts->schema
|
|
@@ -704,6 +735,7 @@ static YeptrisDocument parse_impl(const char* buf, size_t len, const YeptrisPars
|
|
|
704
735
|
doc->dom = NULL;
|
|
705
736
|
doc->lazy_tape = heap_tape;
|
|
706
737
|
doc->lazy_kind = 1;
|
|
738
|
+
doc->lazy_input_ascii = data_ascii; /* #1490: for the dom build */
|
|
707
739
|
} else {
|
|
708
740
|
doc->dom = dom;
|
|
709
741
|
}
|