dual-life Carp
authorZefram <zefram@fysh.org>
Fri, 2 Sep 2011 23:54:36 +0000 (00:54 +0100)
committerZefram <zefram@fysh.org>
Sun, 4 Sep 2011 14:27:34 +0000 (15:27 +0100)
Make Carp portable to older Perl versions:
* check minimum Perl version (5.6) at load time
* use || instead of //
* attempt downgrading to avoid loading Unicode tables when that might fail
* check whether utf8::is_utf8() exists before calling it
* lower IPC::Open3 version requirement in Carp tests

MANIFEST
META.yml
Porting/Maintainers.pl
dist/Carp/Makefile.PL [moved from ext/Carp/Makefile.PL with 91% similarity]
dist/Carp/lib/Carp.pm [moved from ext/Carp/lib/Carp.pm with 95% similarity]
dist/Carp/lib/Carp/Heavy.pm [moved from ext/Carp/lib/Carp/Heavy.pm with 100% similarity]
dist/Carp/t/Carp.t [moved from ext/Carp/t/Carp.t with 99% similarity]
t/porting/known_pod_issues.dat
write_buildcustomize.pl

index 81a5702..a378831 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -2918,6 +2918,10 @@ dist/B-Lint/lib/B/Lint/Debug.pm                  Adds debugging stringification to B::
 dist/B-Lint/lib/B/Lint.pm                      Compiler Lint backend
 dist/B-Lint/t/lint.t                           See if B::Lint works
 dist/B-Lint/t/pluglib/B/Lint/Plugin/Test.pm    See if B::Lint works
+dist/Carp/lib/Carp/Heavy.pm    Error message retired workhorse
+dist/Carp/lib/Carp.pm          Error message extension
+dist/Carp/Makefile.PL          makefile writer for Carp
+dist/Carp/t/Carp.t             See if Carp works
 dist/constant/lib/constant.pm  For "use constant"
 dist/constant/t/constant.t     See if compile-time constants work
 dist/constant/t/utf8.t         Test Unicode constants under utf8 pragma
@@ -3464,10 +3468,6 @@ ext/B/t/terse.t          See if B::Terse works
 ext/B/t/walkoptree.t   See if B::walkoptree (and friends) work
 ext/B/t/xref.t         See if B::Xref works
 ext/B/typemap                  Compiler backend interface types
-ext/Carp/lib/Carp/Heavy.pm     Error message retired workhorse
-ext/Carp/lib/Carp.pm           Error message extension
-ext/Carp/Makefile.PL           makefile writer for Carp
-ext/Carp/t/Carp.t              See if Carp works
 ext/Devel-Peek/Changes         Data debugging tool, changelog
 ext/Devel-Peek/Makefile.PL     Data debugging tool, makefile writer
 ext/Devel-Peek/Peek.pm         Data debugging tool, module and pod
index e597842..3585f16 100644 (file)
--- a/META.yml
+++ b/META.yml
@@ -18,6 +18,7 @@ no_index:
     - dist/B-Lint
     - dist/base
     - dist/bignum
+    - dist/Carp
     - dist/constant
     - dist/Cwd
     - dist/Data-Dumper
index 8ad5471..ffdbefd 100755 (executable)
@@ -342,8 +342,9 @@ use File::Glob qw(:case);
 
     'Carp' =>
        {
-       'MAINTAINER'    => 'p5p',
-       'FILES'         => q[ext/Carp],
+       'MAINTAINER'    => 'zefram',
+       'DISTRIBUTION'  => 'ZEFRAM/Carp-1.22.tar.gz',
+       'FILES'         => q[dist/Carp],
        'UPSTREAM'      => 'blead',
        },
 
