ANSI-C headers in test snippets to please g++ (and the rest)
[p5sagit/p5-mst-13.2.git] / lib / Carp.pm
index 4f161b5..5545c39 100644 (file)
@@ -1,21 +1,21 @@
 package Carp;
-our $VERSION = '1.04';
+
+our $VERSION = '1.05';
 # this file is an utra-lightweight stub. The first time a function is
 # called, Carp::Heavy is loaded, and the real short/longmessmess_jmp
 # subs are installed
 
-# $MaxEvalLen, $Verbose
-# are supposed to default to 0, but undef should be close enough
-
-$CarpLevel = 0;
-$MaxArgLen = 64;    # How much of each argument to print. 0 = all.
-$MaxArgNums = 8;    # How many arguments to print. 0 = all.
+our $MaxEvalLen = 0;
+our $Verbose    = 0;
+our $CarpLevel  = 0;
+our $MaxArgLen  = 64;   # How much of each argument to print. 0 = all.
+our $MaxArgNums = 8;    # How many arguments to print. 0 = all.
 
 require Exporter;
-@ISA = ('Exporter');
-@EXPORT = qw(confess croak carp);
-@EXPORT_OK = qw(cluck verbose longmess shortmess);
-@EXPORT_FAIL = qw(verbose);    # hook to enable verbose mode
+our @ISA = ('Exporter');
+our @EXPORT = qw(confess croak carp);
+our @EXPORT_OK = qw(cluck verbose longmess shortmess);
+our @EXPORT_FAIL = qw(verbose);        # hook to enable verbose mode
 
 # if the caller specifies verbose usage ("perl -MCarp=verbose script.pl")
 # then the following method will be called by the Exporter which knows
@@ -28,8 +28,18 @@ sub export_fail { shift; $Verbose = shift if $_[0] eq 'verbose'; @_ }
 sub longmess  { goto &longmess_jmp }
 sub shortmess { goto &shortmess_jmp }
 # these two are replaced when Carp::Heavy is loaded
-sub longmess_jmp  {{ local($@, $!); require Carp::Heavy} goto &longmess_jmp}
-sub shortmess_jmp {{ local($@, $!); require Carp::Heavy} goto &shortmess_jmp}
+sub longmess_jmp  {
+    local($@, $!);
+    eval { require Carp::Heavy };
+    return $@ if $@;
+    goto &longmess_jmp;
+}
+sub shortmess_jmp  {
+    local($@, $!);
+    eval { require Carp::Heavy };
+    return $@ if $@;
+    goto &shortmess_jmp;
+}
 
 sub croak   { die  shortmess @_ }
 sub confess { die  longmess  @_ }
@@ -188,7 +198,6 @@ Note, this is analogous to using C<use Carp 'verbose'>.
 
 Defaults to C<0>.
 
-
 =head1 BUGS
 
 The Carp routines don't handle exception objects currently.