Skip to content
This repository has been archived by the owner on Jan 27, 2021. It is now read-only.

Commit

Permalink
Updated CPAN module YAML to version 1.23.
Browse files Browse the repository at this point in the history
  • Loading branch information
mgruner committed Jul 12, 2017
1 parent 001a835 commit 72f6a9d
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 9 deletions.
16 changes: 13 additions & 3 deletions Kernel/cpan-lib/YAML.pm
@@ -1,14 +1,24 @@
package YAML;
our $VERSION = '1.20';
our $VERSION = '1.23';

use YAML::Mo;

use Exporter;
push @YAML::ISA, 'Exporter';
our @EXPORT = qw{ Dump Load };
our @EXPORT_OK = qw{ freeze thaw DumpFile LoadFile Bless Blessed };
our (
$UseCode, $DumpCode, $LoadCode,
$SpecVersion,
$UseHeader, $UseVersion, $UseBlock, $UseFold, $UseAliases,
$Indent, $SortKeys, $Preserve,
$AnchorPrefix, $CompressSeries, $InlineSeries, $Purity,
$Stringify, $Numify
);


use YAML::Node; # XXX This is a temp fix for Module::Build
use Scalar::Util qw/ openhandle /;

# XXX This VALUE nonsense needs to go.
use constant VALUE => "\x07YAML\x07VALUE\x07";
Expand Down Expand Up @@ -44,7 +54,7 @@ sub Load {
sub DumpFile {
my $OUT;
my $filename = shift;
if (ref $filename eq 'GLOB') {
if (openhandle $filename) {
$OUT = $filename;
}
else {
Expand All @@ -70,7 +80,7 @@ sub DumpFile {
sub LoadFile {
my $IN;
my $filename = shift;
if (ref $filename eq 'GLOB') {
if (openhandle $filename) {
$IN = $filename;
}
else {
Expand Down
2 changes: 1 addition & 1 deletion Kernel/cpan-lib/YAML/Any.pm
@@ -1,6 +1,6 @@
use strict; use warnings;
package YAML::Any;
our $VERSION = '1.20';
our $VERSION = '1.23';

use Exporter ();

Expand Down
2 changes: 1 addition & 1 deletion Kernel/cpan-lib/YAML/Error.pm
Expand Up @@ -106,7 +106,7 @@ YAML_DUMP_ERR_BAD_REGEXP
YAML_LOAD_ERR_BAD_MAP_ELEMENT
Invalid element in map
YAML_LOAD_WARN_DUPLICATE_KEY
Duplicate map key found. Ignoring.
Duplicate map key '%s' found. Ignoring.
YAML_LOAD_ERR_BAD_SEQ_ELEMENT
Invalid element in sequence
YAML_PARSE_ERR_INLINE_MAP
Expand Down
14 changes: 11 additions & 3 deletions Kernel/cpan-lib/YAML/Loader.pm
Expand Up @@ -355,7 +355,7 @@ sub _parse_mapping {
$self->_parse_next_line(COLLECTION);
my $value = $self->_parse_node();
if (exists $mapping->{$key}) {
$self->warn('YAML_LOAD_WARN_DUPLICATE_KEY');
$self->warn('YAML_LOAD_WARN_DUPLICATE_KEY', $key);
}
else {
$mapping->{$key} = $value;
Expand Down Expand Up @@ -454,6 +454,11 @@ sub _parse_inline {
$node = $self->_parse_inline_simple();
}
$node = $self->_parse_implicit($node) unless $explicit;

if ($self->numify and defined $node and not ref $node and length $node
and $node =~ m/\A-?(?:0|[1-9][0-9]*)?(?:\.[0-9]*)?(?:[eE][+-]?[0-9]+)?\z/) {
$node += 0;
}
}
if ($explicit) {
$node = $self->_parse_explicit($node, $explicit);
Expand Down Expand Up @@ -486,7 +491,7 @@ sub _parse_inline_mapping {
unless $self->{inline} =~ s/^\: \s*//;
my $value = $self->_parse_inline();
if (exists $node->{$key}) {
$self->warn('YAML_LOAD_WARN_DUPLICATE_KEY');
$self->warn('YAML_LOAD_WARN_DUPLICATE_KEY', $key);
}
else {
$node->{$key} = $value;
Expand Down Expand Up @@ -638,7 +643,10 @@ sub _parse_next_line {
$self->die('YAML_EMIT_ERR_BAD_LEVEL') unless defined $offset;
shift @{$self->lines};
$self->eos($self->{done} = not @{$self->lines});
return if $self->eos;
if ($self->eos) {
$self->offset->[$level + 1] = $offset + 1;
return;
}
$self->{line}++;

# Determine the offset for a new leaf node
Expand Down
4 changes: 3 additions & 1 deletion Kernel/cpan-lib/YAML/Loader/Base.pm
Expand Up @@ -20,12 +20,14 @@ has indent => default => sub {0};
has major_version => default => sub {0};
has minor_version => default => sub {0};
has inline => default => sub {''};
has numify => default => sub {0};

sub set_global_options {
my $self = shift;
$self->load_code($YAML::LoadCode || $YAML::UseCode)
if defined $YAML::LoadCode or defined $YAML::UseCode;
$self->preserve($YAML::Preserve) if defined $YAML::Preserve
$self->preserve($YAML::Preserve) if defined $YAML::Preserve;
$self->numify($YAML::Numify) if defined $YAML::Numify;
}

sub load {
Expand Down

0 comments on commit 72f6a9d

Please sign in to comment.