similarity index 91%
rename from ext/Carp/Makefile.PL
rename to dist/Carp/Makefile.PL
index 313f537..42207a2 100644 (file)
@@ -9,7 +9,7 @@ WriteMakefile(
        ABSTRACT_FROM => "lib/Carp.pm",
        PREREQ_PM => {
                "Exporter" => 0,
-               "IPC::Open3" => "1.0104",
+               "IPC::Open3" => "1.0103",
                "Test::More" => 0,
                "strict" => 0,
                "warnings" => 0,
similarity index 95%
rename from ext/Carp/lib/Carp.pm
rename to dist/Carp/lib/Carp.pm
index 6148a68..52edcd8 100644 (file)
@@ -1,9 +1,10 @@
 package Carp;
 
+{ use 5.006; }
 use strict;
 use warnings;
 
-our $VERSION = '1.21';
+our $VERSION = '1.22';
 
 our $MaxEvalLen = 0;
 our $Verbose    = 0;
@@ -120,7 +121,7 @@ sub caller_info {
                 # returning CORE::GLOBAL::caller isn't useful for tracing the cause:
                 return if $package eq 'CORE::GLOBAL' && $subname eq 'caller';
                 " in &${package}::$subname";
-            } // '';
+            } || '';
             @args
                 = "** Incomplete caller override detected$where; \@DB::args were not set **";
         }
@@ -151,16 +152,21 @@ sub format_arg {
         $arg = str_len_trim( $arg, $MaxArgLen );
 
         # Quote it?
+        # Downgrade, and use [0-9] rather than \d, to avoid loading
+        # Unicode tables, which would be liable to fail if we're
+        # processing a syntax error.
+        utf8::downgrade($arg, 1) if "$]" >= 5.008;
         $arg = "'$arg'" unless $arg =~ /^-?[0-9.]+\z/;
-    }                                    # 0-9, not \d, as \d will try to
-    else {                               # load Unicode tables
+    }
+    else {
         $arg = 'undef';
     }
 
     # The following handling of "control chars" is direct from
     # the original code - it is broken on Unicode though.
     # Suggestions?
-    utf8::is_utf8($arg)
+    no strict "refs";
+    defined(*{"utf8::is_utf8"}{CODE}) && utf8::is_utf8($arg)
         or $arg =~ s/([[:cntrl:]]|[[:^ascii:]])/sprintf("\\x{%x}",ord($1))/eg;
     return $arg;
 }
@@ -581,3 +587,25 @@ The Carp routines don't handle exception objects currently.
 If called with a first argument that is a reference, they simply
 call die() or warn(), as appropriate.
 
+=head1 SEE ALSO
+
+L<Carp::Always>,
+L<Carp::Clan>
+
+=head1 AUTHOR
+
+The Carp module first appeared in Larry Wall's perl 5.000 distribution.
+Since then it has been modified by several of the perl 5 porters.
+Andrew Main (Zefram) <zefram@fysh.org> divested Carp into an independent
+distribution.
+
+=head1 COPYRIGHT
+
+Copyright (C) 1994-2011 Larry Wall
+
+Copyright (C) 2011 Andrew Main (Zefram) <zefram@fysh.org>
+
+=head1 LICENSE
+
+This module is free software; you can redistribute it and/or modify it
+under the same terms as Perl itself.
similarity index 99%
rename from ext/Carp/t/Carp.t
rename to dist/Carp/t/Carp.t
index 60b3305..9dd5a12 100644 (file)
@@ -2,7 +2,7 @@ use warnings;
 no warnings "once";
 use Config;
 
-use IPC::Open3 1.0104 qw(open3);
+use IPC::Open3 1.0103 qw(open3);
 use Test::More tests => 58;
 
 sub runperl {
index 927d49f..bee98ef 100644 (file)
@@ -135,6 +135,7 @@ YAML::Tiny
 dist/bignum/lib/bigint.pm      Apparent broken link    1
 dist/bignum/lib/bignum.pm      Apparent broken link    1
 dist/bignum/lib/bigrat.pm      Apparent broken link    1
+dist/carp/lib/carp.pm  Apparent broken link    2
 dist/constant/lib/constant.pm  Apparent broken link    2
 dist/cwd/lib/file/spec/vms.pm  Verbatim line length including indents exceeds 79 by    1
 dist/cwd/lib/file/spec/win32.pm        Verbatim line length including indents exceeds 79 by    1
index 24c767c..ee3eea5 100644 (file)
@@ -18,7 +18,7 @@ require File::Spec::Functions;
 # allow miniperl to build everything else.
 
 my @toolchain = qw(cpan/AutoLoader/lib
-                  ext/Carp/lib
+                  dist/Carp/lib
                   dist/Cwd dist/Cwd/lib
                   dist/ExtUtils-Command/lib
                   dist/ExtUtils-Install/lib