From: Rafael Garcia-Suarez <rgarciasuarez@gmail.com>
Date: Mon, 28 Jan 2008 13:10:48 +0000 (+0000)
Subject: Make lc/uc/lcfirst/ucfirst warn when passed undef.
X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0a0ffbced76eaafcaebd51ddc09366bc6ba04e9e;p=p5sagit%2Fp5-mst-13.2.git

Make lc/uc/lcfirst/ucfirst warn when passed undef.
Naive implementation.

p4raw-id: //depot/perl@33088
---

diff --git a/lib/utf8_heavy.pl b/lib/utf8_heavy.pl
index b6b6b6e..ecdd95e 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 c667e22..2b12a8f 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 1e4344a..e68407c 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);