[perl-Sub-Name: 15/15] Add patch for CPAN RT#50524 (copy contents of %DB::sub entry if it exists)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



commit 6753495aeae38d5bc7c6bdf2ba5cbf6764c452e4
Author: Paul Howarth <paul@xxxxxxxxxxxx>
Date:   Sat Feb 18 14:03:19 2012 +0000

    Add patch for CPAN RT#50524 (copy contents of %DB::sub entry if it exists)

 Sub-Name-0.05-cpan50524.patch |   92 +++++++++++++++++++++++++++++++++++++++++
 perl-Sub-Name.spec            |    5 ++
 2 files changed, 97 insertions(+), 0 deletions(-)
---
diff --git a/Sub-Name-0.05-cpan50524.patch b/Sub-Name-0.05-cpan50524.patch
new file mode 100644
index 0000000..51ab3fb
--- /dev/null
+++ b/Sub-Name-0.05-cpan50524.patch
@@ -0,0 +1,92 @@
+Closes RT#50524
+---
+ Name.xs   |   34 ++++++++++++++++++++++++++++++++++
+ t/smoke.t |   18 +++++++++++++++++-
+ 2 files changed, 51 insertions(+), 1 deletions(-)
+
+diff --git a/Name.xs b/Name.xs
+index f6d7bc2..89d2dd8 100644
+--- a/Name.xs
++++ b/Name.xs
+@@ -64,6 +64,40 @@ subname(name, sub)
+ 		*end = saved;
+ 		name = end;
+ 	}
++
++	/* under debugger, provide information about sub location */
++	if (PL_DBsub && CvGV(cv)) {
++		HV *hv = GvHV(PL_DBsub);
++
++		char* new_pkg = HvNAME(stash);
++
++		char* old_name = GvNAME( CvGV(cv) );
++		char* old_pkg = HvNAME( GvSTASH(CvGV(cv)) );
++
++		int old_len = strlen(old_name) + strlen(old_pkg);
++		int new_len = strlen(name) + strlen(new_pkg);
++
++		char* full_name;
++		Newz(39, full_name, (old_len > new_len ? old_len : new_len) + 3, char);
++
++		strcat(full_name, old_pkg);
++		strcat(full_name, "::");
++		strcat(full_name, old_name);
++
++		SV** old_data = hv_fetch(hv, full_name, strlen(full_name), 0);
++
++		if (old_data) {
++			strcpy(full_name, new_pkg);
++			strcat(full_name, "::");
++			strcat(full_name, name);
++
++			SvREFCNT_inc(*old_data);
++			if (!hv_store(hv, full_name, strlen(full_name), *old_data, 0))
++				SvREFCNT_dec(*old_data);
++		}
++		Safefree(full_name);
++	}
++
+ 	gv = (GV *) newSV(0);
+ 	gv_init(gv, stash, name, s - name, TRUE);
+ 
+diff --git a/t/smoke.t b/t/smoke.t
+index 87508ed..a383789 100644
+--- a/t/smoke.t
++++ b/t/smoke.t
+@@ -1,11 +1,15 @@
+ #!/usr/bin/perl
+ 
+-BEGIN { print "1..5\n"; }
++BEGIN { print "1..10\n"; $^P |= 0x210 }
+ 
+ 
+ use Sub::Name;
+ 
+ my $x = subname foo => sub { (caller 0)[3] };
++my $line = __LINE__ - 1;
++my $file = __FILE__;
++my $anon = $DB::sub{"main::__ANON__[${file}:${line}]"};
++
+ print $x->() eq "main::foo" ? "ok 1\n" : "not ok 1\n";
+ 
+ 
+@@ -26,4 +30,16 @@ for (4 .. 5) {
+ 	print $x->() eq "Blork::Dynamic $_" ? "ok $_\n" : "not ok $_\n";
+ }
+ 
++print $DB::sub{"main::foo"} eq $anon ? "ok 6\n" : "not ok 6\n";
++
++for (4 .. 5) {
++	print $DB::sub{"Blork::Dynamic $_"} eq $anon ? "ok ".($_+3)."\n" : "not ok ".($_+3)."\n";
++}
++
++my $i = 9;
++for ("Blork:: Bar!", "Foo::Bar::Baz") {
++	print $DB::sub{$_} eq $anon  ? "ok $i\n" : "not ok $_ \n";
++	$i++;
++}
++
+ # vim: ft=perl
+-- 
+1.7.0.4
+
diff --git a/perl-Sub-Name.spec b/perl-Sub-Name.spec
index 5567913..72eebf1 100644
--- a/perl-Sub-Name.spec
+++ b/perl-Sub-Name.spec
@@ -9,6 +9,7 @@ License:	GPL+ or Artistic
 Group:		Development/Libraries
 URL:		http://search.cpan.org/dist/Sub-Name/
 Source0:	http://search.cpan.org/CPAN/authors/id/F/FL/FLORA/Sub-Name-%{version}.tar.gz
+Patch0:		Sub-Name-0.05-cpan50524.patch
 BuildRoot:	%{_tmppath}/%{name}-%{version}-%{release}-root-%(id -nu)
 BuildRequires:	perl(base)
 BuildRequires:	perl(DynaLoader)
@@ -36,6 +37,9 @@ by the new name (without some deep magic).
 %prep
 %setup -q -n Sub-Name-%{version}
 
+# Copy the contents of the %%DB::sub entry if it exists (CPAN RT#50524)
+%patch0 -p1
+
 %build
 perl Makefile.PL INSTALLDIRS=vendor optimize="%{optflags}"
 make %{?_smp_mflags}
@@ -63,6 +67,7 @@ rm -rf %{buildroot}
 
 %changelog
 * Sat Feb 18 2012 Paul Howarth <paul@xxxxxxxxxxxx> - 0.05-6
+- Add patch for CPAN RT#50524 (copy contents of %%DB::sub entry if it exists)
 - Reinstate compatibility with old distributions like EL-5
   - Add BuildRoot definition
   - Clean buildroot in %%install
--
Fedora Extras Perl SIG
http://www.fedoraproject.org/wiki/Extras/SIGs/Perl
perl-devel mailing list
perl-devel@xxxxxxxxxxxxxxxxxxxxxxx
https://admin.fedoraproject.org/mailman/listinfo/perl-devel



[Index of Archives]     [Fedora Announce]     [Fedora Kernel]     [Fedora Testing]     [Fedora Legacy Announce]     [Fedora PHP Devel]     [Kernel Devel]     [Fedora Legacy]     [Fedora Maintainers]     [Fedora Desktop]     [PAM]     [Red Hat Development]     [Big List of Linux Books]     [Gimp]     [Yosemite Information]
  Powered by Linux