Browse files

dual-life Carp

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
  • Loading branch information...
1 parent 476b2fe commit 634ff085fbbf05cb775b782f4175b761595f6170 Zefram committed Sep 3, 2011
View
8 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
View
1 META.yml
@@ -18,6 +18,7 @@ no_index:
- dist/B-Lint
- dist/base
- dist/bignum
+ - dist/Carp
- dist/constant
- dist/Cwd
- dist/Data-Dumper
View
5 Porting/Maintainers.pl
@@ -342,8 +342,9 @@ package Maintainers;
'Carp' =>
{
- 'MAINTAINER' => 'p5p',
- 'FILES' => q[ext/Carp],
+ 'MAINTAINER' => 'zefram',
+ 'DISTRIBUTION' => 'ZEFRAM/Carp-1.22.tar.gz',
+ 'FILES' => q[dist/Carp],
'UPSTREAM' => 'blead',
},
View
2 ext/Carp/Makefile.PL → dist/Carp/Makefile.PL
@@ -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,
View
38 ext/Carp/lib/Carp.pm → dist/Carp/lib/Carp.pm
@@ -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.
View
0 ext/Carp/lib/Carp/Heavy.pm → dist/Carp/lib/Carp/Heavy.pm
File renamed without changes.
View
2 ext/Carp/t/Carp.t → dist/Carp/t/Carp.t
@@ -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 {
View
1 t/porting/known_pod_issues.dat
@@ -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
View
2 write_buildcustomize.pl
@@ -18,7 +18,7 @@
# 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

0 comments on commit 634ff08

Please sign in to comment.