From 12679ab7d3c2a210f4123163671b532b8b55d5f9 Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Fri, 15 Mar 2024 03:06:35 +0000 Subject: CTAN sync 202403150306 --- .../tlpkg/tlperl/lib/TAP/Parser/YAMLish/Reader.pm | 27 +++++++++++++++----- .../tlpkg/tlperl/lib/TAP/Parser/YAMLish/Writer.pm | 29 ++++++++++++++-------- 2 files changed, 40 insertions(+), 16 deletions(-) (limited to 'systems/texlive/tlnet/tlpkg/tlperl/lib/TAP/Parser/YAMLish') diff --git a/systems/texlive/tlnet/tlpkg/tlperl/lib/TAP/Parser/YAMLish/Reader.pm b/systems/texlive/tlnet/tlpkg/tlperl/lib/TAP/Parser/YAMLish/Reader.pm index eafc37aa0c..1c122300a3 100644 --- a/systems/texlive/tlnet/tlpkg/tlperl/lib/TAP/Parser/YAMLish/Reader.pm +++ b/systems/texlive/tlnet/tlpkg/tlperl/lib/TAP/Parser/YAMLish/Reader.pm @@ -5,16 +5,21 @@ use warnings; use base 'TAP::Object'; -our $VERSION = '3.43'; +our $VERSION = '3.44'; + + # No EBCDIC support on early perls +*to_native = (ord "A" == 65 || $] < 5.008) + ? sub { return shift } + : sub { utf8::unicode_to_native(shift) }; # TODO: # Handle blessed object syntax # Printable characters for escapes my %UNESCAPES = ( - z => "\x00", a => "\x07", t => "\x09", - n => "\x0a", v => "\x0b", f => "\x0c", - r => "\x0d", e => "\x1b", '\\' => '\\', + z => "\x00", a => "\a", t => "\t", + n => "\n", v => "\cK", f => "\f", + r => "\r", e => "\e", '\\' => '\\', ); my $QQ_STRING = qr{ " (?:\\. | [^"])* " }x; @@ -22,6 +27,7 @@ my $HASH_LINE = qr{ ^ ($QQ_STRING|\S+) \s* : \s* (?: (.+?) \s* )? $ }x; my $IS_HASH_KEY = qr{ ^ [\w\'\"] }x; my $IS_END_YAML = qr{ ^ \.\.\. \s* $ }x; my $IS_QQ_STRING = qr{ ^ $QQ_STRING $ }x; +my $IS_ARRAY_LINE = qr{ ^ - \s* ($QQ_STRING|\S+) }x; # new() implementation supplied by TAP::Object @@ -117,7 +123,8 @@ sub _read_qq { $str =~ s/\\"/"/gx; $str =~ s/ \\ ( [tartan\\favez] | x([0-9a-fA-F]{2}) ) - / (length($1) > 1) ? pack("H2", $2) : $UNESCAPES{$1} /gex; + / (length($1) > 1) ? pack("H2", to_native($2)) + : $UNESCAPES{$1} /gex; return $str; } @@ -240,9 +247,17 @@ sub _read_hash { my ( $key, $value ) = ( $self->_read_scalar($1), $2 ); $self->_next; + my ( $next_line, $next_indent ) = $self->_peek; + if ( defined $value ) { $hash->{$key} = $self->_read_scalar($value); } + elsif (not defined $value # no explicit undef ("~") given + and $next_indent <= $limit # next line is same or less indentation + and $next_line !~ $IS_ARRAY_LINE) # arrays can start at same indent + { + $hash->{$key} = undef; + } else { $hash->{$key} = $self->_read_nested; } @@ -269,7 +284,7 @@ TAP::Parser::YAMLish::Reader - Read YAMLish data from iterator =head1 VERSION -Version 3.43 +Version 3.44 =head1 SYNOPSIS diff --git a/systems/texlive/tlnet/tlpkg/tlperl/lib/TAP/Parser/YAMLish/Writer.pm b/systems/texlive/tlnet/tlpkg/tlperl/lib/TAP/Parser/YAMLish/Writer.pm index 9d6366c325..1199cf45bf 100644 --- a/systems/texlive/tlnet/tlpkg/tlperl/lib/TAP/Parser/YAMLish/Writer.pm +++ b/systems/texlive/tlnet/tlpkg/tlperl/lib/TAP/Parser/YAMLish/Writer.pm @@ -5,17 +5,26 @@ use warnings; use base 'TAP::Object'; -our $VERSION = '3.43'; +our $VERSION = '3.44'; -my $ESCAPE_CHAR = qr{ [ \x00-\x1f \" ] }x; + # No EBCDIC support on early perls +*from_native = (ord "A" == 65 || $] < 5.008) + ? sub { return shift } + : sub { utf8::native_to_unicode(shift) }; + +my $ESCAPE_CHAR = qr{ [ [:cntrl:] \" ] }x; my $ESCAPE_KEY = qr{ (?: ^\W ) | $ESCAPE_CHAR }x; -my @UNPRINTABLE = qw( - z x01 x02 x03 x04 x05 x06 a - x08 t n v f r x0e x0f - x10 x11 x12 x13 x14 x15 x16 x17 - x18 x19 x1a e x1c x1d x1e x1f -); +my @UNPRINTABLE; +$UNPRINTABLE[$_] = sprintf("x%02x", from_native($_)) for 0 .. ord(" ") - 1; +$UNPRINTABLE[ord "\0"] = 'z'; +$UNPRINTABLE[ord "\a"] = 'a'; +$UNPRINTABLE[ord "\t"] = 't'; +$UNPRINTABLE[ord "\n"] = 'n'; +$UNPRINTABLE[ord "\cK"] = 'v'; +$UNPRINTABLE[ord "\f"] = 'f'; +$UNPRINTABLE[ord "\r"] = 'r'; +$UNPRINTABLE[ord "\e"] = 'e'; # new() implementation supplied by TAP::Object @@ -76,7 +85,7 @@ sub _enc_scalar { if ( $val =~ /$rule/ ) { $val =~ s/\\/\\\\/g; $val =~ s/"/\\"/g; - $val =~ s/ ( [\x00-\x1f] ) / '\\' . $UNPRINTABLE[ ord($1) ] /gex; + $val =~ s/ ( [[:cntrl:]] ) / '\\' . $UNPRINTABLE[ ord($1) ] /gex; return qq{"$val"}; } @@ -146,7 +155,7 @@ TAP::Parser::YAMLish::Writer - Write YAMLish data =head1 VERSION -Version 3.43 +Version 3.44 =head1 SYNOPSIS -- cgit v1.2.3