summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafael Garcia-Suarez <rgarciasuarez@gmail.com>2008-01-28 13:10:48 +0000
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2008-01-28 13:10:48 +0000
commit0a0ffbced76eaafcaebd51ddc09366bc6ba04e9e (patch)
treece5bcf24c3bb0ff610008329cd1db826dd0a7265
parentc6502f5c7c927d82523e421275ac87013ce318d5 (diff)
downloadperl-0a0ffbced76eaafcaebd51ddc09366bc6ba04e9e.tar.gz
Make lc/uc/lcfirst/ucfirst warn when passed undef.
Naive implementation. p4raw-id: //depot/perl@33088
-rw-r--r--lib/utf8_heavy.pl2
-rw-r--r--pp.c6
-rw-r--r--t/lib/warnings/9uninit13
3 files changed, 18 insertions, 3 deletions
diff --git a/lib/utf8_heavy.pl b/lib/utf8_heavy.pl
index b6b6b6e215..ecdd95e3cb 100644
--- a/lib/utf8_heavy.pl
+++ b/lib/utf8_heavy.pl
@@ -137,10 +137,12 @@ sub SWASHNEW {
print STDERR "canonical = $canonical\n" if DEBUG;
require "unicore/Canonical.pl";
+ { no warnings "uninitialized";
if (my $base = ($utf8::Canonical{$canonical} || $utf8::Canonical{ lc $utf8::PropertyAlias{$canonical} })) {
$file = "unicore/lib/gc_sc/$base.pl";
last GETFILE;
}
+ }
##
## See if it's a user-level "To".
diff --git a/pp.c b/pp.c
index c667e22ff4..2b12a8fa80 100644
--- a/pp.c
+++ b/pp.c
@@ -3528,6 +3528,8 @@ PP(pp_ucfirst)
if (SvOK(source)) {
s = (const U8*)SvPV_nomg_const(source, slen);
} else {
+ if (ckWARN(WARN_UNINITIALIZED))
+ report_uninit(source);
s = (const U8*)"";
slen = 0;
}
@@ -3652,6 +3654,8 @@ PP(pp_uc)
if (SvOK(source)) {
s = (const U8*)SvPV_nomg_const(source, len);
} else {
+ if (ckWARN(WARN_UNINITIALIZED))
+ report_uninit(source);
s = (const U8*)"";
len = 0;
}
@@ -3752,6 +3756,8 @@ PP(pp_lc)
if (SvOK(source)) {
s = (const U8*)SvPV_nomg_const(source, len);
} else {
+ if (ckWARN(WARN_UNINITIALIZED))
+ report_uninit(source);
s = (const U8*)"";
len = 0;
}
diff --git a/t/lib/warnings/9uninit b/t/lib/warnings/9uninit
index 1e4344ae3b..e68407ccec 100644
--- a/t/lib/warnings/9uninit
+++ b/t/lib/warnings/9uninit
@@ -925,7 +925,6 @@ $v = ord $m1;
$v = chr;
$v = chr $m1;
-# XXX these functions don't warn!
$v = ucfirst;
$v = ucfirst $m1;
$v = lcfirst;
@@ -944,8 +943,16 @@ Use of uninitialized value $_ in ord at - line 7.
Use of uninitialized value $m1 in ord at - line 8.
Use of uninitialized value $_ in chr at - line 9.
Use of uninitialized value $m1 in chr at - line 10.
-Use of uninitialized value $_ in quotemeta at - line 22.
-Use of uninitialized value $m1 in quotemeta at - line 23.
+Use of uninitialized value $_ in ucfirst at - line 12.
+Use of uninitialized value $m1 in ucfirst at - line 13.
+Use of uninitialized value $_ in lcfirst at - line 14.
+Use of uninitialized value $m1 in lcfirst at - line 15.
+Use of uninitialized value $_ in uc at - line 16.
+Use of uninitialized value $m1 in uc at - line 17.
+Use of uninitialized value $_ in lc at - line 18.
+Use of uninitialized value $m1 in lc at - line 19.
+Use of uninitialized value $_ in quotemeta at - line 21.
+Use of uninitialized value $m1 in quotemeta at - line 22.
########
use warnings 'uninitialized';
my ($m1, $v1, $v2, $v3, $v4);