# text and function arguments should be formatted when printed.
$CarpInternal{Carp}++;
+$CarpInternal{warnings}++;
$CarpLevel = 0; # How many extra package levels to skip on carp.
# How many calls to skip on confess.
# Reconciling these notions is hard, use
$All = "" ; vec($All, $Offsets{'all'}, 2) = 3 ;
+sub Croaker
+{
+ delete $Carp::CarpInternal{'warnings'};
+ croak @_ ;
+}
+
sub bits {
my $mask ;
my $catmask ;
$mask |= $DeadBits{$word} if $fatal ;
}
else
- { croak("Unknown warnings category '$word'")}
+ { Croaker("Unknown warnings category '$word'")}
}
return $mask ;
# check the category supplied.
$category = shift ;
if (ref $category) {
- croak ("not an object")
+ Croaker ("not an object")
if $category !~ /^([^=]+)=/ ;
$category = $1 ;
$isobj = 1 ;
}
$offset = $Offsets{$category};
- croak("Unknown warnings category '$category'")
+ Croaker("Unknown warnings category '$category'")
unless defined $offset;
}
else {
$category = (caller(1))[0] ;
$offset = $Offsets{$category};
- croak("package '$category' not registered for warnings")
+ Croaker("package '$category' not registered for warnings")
unless defined $offset ;
}
sub enabled
{
- croak("Usage: warnings::enabled([category])")
+ Croaker("Usage: warnings::enabled([category])")
unless @_ == 1 || @_ == 0 ;
my ($callers_bitmask, $offset, $i) = __chk(@_) ;
sub warn
{
- croak("Usage: warnings::warn([category,] 'message')")
+ Croaker("Usage: warnings::warn([category,] 'message')")
unless @_ == 2 || @_ == 1 ;
my $message = pop ;
my ($callers_bitmask, $offset, $i) = __chk(@_) ;
- local $Carp::CarpLevel = $i ;
croak($message)
if vec($callers_bitmask, $offset+1, 1) ||
vec($callers_bitmask, $Offsets{'all'}+1, 1) ;
sub warnif
{
- croak("Usage: warnings::warnif([category,] 'message')")
+ Croaker("Usage: warnings::warnif([category,] 'message')")
unless @_ == 2 || @_ == 1 ;
my $message = pop ;
my ($callers_bitmask, $offset, $i) = __chk(@_) ;
- local $Carp::CarpLevel = $i ;
return
unless defined $callers_bitmask &&
--FILE--
use warnings 'syntax' ;
use abc ;
-eval { abc::check() ; };
+eval {
+ abc::check() ;
+};
print $@ ;
EXPECT
ok1
--FILE--
use warnings 'syntax' ;
use abc ;
-eval { abc::check() ; } ;
+eval {
+ abc::check() ;
+ } ;
print $@ ;
EXPECT
ok1
--FILE--
use warnings 'syntax' ;
require "abc" ;
-eval { abc::check() ; } ;
+eval {
+ abc::check() ;
+ } ;
print $@ ;
EXPECT
ok1
--FILE--
use warnings 'syntax' ;
require "abc" ;
-eval { use warnings 'io' ; abc::check() ; };
+eval {
+ use warnings 'io' ;
+ abc::check() ;
+};
abc::check() ;
print $@ ;
EXPECT
# check warnings::warn
use warnings ;
-eval { warnings::warn() } ;
+eval {
+ warnings::warn()
+ } ;
print $@ ;
-eval { warnings::warn("fred", "joe") } ;
+eval {
+ warnings::warn("fred", "joe")
+ } ;
print $@ ;
EXPECT
-Usage: warnings::warn([category,] 'message') at - line 4
-Unknown warnings category 'fred' at - line 6
+Usage: warnings::warn([category,] 'message') at - line 5
+Unknown warnings category 'fred' at - line 9
########
# check warnings::warnif
use warnings ;
-eval { warnings::warnif() } ;
+eval {
+ warnings::warnif()
+} ;
print $@ ;
-eval { warnings::warnif("fred", "joe") } ;
+eval {
+ warnings::warnif("fred", "joe")
+} ;
print $@ ;
EXPECT
-Usage: warnings::warnif([category,] 'message') at - line 4
-Unknown warnings category 'fred' at - line 6
+Usage: warnings::warnif([category,] 'message') at - line 5
+Unknown warnings category 'fred' at - line 9
########
--FILE-- abc.pm
--FILE--
use warnings qw( FATAL deprecated ) ;
use abc;
-eval { abc::check() ; } ;
+eval {
+ abc::check() ;
+ } ;
print "[[$@]]\n";
EXPECT
-hello at - line 3
- eval {...} called at - line 3
+hello at - line 4
[[]]
########
--FILE--
use warnings qw( FATAL io ) ;
use abc;
-eval { abc::check() ; } ;
+eval {
+ abc::check() ;
+} ;
print "[[$@]]\n";
EXPECT
-[[hello at - line 3
- eval {...} called at - line 3
+[[hello at - line 4
]]
########
-W
--FILE--
use abc;
use warnings qw( FATAL deprecated ) ;
-eval { abc::check() ; } ;
+eval {
+ abc::check() ;
+ } ;
print "[[$@]]\n";
EXPECT
-hello at - line 3
- eval {...} called at - line 3
+hello at - line 4
[[]]
########
--FILE--
use abc;
use warnings qw( FATAL abc ) ;
-eval { abc::check() ; } ;
+eval {
+ abc::check() ;
+ } ;
print "[[$@]]\n";
EXPECT
-[[hello at - line 3
- eval {...} called at - line 3
+[[hello at - line 4
]]
########
-W
ok3
ok4
my message 1 at abc.pm line 5
- abc::in1() called at - line 3
my message 2 at abc.pm line 5
- abc::in1() called at - line 3
my message 3 at abc.pm line 5
- abc::in1() called at - line 3
########
--FILE-- def.pm
$All = "" ; vec($All, $Offsets{'all'}, 2) = 3 ;
+sub Croaker
+{
+ delete $Carp::CarpInternal{'warnings'};
+ croak @_ ;
+}
+
sub bits {
my $mask ;
my $catmask ;
$mask |= $DeadBits{$word} if $fatal ;
}
else
- { croak("Unknown warnings category '$word'")}
+ { Croaker("Unknown warnings category '$word'")}
}
return $mask ;
# check the category supplied.
$category = shift ;
if (ref $category) {
- croak ("not an object")
+ Croaker ("not an object")
if $category !~ /^([^=]+)=/ ;
$category = $1 ;
$isobj = 1 ;
}
$offset = $Offsets{$category};
- croak("Unknown warnings category '$category'")
+ Croaker("Unknown warnings category '$category'")
unless defined $offset;
}
else {
$category = (caller(1))[0] ;
$offset = $Offsets{$category};
- croak("package '$category' not registered for warnings")
+ Croaker("package '$category' not registered for warnings")
unless defined $offset ;
}
sub enabled
{
- croak("Usage: warnings::enabled([category])")
+ Croaker("Usage: warnings::enabled([category])")
unless @_ == 1 || @_ == 0 ;
my ($callers_bitmask, $offset, $i) = __chk(@_) ;
sub warn
{
- croak("Usage: warnings::warn([category,] 'message')")
+ Croaker("Usage: warnings::warn([category,] 'message')")
unless @_ == 2 || @_ == 1 ;
my $message = pop ;
my ($callers_bitmask, $offset, $i) = __chk(@_) ;
- local $Carp::CarpLevel = $i ;
croak($message)
if vec($callers_bitmask, $offset+1, 1) ||
vec($callers_bitmask, $Offsets{'all'}+1, 1) ;
sub warnif
{
- croak("Usage: warnings::warnif([category,] 'message')")
+ Croaker("Usage: warnings::warnif([category,] 'message')")
unless @_ == 2 || @_ == 1 ;
my $message = pop ;
my ($callers_bitmask, $offset, $i) = __chk(@_) ;
- local $Carp::CarpLevel = $i ;
return
unless defined $callers_bitmask &&