Compare commits

...

4 Commits
master ... f26

Author SHA1 Message Date
Petr Písař c8ea0bbaaf Fix postentry for quoted glob 2018-01-11 10:53:55 +01:00
Petr Písař 01abe88e16 Sort build-requires 2017-12-05 11:19:52 +01:00
Petr Písař 8bbeac9f37 Fix quoting glob names 2017-12-05 11:14:48 +01:00
Petr Písař 8c253abcda perl dependency renamed to perl-interpreter <https://fedoraproject.org/wiki/Changes/perl_Package_to_Install_Core_Modules> 2017-12-05 11:13:33 +01:00
3 changed files with 261 additions and 2 deletions

View File

@ -0,0 +1,112 @@
From 76b7c82c2947d64a3494175ef6530b3fba8a499d Mon Sep 17 00:00:00 2001
From: Zefram <zefram@fysh.org>
Date: Wed, 10 Jan 2018 21:09:45 +0000
Subject: [PATCH] fix Data-Dumper postentry for quoted glob
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
In Data-Dumper, where a glob with a quoted name required a postentry,
the name part of the postentry was being emitted as just "}". This was
an old bug affecting upgraded glob names, which the recent commit
abda9fe0fe75ae824723761c1c98af958f17a41c made affect all quoted glob
names. Fix the postentry name to encompass the entire quoted name.
Fixes [perl #132695].
Petr Písař: Ported to Data-Dumpe-2.167 from perl
fb5043174b070927d312677f0a2f04a29b11349a.
Signed-off-by: Petr Písař <ppisar@redhat.com>
---
Dumper.xs | 11 ++++++-----
t/dumper.t | 32 +++++++++++++++++++++++++++++++-
2 files changed, 37 insertions(+), 6 deletions(-)
diff --git a/Dumper.xs b/Dumper.xs
index 8a16e04..206e8b5 100644
--- a/Dumper.xs
+++ b/Dumper.xs
@@ -1300,11 +1300,11 @@ DD_dump(pTHX_ SV *val, const char *name, STRLEN namelen, SV *retval, HV *seenhv,
i = 0; else i -= 4;
}
if (globname_needs_quote(c,i)) {
- sv_grow(retval, SvCUR(retval)+2);
+ sv_grow(retval, SvCUR(retval)+3);
r = SvPVX(retval)+SvCUR(retval);
- r[0] = '*'; r[1] = '{';
+ r[0] = '*'; r[1] = '{'; r[2] = 0;
SvCUR_set(retval, SvCUR(retval)+2);
- esc_q_utf8(aTHX_ retval, c, i,
+ i = 3 + esc_q_utf8(aTHX_ retval, c, i,
#ifdef GvNAMEUTF8
!!GvNAMEUTF8(val)
#else
@@ -1314,15 +1314,16 @@ DD_dump(pTHX_ SV *val, const char *name, STRLEN namelen, SV *retval, HV *seenhv,
sv_grow(retval, SvCUR(retval)+2);
r = SvPVX(retval)+SvCUR(retval);
r[0] = '}'; r[1] = '\0';
- i = 1;
+ SvCUR_set(retval, SvCUR(retval)+1);
+ r = r+1 - i;
}
else {
sv_grow(retval, SvCUR(retval)+i+2);
r = SvPVX(retval)+SvCUR(retval);
r[0] = '*'; strcpy(r+1, c);
i++;
+ SvCUR_set(retval, SvCUR(retval)+i);
}
- SvCUR_set(retval, SvCUR(retval)+i);
if (style->purity) {
static const char* const entries[] = { "{SCALAR}", "{ARRAY}", "{HASH}" };
diff --git a/t/dumper.t b/t/dumper.t
index 0c12f34..e09a2dd 100644
--- a/t/dumper.t
+++ b/t/dumper.t
@@ -108,7 +108,7 @@ sub SKIP_TEST {
++$TNUM; print "ok $TNUM # skip $reason\n";
}
-$TMAX = 456;
+$TMAX = 468;
# Force Data::Dumper::Dump to use perl. We test Dumpxs explicitly by calling
# it direct. Out here it lets us knobble the next if to test that the perl
@@ -1773,3 +1773,33 @@ EOT
TEST (q(Data::Dumper->Dumpxs([\@globs], ["globs"])), 'globs: Dumpxs()')
if $XS;
}
+#############
+$WANT = <<'EOT';
+#$v = {
+# a => \*::ppp,
+# b => \*{'::a/b'},
+# c => \*{"::a\x{2603}b"}
+#};
+#*::ppp = {
+# a => 1
+#};
+#*{'::a/b'} = {
+# b => 3
+#};
+#*{"::a\x{2603}b"} = {
+# c => 5
+#};
+EOT
+{
+ *ppp = { a => 1 };
+ *{"a/b"} = { b => 3 };
+ *{"a\x{2603}b"} = { c => 5 };
+ our $v = { a => \*ppp, b => \*{"a/b"}, c => \*{"a\x{2603}b"} };
+ local $Data::Dumper::Purity = 1;
+ TEST (q(Data::Dumper->Dump([$v], ["v"])), 'glob purity: Dump()');
+ TEST (q(Data::Dumper->Dumpxs([$v], ["v"])), 'glob purity: Dumpxs()') if $XS;
+ $WANT =~ tr/'/"/;
+ local $Data::Dumper::Useqq = 1;
+ TEST (q(Data::Dumper->Dump([$v], ["v"])), 'glob purity: Dump()');
+ TEST (q(Data::Dumper->Dumpxs([$v], ["v"])), 'glob purity: Dumpxs()') if $XS;
+}
--
2.13.6

View File

@ -0,0 +1,134 @@
From 69beb4272d324bb0724b140b5ddca517e90d89b9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
Date: Tue, 5 Dec 2017 10:59:42 +0100
Subject: [PATCH] in Data-Dumper, quote glob names better
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Ported to Data-Dumper-1.167 from perl git tree:
commit abda9fe0fe75ae824723761c1c98af958f17a41c
Author: Zefram <zefram@fysh.org>
Date: Fri Dec 1 17:35:35 2017 +0000
in Data-Dumper, quote glob names better
Glob name quoting should obey Useqq. Fixes [perl #119831].
Signed-off-by: Petr Písař <ppisar@redhat.com>
---
Dumper.pm | 4 ++--
Dumper.xs | 22 +++++++---------------
t/dumper.t | 35 ++++++++++++++++++++++++++++++++++-
3 files changed, 43 insertions(+), 18 deletions(-)
diff --git a/Dumper.pm b/Dumper.pm
index 00f6326..696964a 100644
--- a/Dumper.pm
+++ b/Dumper.pm
@@ -527,8 +527,8 @@ sub _dump {
$ref = \$val;
if (ref($ref) eq 'GLOB') { # glob
my $name = substr($val, 1);
- if ($name =~ /^[A-Za-z_][\w:]*$/ && $name ne 'main::') {
- $name =~ s/^main::/::/;
+ $name =~ s/^main::(?!\z)/::/;
+ if ($name =~ /\A(?:[A-Z_a-z][0-9A-Z_a-z]*)?::(?:[0-9A-Z_a-z]+::)*[0-9A-Z_a-z]*\z/ && $name ne 'main::') {
$sname = $name;
}
else {
diff --git a/Dumper.xs b/Dumper.xs
index 5a21721..8a16e04 100644
--- a/Dumper.xs
+++ b/Dumper.xs
@@ -1300,29 +1300,21 @@ DD_dump(pTHX_ SV *val, const char *name, STRLEN namelen, SV *retval, HV *seenhv,
i = 0; else i -= 4;
}
if (globname_needs_quote(c,i)) {
-#ifdef GvNAMEUTF8
- if (GvNAMEUTF8(val)) {
sv_grow(retval, SvCUR(retval)+2);
r = SvPVX(retval)+SvCUR(retval);
r[0] = '*'; r[1] = '{';
SvCUR_set(retval, SvCUR(retval)+2);
- esc_q_utf8(aTHX_ retval, c, i, 1, style->useqq);
+ esc_q_utf8(aTHX_ retval, c, i,
+#ifdef GvNAMEUTF8
+ !!GvNAMEUTF8(val)
+#else
+ 0
+#endif
+ , style->useqq);
sv_grow(retval, SvCUR(retval)+2);
r = SvPVX(retval)+SvCUR(retval);
r[0] = '}'; r[1] = '\0';
i = 1;
- }
- else
-#endif
- {
- sv_grow(retval, SvCUR(retval)+6+2*i);
- r = SvPVX(retval)+SvCUR(retval);
- r[0] = '*'; r[1] = '{'; r[2] = '\'';
- i += esc_q(r+3, c, i);
- i += 3;
- r[i++] = '\''; r[i++] = '}';
- r[i] = '\0';
- }
}
else {
sv_grow(retval, SvCUR(retval)+i+2);
diff --git a/t/dumper.t b/t/dumper.t
index 643160a..0c12f34 100644
--- a/t/dumper.t
+++ b/t/dumper.t
@@ -108,7 +108,7 @@ sub SKIP_TEST {
++$TNUM; print "ok $TNUM # skip $reason\n";
}
-$TMAX = 450;
+$TMAX = 456;
# Force Data::Dumper::Dump to use perl. We test Dumpxs explicitly by calling
# it direct. Out here it lets us knobble the next if to test that the perl
@@ -1740,3 +1740,36 @@ EOT
TEST (qq(Dumper("\n")), '\n alone');
TEST (qq(Data::Dumper::DumperX("\n")), '\n alone') if $XS;
}
+#############
+our @globs = map { $_, \$_ } map { *$_ } map { $_, "s::$_" }
+ "foo", "\1bar", "L\x{e9}on", "m\x{100}cron", "snow\x{2603}";
+$WANT = <<'EOT';
+#$globs = [
+# *::foo,
+# \*::foo,
+# *s::foo,
+# \*s::foo,
+# *{"::\1bar"},
+# \*{"::\1bar"},
+# *{"s::\1bar"},
+# \*{"s::\1bar"},
+# *{"::L\351on"},
+# \*{"::L\351on"},
+# *{"s::L\351on"},
+# \*{"s::L\351on"},
+# *{"::m\x{100}cron"},
+# \*{"::m\x{100}cron"},
+# *{"s::m\x{100}cron"},
+# \*{"s::m\x{100}cron"},
+# *{"::snow\x{2603}"},
+# \*{"::snow\x{2603}"},
+# *{"s::snow\x{2603}"},
+# \*{"s::snow\x{2603}"}
+#];
+EOT
+{
+ local $Data::Dumper::Useqq = 1;
+ TEST (q(Data::Dumper->Dump([\@globs], ["globs"])), 'globs: Dump()');
+ TEST (q(Data::Dumper->Dumpxs([\@globs], ["globs"])), 'globs: Dumpxs()')
+ if $XS;
+}
--
2.13.6

View File

@ -1,17 +1,22 @@
Name: perl-Data-Dumper
Version: 2.161
Release: 2%{?dist}
Release: 4%{?dist}
Summary: Stringify perl data structures, suitable for printing and eval
License: GPL+ or Artistic
Group: Development/Libraries
URL: http://search.cpan.org/dist/Data-Dumper/
Source0: http://www.cpan.org/authors/id/S/SM/SMUELLER/Data-Dumper-%{version}.tar.gz
# Fix quoting glob names, RT#119831, in upstream after perl-5.27.6
Patch0: Data-Dumper-2.167-in-Data-Dumper-quote-glob-names-better.patch
# Fix postentry for quoted glob, bug #1532524, RT#132695,
# in upstream after perl-5.27.7
Patch1: Data-Dumper-2.167-fix-Data-Dumper-postentry-for-quoted-glob.patch
BuildRequires: findutils
BuildRequires: gcc
BuildRequires: make
BuildRequires: perl
BuildRequires: perl-devel
BuildRequires: perl-generators
BuildRequires: perl-interpreter
BuildRequires: perl(ExtUtils::MakeMaker)
BuildRequires: sed
# Run-time:
@ -52,6 +57,8 @@ structures correctly.
%prep
%setup -q -n Data-Dumper-%{version}
%patch0 -p1
%patch1 -p1
sed -i '/MAN3PODS/d' Makefile.PL
%build
@ -76,6 +83,12 @@ make test
%{_mandir}/man3/*
%changelog
* Thu Jan 11 2018 Petr Pisar <ppisar@redhat.com> - 2.161-4
- Fix postentry for quoted glob (bug #1532524)
* Tue Dec 05 2017 Petr Pisar <ppisar@redhat.com> - 2.161-3
- Fix quoting glob names (RT#119831)
* Sat Feb 11 2017 Fedora Release Engineering <releng@fedoraproject.org> - 2.161-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild