yeptris 0.6.62.2-s390x-linux → 0.6.64.0-s390x-linux
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/extconf.rb +9 -3
- data/ext/yeptris_native/version.h +2 -2
- data/lib/yeptris/document.rb +12 -2
- data/lib/yeptris/materializer.rb +22 -1
- data/lib/yeptris/node.rb +11 -4
- data/lib/yeptris/psych/visitors.rb +13 -1
- data/lib/yeptris/psych.rb +15 -3
- data/lib/yeptris/valueml.rb +17 -2
- data/lib/yeptris/yaml.rb +16 -14
- data/lib/yeptris.rb +1 -1
- data/libyeptris.so +0 -0
- data/vendor/libyeptris/CMakeLists.txt +1 -1
- data/vendor/libyeptris/src/yeptris/emit/writer.c +96 -10
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 46ee2ae81b2f2d5a4e016a9ce08828b4a7f21cd6a0cd0abcd3fc182d8dbfba5e
|
|
4
|
+
data.tar.gz: fce3eff4d6ba394dc1cca2e19bd45269c7e2796fe675ef25f235e2cb3d294a58
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 42940f5f443d17252cb59d2cef768ff2815b6d3bec2f875ecd3fc78d12f8a63a3bb949a598ebb777bec6c0c5109b986d9e7e2d67fcb5be0f70e5ca06e70e5d53
|
|
7
|
+
data.tar.gz: aa9c2edbd760be6670811066575bc972c1246b1eaeb20236654010b4364c1f15bf2f5235af6048594fbffac903eab0479addeb000034546379eb6ff86dc4e329
|
|
@@ -61,10 +61,16 @@ else
|
|
|
61
61
|
unless File.exist?(File.join(src_root, "include", "yeptris", "version.h"))
|
|
62
62
|
if File.exist?(vhin)
|
|
63
63
|
# CMakeLists sits at the engine tree's root: the vendored gem
|
|
64
|
-
# tree (vendor/libyeptris) or the CI checkout (libyeptris-src)
|
|
65
|
-
|
|
64
|
+
# tree (vendor/libyeptris) or the CI checkout (libyeptris-src).
|
|
65
|
+
# encoding: pinned UTF-8 — the engine sources carry UTF-8 prose
|
|
66
|
+
# (em-dashes in comments), and a POSIX/C-locale environment
|
|
67
|
+
# (debian distro ruby, LC_ALL=C users building the source gem)
|
|
68
|
+
# defaults Ruby's external encoding to US-ASCII, where any byte
|
|
69
|
+
# >= 0x80 makes this regex raise "invalid byte sequence"
|
|
70
|
+
# (surfaced by the riscv64-linux platform-gem leg).
|
|
71
|
+
ver = File.read(File.join(File.dirname(src_root), "CMakeLists.txt"), encoding: "UTF-8")[/project\s*\([^)]*?VERSION\s+([0-9.]+)/m, 1] || "0.0.0"
|
|
66
72
|
maj, min, pat = ver.split(".")
|
|
67
|
-
File.write("version.h", File.read(vhin)
|
|
73
|
+
File.write("version.h", File.read(vhin, encoding: "UTF-8")
|
|
68
74
|
.gsub("@PROJECT_VERSION_MAJOR@", maj || "0")
|
|
69
75
|
.gsub("@PROJECT_VERSION_MINOR@", min || "0")
|
|
70
76
|
.gsub("@PROJECT_VERSION_PATCH@", pat || "0")
|
|
@@ -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 64
|
|
15
|
+
#define YEPTRIS_VERSION_STRING "0.6.64"
|
|
16
16
|
|
|
17
17
|
#ifdef __cplusplus
|
|
18
18
|
extern "C" {
|
data/lib/yeptris/document.rb
CHANGED
|
@@ -116,8 +116,8 @@ class Yeptris::Document
|
|
|
116
116
|
# a parse_stream on a multi-doc stream would free the same pointer
|
|
117
117
|
# three times at GC → SIGABRT. This factory builds the wrapper
|
|
118
118
|
# WITHOUT a finalizer; the wrapper's lifetime follows the owner.
|
|
119
|
-
def self.without_finalizer(c_ptr)
|
|
120
|
-
doc = new(c_ptr)
|
|
119
|
+
def self.without_finalizer(c_ptr, source = nil)
|
|
120
|
+
doc = new(c_ptr, Freed.new(:alive), :core_12, source)
|
|
121
121
|
ObjectSpace.undefine_finalizer(doc)
|
|
122
122
|
doc
|
|
123
123
|
end
|
|
@@ -157,6 +157,16 @@ class Yeptris::Document
|
|
|
157
157
|
@readonly_memo ||= {}
|
|
158
158
|
end
|
|
159
159
|
|
|
160
|
+
# @api private — whether the C marshal materialization lane may
|
|
161
|
+
# serve this document: refused when the parse source carries a
|
|
162
|
+
# quoted-symbol literal's byte fingerprint (the C builder names
|
|
163
|
+
# symbols from the raw scalar text and keeps the quotes, #1304 —
|
|
164
|
+
# the Ruby walks own the strip until the engine strip lands).
|
|
165
|
+
# Memoized: the verdict is a property of the immutable source.
|
|
166
|
+
def marshal_lane_ok?
|
|
167
|
+
@marshal_lane_ok ||= @source.nil? || ::Yeptris::ValueML.marshal_lane_ok?(@source)
|
|
168
|
+
end
|
|
169
|
+
|
|
160
170
|
# @api private — the single Node construction path. Query handles
|
|
161
171
|
# are transient C allocations; the wrapper cache is keyed on the
|
|
162
172
|
# STABLE node id (yeptris_node_id), so the same node always yields
|
data/lib/yeptris/materializer.rb
CHANGED
|
@@ -50,7 +50,28 @@ module Yeptris
|
|
|
50
50
|
SEXAGESIMAL_INT = /\A[-+]?[1-9][0-9_]*(:[0-5]?[0-9])+\z/
|
|
51
51
|
SEXAGESIMAL_FLOAT = /\A[-+]?[0-9][0-9_]*(:[0-5]?[0-9])+:[0-5]?[0-9]\.[0-9_]*\z/
|
|
52
52
|
|
|
53
|
+
# Psych's quoted-symbol capture (scalar_scanner tokenize, the /^:/
|
|
54
|
+
# arm): /^:(["'])(.*)\1/ — a QUOTED symbol literal names the
|
|
55
|
+
# UNQUOTED string; the quotes are the scanner's, not the name's
|
|
56
|
+
# (#1304 — the plain-text strip rode every face as :"\"x y\"").
|
|
57
|
+
# Escapes do not decode: the literal is a plain scalar, so the
|
|
58
|
+
# inner text is captured byte for byte. Greedy .* + the backref —
|
|
59
|
+
# psych's own spelling, no end anchor.
|
|
60
|
+
QUOTED_SYMBOL = /\A:(["'])(.*)\1/
|
|
61
|
+
|
|
53
62
|
class << self
|
|
63
|
+
# The scalar→Symbol name law, ONE place: the quoted literal form
|
|
64
|
+
# (:"x y" / :'q z') strips the quoting before resolution; the
|
|
65
|
+
# bare form strips only the leading colon. Every materialization
|
|
66
|
+
# face rides this — the record walk (scan_by_tag), the columns
|
|
67
|
+
# walk (str_to_value) and the DOM walk (symbolize). The callers
|
|
68
|
+
# keep the ":": guard (plain-colon-only, :: stays a String).
|
|
69
|
+
def resolve_symbol(text)
|
|
70
|
+
m = QUOTED_SYMBOL.match(text)
|
|
71
|
+
return m[2].sub(/\A:/, "").to_sym if m
|
|
72
|
+
|
|
73
|
+
text[1..].to_sym
|
|
74
|
+
end
|
|
54
75
|
# First document of the stream, or nil when the stream is empty.
|
|
55
76
|
def load(yaml, schema: :compat_11)
|
|
56
77
|
docs = load_stream(yaml, schema: schema)
|
|
@@ -155,7 +176,7 @@ module Yeptris
|
|
|
155
176
|
return value unless implicit
|
|
156
177
|
|
|
157
178
|
value.start_with?(":") && !value.start_with?("::") &&
|
|
158
|
-
value.length > 1 ? value
|
|
179
|
+
value.length > 1 ? resolve_symbol(value) : value
|
|
159
180
|
when TAG_NULL then nil
|
|
160
181
|
when TAG_BOOL
|
|
161
182
|
return value if value.length == 1 # Psych: "y"/"n" stay Strings
|
data/lib/yeptris/node.rb
CHANGED
|
@@ -289,10 +289,13 @@ class Yeptris::Node
|
|
|
289
289
|
# turns this subtree into Marshal 4.8 bytes — Marshal.load builds
|
|
290
290
|
# the Ruby objects in C, no per-node FFI. nil when the document
|
|
291
291
|
# carries constructs the format cannot express (merge keys,
|
|
292
|
-
# timestamps, tagged revivals
|
|
293
|
-
#
|
|
292
|
+
# timestamps, tagged revivals, quoted-symbol literals — the C
|
|
293
|
+
# builder names symbols from the raw text, #1304): the caller
|
|
294
|
+
# walks instead. Raises ParseError on engine errors (not on the
|
|
295
|
+
# bail).
|
|
294
296
|
def marshal_fast
|
|
295
297
|
return nil unless Yeptris::FFI::MARSHAL
|
|
298
|
+
return nil unless @document.marshal_lane_ok?
|
|
296
299
|
|
|
297
300
|
out_p = ::FFI::MemoryPointer.new(:pointer)
|
|
298
301
|
olen_p = ::FFI::MemoryPointer.new(:size_t)
|
|
@@ -456,14 +459,18 @@ class Yeptris::Node
|
|
|
456
459
|
end
|
|
457
460
|
|
|
458
461
|
# Psych's ScalarScanner: plain ":name" (and ":", the null Symbol)
|
|
459
|
-
# scans to a Symbol; quoting defeats it.
|
|
462
|
+
# scans to a Symbol; quoting defeats it. The name rides the ONE
|
|
463
|
+
# resolve law (#1304): a quoted literal form (:"x y") strips the
|
|
464
|
+
# quoting before resolution.
|
|
460
465
|
def symbol?
|
|
461
466
|
style == :plain && value&.start_with?(":") && !value.start_with?("::")
|
|
462
467
|
end
|
|
463
468
|
|
|
464
469
|
def symbolize
|
|
465
470
|
v = value
|
|
466
|
-
|
|
471
|
+
return :"" if v.length <= 1
|
|
472
|
+
|
|
473
|
+
::Yeptris::Materializer.resolve_symbol(v)
|
|
467
474
|
end
|
|
468
475
|
|
|
469
476
|
|
|
@@ -229,7 +229,19 @@ module Yeptris
|
|
|
229
229
|
key_node.set_tag("tag:yaml.org,2002:str")
|
|
230
230
|
m.map_add_node(key_node, visit(v))
|
|
231
231
|
else
|
|
232
|
-
|
|
232
|
+
# String keys ride psych's ONE visit_String law (the
|
|
233
|
+
# reshape words quote in key position too: "n": 1,
|
|
234
|
+
# 'yes': ... — #1264's premise had the psych side
|
|
235
|
+
# inverted; stdlib quotes these keys on every version
|
|
236
|
+
# since 4.0.2). Symbols stay :sym text (never through
|
|
237
|
+
# visit_String), matching stdlib.
|
|
238
|
+
key_node =
|
|
239
|
+
if k.is_a?(::String)
|
|
240
|
+
::Yeptris::YAML::Builder.build_string(@tree, k)
|
|
241
|
+
else
|
|
242
|
+
@tree.new_scalar(key_text(k), :plain)
|
|
243
|
+
end
|
|
244
|
+
m.map_add_node(key_node, visit(v))
|
|
233
245
|
end
|
|
234
246
|
end
|
|
235
247
|
m
|
data/lib/yeptris/psych.rb
CHANGED
|
@@ -560,9 +560,21 @@ module Yeptris
|
|
|
560
560
|
end
|
|
561
561
|
end
|
|
562
562
|
end
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
563
|
+
# psych's safe law for the timestamp family (#1305): the gate
|
|
564
|
+
# applies to the RESOLVED class, not the tag. A plain
|
|
565
|
+
# timestamp resolves like psych's scanner — date-only to
|
|
566
|
+
# Date, date+time to Time (ClassLoader::Restricted#time /
|
|
567
|
+
# #date raise DisallowedClass naming the class) — so the
|
|
568
|
+
# decision rides the ONE resolver the materializer itself
|
|
569
|
+
# uses (parse_timestamp); a malformed timestamp text
|
|
570
|
+
# resolves to String there and psych likewise yields a
|
|
571
|
+
# String (no gate — plain data).
|
|
572
|
+
if node.kind == :scalar && node.tag_id == :timestamp
|
|
573
|
+
resolved = ::Yeptris::Materializer.parse_timestamp(node.value.to_s)
|
|
574
|
+
klass = resolved.class
|
|
575
|
+
if (klass == ::Date || klass == ::Time) && !permitted.include?(klass)
|
|
576
|
+
raise DisallowedClass, klass.name
|
|
577
|
+
end
|
|
566
578
|
end
|
|
567
579
|
case node.kind
|
|
568
580
|
when :mapping
|
data/lib/yeptris/valueml.rb
CHANGED
|
@@ -26,19 +26,34 @@ module Yeptris
|
|
|
26
26
|
# Symbol (Psych's ScalarScanner; quoted ':x' stays a String).
|
|
27
27
|
# Every str-column conversion rides this — the pair fast path
|
|
28
28
|
# drifted once and handed bignums/symbol-keys through as Strings
|
|
29
|
-
# (audit 2026-10-31).
|
|
29
|
+
# (audit 2026-10-31). The Symbol arm rides Materializer.resolve_symbol
|
|
30
|
+
# (#1304: the quoted literal form strips its quoting).
|
|
30
31
|
def self.str_to_value(text, typed)
|
|
31
32
|
return text unless typed
|
|
32
33
|
|
|
33
34
|
if text.length > 18 && PSYCH_INT_SHAPE.match?(text)
|
|
34
35
|
text.delete(",_").to_i
|
|
35
36
|
elsif text.length > 1 && text.start_with?(":") && !text.start_with?("::")
|
|
36
|
-
text
|
|
37
|
+
::Yeptris::Materializer.resolve_symbol(text)
|
|
37
38
|
else
|
|
38
39
|
text
|
|
39
40
|
end
|
|
40
41
|
end
|
|
41
42
|
|
|
43
|
+
# A quoted-symbol literal's byte fingerprint: the plain text of
|
|
44
|
+
# `:"x y"` / `:'q z'` carries the colon DIRECTLY followed by a
|
|
45
|
+
# quote. A source that contains it may name a quoted symbol, and
|
|
46
|
+
# the C marshal builder names symbols from the raw scalar text —
|
|
47
|
+
# it strips the leading colon but keeps the quotes (engine finding,
|
|
48
|
+
# #1304). The binding refuses the marshal lane for such sources and
|
|
49
|
+
# walks in Ruby, where the strip law lives; when the engine strip
|
|
50
|
+
# lands, the lane reopens by relaxing this one predicate.
|
|
51
|
+
QUOTED_SYMBOL_TEXT = /:(["'])/.freeze
|
|
52
|
+
|
|
53
|
+
def self.marshal_lane_ok?(source)
|
|
54
|
+
!QUOTED_SYMBOL_TEXT.match?(source)
|
|
55
|
+
end
|
|
56
|
+
|
|
42
57
|
V_TS = 6
|
|
43
58
|
SEQ_OPEN = 7
|
|
44
59
|
MAP_OPEN = 8
|
data/lib/yeptris/yaml.rb
CHANGED
|
@@ -236,7 +236,7 @@ module Yeptris
|
|
|
236
236
|
|
|
237
237
|
index = FFI.read_c_size_t(idx_p)
|
|
238
238
|
if st == FFI::OK
|
|
239
|
-
doc = Document.without_finalizer(doc_ptr)
|
|
239
|
+
doc = Document.without_finalizer(doc_ptr, yaml)
|
|
240
240
|
begin
|
|
241
241
|
yield doc.to_ruby, nil
|
|
242
242
|
ensure
|
|
@@ -261,8 +261,11 @@ module Yeptris
|
|
|
261
261
|
# The Marshal fast path when the loaded libyeptris has it (>= 0.1.11
|
|
262
262
|
# era builds), falling back to the columnar drain and finally the
|
|
263
263
|
# record drain — one code path, the fastest the library offers.
|
|
264
|
+
# The marshal lane is refused for sources that may name a quoted
|
|
265
|
+
# symbol: the C builder keeps the quotes in the name (#1304), and
|
|
266
|
+
# the columns/record walks carry the strip law.
|
|
264
267
|
def _drain_all(yaml, schema)
|
|
265
|
-
if FFI::MARSHAL
|
|
268
|
+
if FFI::MARSHAL && ValueML.marshal_lane_ok?(yaml)
|
|
266
269
|
result = ValueML.load_all_marshal(yaml, schema: schema, mode: :all)
|
|
267
270
|
return result unless result.nil?
|
|
268
271
|
end
|
|
@@ -414,13 +417,13 @@ module Yeptris
|
|
|
414
417
|
blob << "!!str"
|
|
415
418
|
off[0] += 5
|
|
416
419
|
elsif k.is_a?(String)
|
|
417
|
-
# keys ride
|
|
418
|
-
#
|
|
419
|
-
#
|
|
420
|
-
#
|
|
421
|
-
#
|
|
422
|
-
#
|
|
423
|
-
style =
|
|
420
|
+
# keys ride psych's ONE visit_String law — stdlib applies
|
|
421
|
+
# it to keys and values alike, so the reshape words quote
|
|
422
|
+
# in BOTH positions ("n": 1, 'yes': ...; #1264's premise
|
|
423
|
+
# had the psych side inverted: stdlib quotes these keys
|
|
424
|
+
# on every version since 4.0.2). The engine's own
|
|
425
|
+
# plain-key-safety re-check still guards the position.
|
|
426
|
+
style = STYLE_BY_NAME[string_style(k)]
|
|
424
427
|
scalar(k, style, emit, blob, off)
|
|
425
428
|
else
|
|
426
429
|
scalar(k.to_s, STYLE_PLAIN, emit, blob, off)
|
|
@@ -544,11 +547,10 @@ module Yeptris
|
|
|
544
547
|
return :double if !s.empty? && !s.include?('"') && s.match?(/\A[^[:word:]]/)
|
|
545
548
|
return :single if s.match?(/\A0[0-7]*[89]/)
|
|
546
549
|
return :plain if plain_string?(s)
|
|
547
|
-
#
|
|
548
|
-
#
|
|
549
|
-
#
|
|
550
|
-
#
|
|
551
|
-
return :double if s.each_byte.any? { |b| b < 0x20 || b == 0x7f }
|
|
550
|
+
# \n and \r are BREAKS in libyaml, not specials - the emitter's
|
|
551
|
+
# single-quoted law carries them ('x y z\n\n ': single_quoted_
|
|
552
|
+
# allowed survives line breaks, #1264's family A); other C0
|
|
553
|
+
# bytes and DEL need the escapes
|
|
552
554
|
return :double if s.match?(/[\u0085\u2028\u2029\uFEFF]/)
|
|
553
555
|
:single
|
|
554
556
|
end
|
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.64.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
|
|
@@ -372,8 +372,11 @@ static void emit_sq(yep_writer* w, const char* p, uint32_t n) {
|
|
|
372
372
|
* indent to parent_indent + best_indent for the scalar's own lines).
|
|
373
373
|
* The folded bodies carry no breaks by construction: sc_route sends
|
|
374
374
|
* multiline content to DQ/literal, so the walk only decides on ' '
|
|
375
|
-
* (IS_SPACE — a tab is content).
|
|
376
|
-
*
|
|
375
|
+
* (IS_SPACE — a tab is content). EXCEPTION (#1268): single-quoted
|
|
376
|
+
* bodies may carry breaks when the value is single-able (no
|
|
377
|
+
* space_break/break_space/specials) — emit_sq_folded renders those
|
|
378
|
+
* breaks per libyaml's write_single_quoted. Columns are BYTES, matching
|
|
379
|
+
* the engine's existing 13B flow fold; libyaml counts characters, so
|
|
377
380
|
* multi-byte content folds at slightly different points (documented
|
|
378
381
|
* divergence, ASCII input folds byte-identically). */
|
|
379
382
|
|
|
@@ -393,7 +396,7 @@ static void emit_plain_folded(yep_writer* w, const char* p, uint32_t n, int fold
|
|
|
393
396
|
uint32_t i = 0;
|
|
394
397
|
while (i < n) {
|
|
395
398
|
if (p[i] == ' ' && i > 0 && i + 1 < n && w->col + (int)run > w->best_width &&
|
|
396
|
-
p[i - 1] != ' ' && p[i + 1] != ' ') {
|
|
399
|
+
p[i - 1] != ' ' && p[i + 1] != ' ' && p[i - 1] != '\t' && p[i + 1] != '\t') {
|
|
397
400
|
if (run) {
|
|
398
401
|
wr_put(w, p + i - run, run);
|
|
399
402
|
run = 0;
|
|
@@ -410,14 +413,64 @@ static void emit_plain_folded(yep_writer* w, const char* p, uint32_t n, int fold
|
|
|
410
413
|
}
|
|
411
414
|
}
|
|
412
415
|
|
|
416
|
+
/* libyaml's single_quoted_allowed predicate (emitter.c analyze):
|
|
417
|
+
* disabled ONLY by special characters, a space immediately before a
|
|
418
|
+
* break (space_break), or a break immediately followed by a space
|
|
419
|
+
* (break_space). line_breaks and trailing_space do NOT kill it — so a
|
|
420
|
+
* trailing-newline scalar like "x y z\n" rides single-quoted in
|
|
421
|
+
* libyaml/psych ('x y z\n\n '), not double-quoted. */
|
|
422
|
+
static int writer_sq_allowed(const char* p, uint32_t n) {
|
|
423
|
+
uint32_t i;
|
|
424
|
+
for (i = 0; i < n; i++) {
|
|
425
|
+
unsigned char c = (unsigned char)p[i];
|
|
426
|
+
if (c < 0x20 && c != '\n' && c != '\r') {
|
|
427
|
+
return 0; /* special characters (the breaks ride the two
|
|
428
|
+
adjacency checks below) */
|
|
429
|
+
}
|
|
430
|
+
if (c == 0x7f) {
|
|
431
|
+
return 0;
|
|
432
|
+
}
|
|
433
|
+
if (c == ' ' && i + 1 < n && (p[i + 1] == '\n' || p[i + 1] == '\r')) {
|
|
434
|
+
return 0; /* space_break */
|
|
435
|
+
}
|
|
436
|
+
if ((c == '\n' || c == '\r') && i + 1 < n && p[i + 1] == ' ') {
|
|
437
|
+
return 0; /* break_space */
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
return 1;
|
|
441
|
+
}
|
|
442
|
+
|
|
413
443
|
/* The single-quoted twin: '' doubling rides the same walk (a doubled
|
|
414
444
|
* apostrophe is two written bytes; the column tracking through wr_put
|
|
415
|
-
* prices it in automatically).
|
|
445
|
+
* prices it in automatically). Content breaks render libyaml's
|
|
446
|
+
* write_single_quoted law: the first '\n' of a run writes an extra
|
|
447
|
+
* break (single-quoted clips one raw newline per content newline on
|
|
448
|
+
* re-parse), each break byte writes as-is, the byte after a break run
|
|
449
|
+
* re-indents to the fold column, and a trailing break re-indents
|
|
450
|
+
* before the closing quote (#1268: 'x y z\n\n '). */
|
|
416
451
|
static void emit_sq_folded(yep_writer* w, const char* p, uint32_t n, int fold_col) {
|
|
417
452
|
wr_byte(w, '\'');
|
|
418
453
|
uint32_t run = 0;
|
|
419
454
|
uint32_t i = 0;
|
|
455
|
+
int breaks = 0;
|
|
420
456
|
while (i < n) {
|
|
457
|
+
if (p[i] == '\n' || p[i] == '\r') {
|
|
458
|
+
if (run) {
|
|
459
|
+
wr_put(w, p + i - run, run);
|
|
460
|
+
run = 0;
|
|
461
|
+
}
|
|
462
|
+
if (!breaks && p[i] == '\n') {
|
|
463
|
+
wr_byte(w, '\n');
|
|
464
|
+
}
|
|
465
|
+
wr_byte(w, p[i]);
|
|
466
|
+
breaks = 1;
|
|
467
|
+
i++;
|
|
468
|
+
continue;
|
|
469
|
+
}
|
|
470
|
+
if (breaks) {
|
|
471
|
+
wr_indent(w, fold_col);
|
|
472
|
+
breaks = 0;
|
|
473
|
+
}
|
|
421
474
|
if (p[i] == '\'') {
|
|
422
475
|
if (run) {
|
|
423
476
|
wr_put(w, p + i - run, run);
|
|
@@ -428,7 +481,7 @@ static void emit_sq_folded(yep_writer* w, const char* p, uint32_t n, int fold_co
|
|
|
428
481
|
continue;
|
|
429
482
|
}
|
|
430
483
|
if (p[i] == ' ' && i > 0 && i + 1 < n && w->col + (int)run > w->best_width &&
|
|
431
|
-
p[i - 1] != ' ' && p[i + 1] != ' ') {
|
|
484
|
+
p[i - 1] != ' ' && p[i + 1] != ' ' && p[i - 1] != '\t' && p[i + 1] != '\t') {
|
|
432
485
|
if (run) {
|
|
433
486
|
wr_put(w, p + i - run, run);
|
|
434
487
|
run = 0;
|
|
@@ -440,7 +493,9 @@ static void emit_sq_folded(yep_writer* w, const char* p, uint32_t n, int fold_co
|
|
|
440
493
|
i++;
|
|
441
494
|
run++;
|
|
442
495
|
}
|
|
443
|
-
if (
|
|
496
|
+
if (breaks) {
|
|
497
|
+
wr_indent(w, fold_col);
|
|
498
|
+
} else if (run) {
|
|
444
499
|
wr_put(w, p + n - run, run);
|
|
445
500
|
}
|
|
446
501
|
wr_byte(w, '\'');
|
|
@@ -732,17 +787,33 @@ static uint8_t sc_route(yep_writer* w, const char* p, uint32_t len, int as_key,
|
|
|
732
787
|
int multiline = (len > 0 && memchr(p, '\n', len) != NULL);
|
|
733
788
|
int blockable = 0;
|
|
734
789
|
if (multiline && !as_key) {
|
|
790
|
+
/* libyaml's block_allowed law: trailing_space (a trailing
|
|
791
|
+
* blank), space_break (a blank immediately before a break) and
|
|
792
|
+
* special characters kill the block forms (#1264's family-A
|
|
793
|
+
* control: "x \ny" stays DQ, not `|-` with a trailing-space
|
|
794
|
+
* line); the all-whitespace and CR exclusions are the
|
|
795
|
+
* engine's established law */
|
|
735
796
|
int allws = 1;
|
|
736
797
|
int has_cr = 0;
|
|
798
|
+
int space_break = 0;
|
|
799
|
+
int trailing_blank = 0;
|
|
737
800
|
for (uint32_t i = 0; i < len; i++) {
|
|
738
|
-
|
|
801
|
+
unsigned char c = (unsigned char)p[i];
|
|
802
|
+
if (c != ' ' && c != '\t' && c != '\n' && c != '\r') {
|
|
739
803
|
allws = 0;
|
|
740
804
|
}
|
|
741
|
-
if (
|
|
805
|
+
if (c == '\r') {
|
|
742
806
|
has_cr = 1;
|
|
743
807
|
}
|
|
808
|
+
if ((c == ' ' || c == '\t') && i + 1 < len && (p[i + 1] == '\n' || p[i + 1] == '\r')) {
|
|
809
|
+
space_break = 1;
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
if (len > 0) {
|
|
813
|
+
unsigned char last = (unsigned char)p[len - 1];
|
|
814
|
+
trailing_blank = last == ' ' || last == '\t';
|
|
744
815
|
}
|
|
745
|
-
blockable = !allws && !has_cr;
|
|
816
|
+
blockable = !allws && !has_cr && !space_break && !trailing_blank;
|
|
746
817
|
}
|
|
747
818
|
uint8_t sty = sty_in;
|
|
748
819
|
if (sty == 4 || sty == 5) {
|
|
@@ -799,9 +870,24 @@ static uint8_t sc_route(yep_writer* w, const char* p, uint32_t len, int as_key,
|
|
|
799
870
|
}
|
|
800
871
|
return YEP_SC_SQ;
|
|
801
872
|
}
|
|
873
|
+
/* libyaml's analyze keeps single_quoted_allowed through plain
|
|
874
|
+
* line breaks (only special_characters/space_break/break_space
|
|
875
|
+
* kill it), so a multiline plain-unsafe VALUE rides
|
|
876
|
+
* single-quoted — psych's 'x y z\n\n ' shape (#1268). Keys
|
|
877
|
+
* never go multiline-simple, and flow bodies ride the
|
|
878
|
+
* breakless emit_sq, so both stay DQ. */
|
|
879
|
+
if (!as_key && !w->in_flow && writer_sq_allowed(p, len)) {
|
|
880
|
+
return YEP_SC_SQ;
|
|
881
|
+
}
|
|
802
882
|
return YEP_SC_DQ;
|
|
803
883
|
case 2:
|
|
804
|
-
|
|
884
|
+
if (!multiline) {
|
|
885
|
+
return YEP_SC_SQ;
|
|
886
|
+
}
|
|
887
|
+
if (!as_key && !w->in_flow && writer_sq_allowed(p, len)) {
|
|
888
|
+
return YEP_SC_SQ;
|
|
889
|
+
}
|
|
890
|
+
return YEP_SC_DQ;
|
|
805
891
|
default:
|
|
806
892
|
return YEP_SC_DQ;
|
|
807
893
|
}
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: yeptris
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.6.
|
|
4
|
+
version: 0.6.64.0
|
|
5
5
|
platform: s390x-linux
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-11-
|
|
11
|
+
date: 2026-11-13 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: ffi
|