diff options
author | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2008-01-28 13:10:48 +0000 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2008-01-28 13:10:48 +0000 |
commit | 0a0ffbced76eaafcaebd51ddc09366bc6ba04e9e (patch) | |
tree | ce5bcf24c3bb0ff610008329cd1db826dd0a7265 | |
parent | c6502f5c7c927d82523e421275ac87013ce318d5 (diff) | |
download | perl-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.pl | 2 | ||||
-rw-r--r-- | pp.c | 6 | ||||
-rw-r--r-- | t/lib/warnings/9uninit | 13 |
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". @@ -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); |