yeptris 0.6.64.0-arm-linux-eabihf → 0.6.66.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/ffi.rb +4 -0
- data/lib/yeptris/materializer.rb +29 -7
- data/lib/yeptris/node.rb +1 -1
- data/lib/yeptris/psych/visitors.rb +71 -5
- data/lib/yeptris/psych.rb +177 -88
- data/lib/yeptris/yaml.rb +62 -18
- 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 +43 -7
- data/vendor/libyeptris/src/yeptris/dom/dom.c +18 -0
- data/vendor/libyeptris/src/yeptris/dom/dom.h +24 -16
- data/vendor/libyeptris/src/yeptris/dom/ytape.c +9 -0
- data/vendor/libyeptris/src/yeptris/emit/writer.c +375 -29
- data/vendor/libyeptris/src/yeptris/emit/writer.h +6 -0
- data/vendor/libyeptris/src/yeptris/encoding/utf8_validate.c +362 -0
- data/vendor/libyeptris/src/yeptris/parse/engine.c +36 -40
- data/vendor/libyeptris/src/yeptris/scan/scan.c +10 -0
- data/vendor/libyeptris/src/yeptris/scan/scan.h +7 -0
- data/vendor/libyeptris/src/yeptris/tape.c +21 -13
- metadata +1 -1
data/lib/yeptris/yaml.rb
CHANGED
|
@@ -302,8 +302,14 @@ module Yeptris
|
|
|
302
302
|
# with the #1257 flip also block plain/single-quoted scalars, the
|
|
303
303
|
# psych/libyaml stored-file behavior); a negative width is psych's
|
|
304
304
|
# line_width: -1 unwrap (the engine clamps it to never-fold).
|
|
305
|
-
|
|
306
|
-
|
|
305
|
+
# merge_tag: the bytes stored for a literal chevron key — the
|
|
306
|
+
# neutral face pins the shorthand (its documented form); the
|
|
307
|
+
# Psych facade passes BulkBuilder::MERGE_KEY_TAG (the URI the
|
|
308
|
+
# engine's tag writer renders as !!str).
|
|
309
|
+
def dump(obj, canonical: false, header: false, width: nil,
|
|
310
|
+
merge_tag: "!!str")
|
|
311
|
+
BulkBuilder.dump(obj, canonical: canonical, header: header,
|
|
312
|
+
width: width, merge_tag: merge_tag)
|
|
307
313
|
end
|
|
308
314
|
|
|
309
315
|
|
|
@@ -325,6 +331,12 @@ module Yeptris
|
|
|
325
331
|
STYLE_DQ = 3
|
|
326
332
|
STYLE_LIT = 4
|
|
327
333
|
BUILD_TAG = Yeptris::FFI::BUILD_TAG
|
|
334
|
+
# The chevron-key tag bytes a PSYCH-shaped document carries
|
|
335
|
+
# (#857/#862): the full core URI — the engine's tag writer
|
|
336
|
+
# renders !!str from it, while the verbatim shorthand rides the
|
|
337
|
+
# URI escaper (!%21str) through the bulk build. The neutral
|
|
338
|
+
# face's default stays the shorthand (its documented form).
|
|
339
|
+
MERGE_KEY_TAG = "tag:yaml.org,2002:str"
|
|
328
340
|
|
|
329
341
|
module_function
|
|
330
342
|
|
|
@@ -354,7 +366,7 @@ module Yeptris
|
|
|
354
366
|
Yeptris::FFI::BUILD_SEQ => SEQ_ENTRY,
|
|
355
367
|
Yeptris::FFI::BUILD_END => END_ENTRY }.freeze
|
|
356
368
|
|
|
357
|
-
def dump(obj, canonical: false, header: false, width: nil)
|
|
369
|
+
def dump(obj, canonical: false, header: false, width: nil, merge_tag: "!!str")
|
|
358
370
|
# The nil root rides the bare form (psych's dump(nil) == "\n",
|
|
359
371
|
# #290): the engine's r201 quoted-form law ("a document-root
|
|
360
372
|
# empty scalar rides the quoted form" -- the plain form does not
|
|
@@ -365,6 +377,26 @@ module Yeptris
|
|
|
365
377
|
# round-trips THROUGH THE BINDING while keeping the engine's
|
|
366
378
|
# invariant untouched.
|
|
367
379
|
return header ? "--- \n" : "\n" if obj.nil? && !canonical
|
|
380
|
+
|
|
381
|
+
doc = Document.create
|
|
382
|
+
build_into(doc, obj, merge_tag)
|
|
383
|
+
doc.serialize(canonical: canonical, best_width: width || 0,
|
|
384
|
+
explicit_doc_start: header)
|
|
385
|
+
ensure
|
|
386
|
+
doc&.free
|
|
387
|
+
end
|
|
388
|
+
|
|
389
|
+
# The bulk build itself (#857's shared lane): one flat entry
|
|
390
|
+
# stream plus one string blob, and yeptris_document_build raises
|
|
391
|
+
# the DOM in a SINGLE FFI call — per-node FFI is gone. `doc` is
|
|
392
|
+
# the receiving document (the neutral face creates its own; the
|
|
393
|
+
# Psych YAMLTree hands its @tree over so finish/document keep
|
|
394
|
+
# working unchanged). merge_tag: the bytes stored for a literal
|
|
395
|
+
# chevron key — the neutral face spells the shorthand "!!str"
|
|
396
|
+
# (its pinned form), the Psych visitor carries the full core URI
|
|
397
|
+
# the engine's tag writer renders as !!str (the verbatim
|
|
398
|
+
# shorthand would emit as a LOCAL tag — the writer.c regression).
|
|
399
|
+
def build_into(doc, obj, merge_tag = "!!str")
|
|
368
400
|
parts = []
|
|
369
401
|
blob = String.new(encoding: Encoding::BINARY)
|
|
370
402
|
off = [0]
|
|
@@ -373,19 +405,17 @@ module Yeptris
|
|
|
373
405
|
parts << (o.zero? && len.zero? && style.zero? ? CONT_ENTRY[op] :
|
|
374
406
|
[op, style, o, len].pack("CCx2VV"))
|
|
375
407
|
end
|
|
376
|
-
place(obj, emit, blob, off, {})
|
|
377
|
-
doc = Document.create
|
|
408
|
+
place(obj, emit, blob, off, {}, merge_tag)
|
|
378
409
|
buf = ::FFI::MemoryPointer.from_string(parts.join)
|
|
379
410
|
bblob = ::FFI::MemoryPointer.from_string(blob)
|
|
380
411
|
rc = doc.build_entries(buf, parts.length, bblob, blob.bytesize)
|
|
381
412
|
raise DumpError, "document_build failed: #{rc}" unless rc == FFI::OK
|
|
382
|
-
|
|
383
|
-
explicit_doc_start: header)
|
|
384
|
-
ensure
|
|
385
|
-
doc&.free
|
|
413
|
+
rc
|
|
386
414
|
end
|
|
387
415
|
|
|
388
|
-
|
|
416
|
+
# The flat-value walk. merge_tag threads through the recursion
|
|
417
|
+
# (the chevron key is the only place the two faces diverge).
|
|
418
|
+
def place(obj, emit, blob, off, seen, merge_tag = "!!str")
|
|
389
419
|
case obj
|
|
390
420
|
when Hash
|
|
391
421
|
cycle_guard(obj, seen) do
|
|
@@ -411,11 +441,12 @@ module Yeptris
|
|
|
411
441
|
elsif k.is_a?(String) && k == "<<"
|
|
412
442
|
# stdlib yaml_tree: a literal chevron key carries the
|
|
413
443
|
# explicit !!str tag (single-quoted) so it does not
|
|
414
|
-
# re-load as a merge
|
|
444
|
+
# re-load as a merge — merge_tag carries the spelling
|
|
445
|
+
# the calling face pins
|
|
415
446
|
scalar("<<", STYLE_SQ, emit, blob, off)
|
|
416
|
-
emit.call(BUILD_TAG, 0, off[0],
|
|
417
|
-
blob <<
|
|
418
|
-
off[0] +=
|
|
447
|
+
emit.call(BUILD_TAG, 0, off[0], merge_tag.bytesize)
|
|
448
|
+
blob << merge_tag
|
|
449
|
+
off[0] += merge_tag.bytesize
|
|
419
450
|
elsif k.is_a?(String)
|
|
420
451
|
# keys ride psych's ONE visit_String law — stdlib applies
|
|
421
452
|
# it to keys and values alike, so the reshape words quote
|
|
@@ -423,19 +454,32 @@ module Yeptris
|
|
|
423
454
|
# had the psych side inverted: stdlib quotes these keys
|
|
424
455
|
# on every version since 4.0.2). The engine's own
|
|
425
456
|
# plain-key-safety re-check still guards the position.
|
|
426
|
-
|
|
427
|
-
|
|
457
|
+
if k.encoding == ::Encoding::ASCII_8BIT && !k.ascii_only?
|
|
458
|
+
# #168's binary branch is key/value-agnostic (psych's
|
|
459
|
+
# visit_String never asks which slot it sits in): strict
|
|
460
|
+
# base64 + the short !binary tag + literal style — the
|
|
461
|
+
# node walk's build_string already spelled it this way;
|
|
462
|
+
# the old double-quote arm carried raw non-UTF8 bytes
|
|
463
|
+
# into the document
|
|
464
|
+
scalar([k].pack("m0"), STYLE_LIT, emit, blob, off)
|
|
465
|
+
emit.call(BUILD_TAG, 0, off[0], 7)
|
|
466
|
+
blob << "!binary"
|
|
467
|
+
off[0] += 7
|
|
468
|
+
else
|
|
469
|
+
style = STYLE_BY_NAME[string_style(k)]
|
|
470
|
+
scalar(k, style, emit, blob, off)
|
|
471
|
+
end
|
|
428
472
|
else
|
|
429
473
|
scalar(k.to_s, STYLE_PLAIN, emit, blob, off)
|
|
430
474
|
end
|
|
431
|
-
place(v, emit, blob, off, seen)
|
|
475
|
+
place(v, emit, blob, off, seen, merge_tag)
|
|
432
476
|
end
|
|
433
477
|
emit.call(STOP, 0, 0, 0)
|
|
434
478
|
end
|
|
435
479
|
when Array
|
|
436
480
|
cycle_guard(obj, seen) do
|
|
437
481
|
emit.call(SEQ, 0, 0, 0)
|
|
438
|
-
obj.each { |e| place(e, emit, blob, off, seen) }
|
|
482
|
+
obj.each { |e| place(e, emit, blob, off, seen, merge_tag) }
|
|
439
483
|
emit.call(STOP, 0, 0, 0)
|
|
440
484
|
end
|
|
441
485
|
when String
|
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.66.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
|
|
@@ -86,8 +86,19 @@ static void cbor_fail(yep_cdec* c, yep_err_code code, const char* msg) {
|
|
|
86
86
|
/* The head's argument: additional info 0-23 inline, 24-27 a 1/2/4/8-byte
|
|
87
87
|
* big-endian value; 28-30 are reserved (never well-formed). Strict mode
|
|
88
88
|
* also rejects non-minimal encodings (RFC 8949 s4.2.1's argument rule).
|
|
89
|
-
* ai 31 is the caller's (indefinite/break) — never reaches here.
|
|
90
|
-
|
|
89
|
+
* ai 31 is the caller's (indefinite/break) — never reaches here.
|
|
90
|
+
*
|
|
91
|
+
* Inlined into cbor_item (the #742 profile's hottest frame pair: the
|
|
92
|
+
* out-of-line call + strict/nbytes reloads cost measurable share on
|
|
93
|
+
* int/string-dense shapes). Fixed-width big-endian compose — the
|
|
94
|
+
* compilers lower the constant-width forms to a rev/bswap load. */
|
|
95
|
+
#if defined(__GNUC__)
|
|
96
|
+
#define CBOR_ARG_INLINE __attribute__((always_inline)) inline
|
|
97
|
+
#else
|
|
98
|
+
#define CBOR_ARG_INLINE /* plain static: MSVC has no always_inline */
|
|
99
|
+
#endif
|
|
100
|
+
|
|
101
|
+
static CBOR_ARG_INLINE int cbor_arg(yep_cdec* c, uint8_t ai, uint64_t* val) {
|
|
91
102
|
static const uint8_t nbytes[4] = {1, 2, 4, 8};
|
|
92
103
|
static const uint64_t minv[4] = {24, 0x100ull, 0x10000ull, 0x100000000ull};
|
|
93
104
|
if (ai >= 28) {
|
|
@@ -95,15 +106,28 @@ static int cbor_arg(yep_cdec* c, uint8_t ai, uint64_t* val) {
|
|
|
95
106
|
}
|
|
96
107
|
uint64_t v = ai;
|
|
97
108
|
if (ai >= 24) {
|
|
109
|
+
const unsigned char* q = c->p + c->i;
|
|
98
110
|
size_t n = nbytes[ai - 24];
|
|
99
111
|
if (c->len - c->i < n) {
|
|
100
112
|
cbor_fail(c, YEP_ERR_UNEXPECTED, "truncated head");
|
|
101
113
|
c->status = YEPTRIS_ERROR_PARSE;
|
|
102
114
|
return 0;
|
|
103
115
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
v =
|
|
116
|
+
switch (n) {
|
|
117
|
+
case 1:
|
|
118
|
+
v = q[0];
|
|
119
|
+
break;
|
|
120
|
+
case 2:
|
|
121
|
+
v = ((uint64_t)q[0] << 8) | q[1];
|
|
122
|
+
break;
|
|
123
|
+
case 4:
|
|
124
|
+
v = ((uint64_t)q[0] << 24) | ((uint64_t)q[1] << 16) | ((uint64_t)q[2] << 8) | q[3];
|
|
125
|
+
break;
|
|
126
|
+
default: /* 8 */
|
|
127
|
+
v = ((uint64_t)q[0] << 56) | ((uint64_t)q[1] << 48) | ((uint64_t)q[2] << 40) |
|
|
128
|
+
((uint64_t)q[3] << 32) | ((uint64_t)q[4] << 24) | ((uint64_t)q[5] << 16) |
|
|
129
|
+
((uint64_t)q[6] << 8) | q[7];
|
|
130
|
+
break;
|
|
107
131
|
}
|
|
108
132
|
c->i += n;
|
|
109
133
|
if (c->strict && v < minv[ai - 24]) {
|
|
@@ -811,12 +835,24 @@ static const yep_cbor_sink yep_cbor_dom_sink_impl = {
|
|
|
811
835
|
int yep_cbor_decode_gen(const unsigned char* p, size_t len, int strict, size_t* consumed,
|
|
812
836
|
const yep_cbor_sink* sink) {
|
|
813
837
|
yep_cdec c;
|
|
814
|
-
|
|
815
|
-
|
|
838
|
+
/* field init, not memset: the struct carries the 1000-deep frame
|
|
839
|
+
* stack (~24 KB) and the decode profile shows small payloads pay
|
|
840
|
+
* it per call (a 100-byte item memset 200x its size). Every frame
|
|
841
|
+
* slot is written by cbor_open/the gen loop before it is read, so
|
|
842
|
+
* the stack needs no zero-init; tagbuf is guarded by taglen. */
|
|
843
|
+
c.d = NULL;
|
|
816
844
|
c.p = p;
|
|
817
845
|
c.len = len;
|
|
846
|
+
c.i = 0;
|
|
818
847
|
c.strict = strict;
|
|
819
848
|
c.status = YEPTRIS_OK;
|
|
849
|
+
c.taglen = 0;
|
|
850
|
+
c.taglinks = 0;
|
|
851
|
+
c.ibuf = NULL;
|
|
852
|
+
c.icap = 0;
|
|
853
|
+
c.ilen = 0;
|
|
854
|
+
c.s = sink;
|
|
855
|
+
c.depth = 0;
|
|
820
856
|
int done_top = 0; /* the ONE top-level item is done (tags never count) */
|
|
821
857
|
int rc;
|
|
822
858
|
for (;;) {
|
|
@@ -731,9 +731,17 @@ static int jb_string_node(jbuilder* b) {
|
|
|
731
731
|
}
|
|
732
732
|
n->value = yep_dom_str_commit(
|
|
733
733
|
b->d, yep_finish_double_into(b->p, (uint32_t)(start + 1), (uint32_t)close, dst, span));
|
|
734
|
+
/* decoded bytes can carry anything the escapes spelled: one
|
|
735
|
+
* scan prices the fact (#739); 0 keeps the emit-side loop */
|
|
736
|
+
yep_view dec = yep_dom_view(b->d, n->value);
|
|
737
|
+
n->json_clean = (uint8_t)yep_scan_json_clean(dec.p, dec.len);
|
|
734
738
|
} else {
|
|
735
739
|
yep_view v = {b->p + start + 1, (uint32_t)(close - start - 1)};
|
|
736
740
|
n->value = dom_str_in(b->d, &v, 1);
|
|
741
|
+
/* the zero-copy law pays the fact for free: strict JSON
|
|
742
|
+
* forbids raw C0 in strings, and an unescaped span carries no
|
|
743
|
+
* '"'/'\' by the scanner's own termination rule (#739) */
|
|
744
|
+
n->json_clean = 1;
|
|
737
745
|
}
|
|
738
746
|
n->style = YEP_STYLE_DOUBLE_QUOTED;
|
|
739
747
|
n->tag_id = 0; /* str */
|
|
@@ -771,6 +779,8 @@ static int jb_scalar_node(jbuilder* b) {
|
|
|
771
779
|
n->value = dom_str_in(b->d, &v, 1);
|
|
772
780
|
n->style = YEP_STYLE_PLAIN;
|
|
773
781
|
n->implicit = 1;
|
|
782
|
+
/* literal/number tokens are [a-z0-9+-.]: JSON-clean by grammar */
|
|
783
|
+
n->json_clean = 1;
|
|
774
784
|
n->tag_id = r->resolve(NULL, v.p, v.len);
|
|
775
785
|
return dom_place(b->d, id) == 0 ? 0 : -1;
|
|
776
786
|
}
|
|
@@ -1159,9 +1169,17 @@ int dom_from_tape(yep_dom* d, const yeptris_json_tape* t) {
|
|
|
1159
1169
|
d, yep_finish_double_into(src, off, off + len, dst, len));
|
|
1160
1170
|
d->nodes[id].no_exotic = 1; /* JSON-class: escapes
|
|
1161
1171
|
only, the walker's law */
|
|
1172
|
+
{
|
|
1173
|
+
yep_view dec = yep_dom_view(d, d->nodes[id].value);
|
|
1174
|
+
d->nodes[id].json_clean = (uint8_t)yep_scan_json_clean(dec.p, dec.len);
|
|
1175
|
+
}
|
|
1162
1176
|
} else {
|
|
1163
1177
|
yep_view v = {src + off, len};
|
|
1164
1178
|
dom_set_value(d, id, &v, 1);
|
|
1179
|
+
/* the tape seam rides both tape flavors: one scan
|
|
1180
|
+
* prices the fact instead of trusting the grammar
|
|
1181
|
+
* (the lenient route is not the strict gate) */
|
|
1182
|
+
d->nodes[id].json_clean = (uint8_t)yep_scan_json_clean(src + off, len);
|
|
1165
1183
|
}
|
|
1166
1184
|
} else {
|
|
1167
1185
|
yep_view v = {src + off, len};
|
|
@@ -60,22 +60,30 @@ typedef struct yep_sview {
|
|
|
60
60
|
* fields left the record — they live in the DOM's lazily-built side
|
|
61
61
|
* tables (parse pays nothing; dom.c owns them). */
|
|
62
62
|
typedef struct yep_dnode {
|
|
63
|
-
uint8_t kind : 2;
|
|
64
|
-
uint8_t style : 3;
|
|
65
|
-
uint8_t flow : 1;
|
|
66
|
-
uint8_t implicit : 1;
|
|
67
|
-
uint8_t no_exotic : 1;
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
uint8_t plain_ok;
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
uint8_t
|
|
78
|
-
|
|
63
|
+
uint8_t kind : 2; /* yep_dom_kind (0-3) */
|
|
64
|
+
uint8_t style : 3; /* yep_scalar_style (0-5) */
|
|
65
|
+
uint8_t flow : 1; /* collection opened in flow style */
|
|
66
|
+
uint8_t implicit : 1; /* scalar written without quotes/tag */
|
|
67
|
+
uint8_t no_exotic : 1; /* value verified clean of the dq-forced
|
|
68
|
+
* byte set (#352 lane 2): the serializer's
|
|
69
|
+
* sc_route skips its rescan. Set at every
|
|
70
|
+
* value assignment; 0 = unknown = scan. */
|
|
71
|
+
uint8_t plain_ok : 1; /* value bytes verified yep_scan_plain_safe
|
|
72
|
+
* (#352 lane 3): the emitter skips its
|
|
73
|
+
* plain-safety walk (the block kernel's 35%
|
|
74
|
+
* frame). Same invariant as no_exotic: set
|
|
75
|
+
* at every dom_set_value; 0 = unknown =
|
|
76
|
+
* derive. */
|
|
77
|
+
uint8_t json_clean : 1; /* value bytes verified yep_scan_json_clean
|
|
78
|
+
* (#739): no '"', no '\', no C0 — the JSON
|
|
79
|
+
* writer's fused quote+memcpy arm takes it
|
|
80
|
+
* without the per-byte escape loop. Set by
|
|
81
|
+
* the JSON builders where the grammar (or
|
|
82
|
+
* one decode scan) proves it; dom_set_value
|
|
83
|
+
* leaves 0 = unknown = the byte loop, so
|
|
84
|
+
* the YAML parse path pays nothing. */
|
|
85
|
+
uint8_t tag_id; /* resolved tag (resolve/resolver.h) */
|
|
86
|
+
uint32_t first_child; /* child link (mappings: key,value,key,value…) */
|
|
79
87
|
uint32_t last_child;
|
|
80
88
|
uint32_t next_sibling;
|
|
81
89
|
uint32_t count; /* children (mappings: 2 × pairs) */
|
|
@@ -1381,6 +1381,15 @@ static int yt_f_run(yt_fused* F) {
|
|
|
1381
1381
|
root_evented = 1;
|
|
1382
1382
|
st[0].started = 1;
|
|
1383
1383
|
}
|
|
1384
|
+
if (st[0].content_col == 0) {
|
|
1385
|
+
/* the root now has content: without it the next
|
|
1386
|
+
* sibling key re-fires the contentless-root law
|
|
1387
|
+
* in yt_f_open_form, a second OPEN lands in the
|
|
1388
|
+
* root's spent-key slot and the replay pairs the
|
|
1389
|
+
* fresh map as a KEY (issue #1303 — the drain
|
|
1390
|
+
* walk is the reference law) */
|
|
1391
|
+
st[0].content_col = st[depth].indent + 1;
|
|
1392
|
+
}
|
|
1384
1393
|
} else if (!st[depth - 1].started && col != st[depth - 1].indent) {
|
|
1385
1394
|
yt_f_start(F, &st[depth - 1]);
|
|
1386
1395
|
}
|