From: Robin Barker Date: Fri, 6 Apr 2001 18:08:52 +0000 (+0100) Subject: isn't numeric warning X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=59bb58455c306b86a68fba97f3fcce0a1f372a01;p=p5sagit%2Fp5-mst-13.2.git isn't numeric warning Message-Id: <200104061708.SAA06783@tempest.npl.co.uk> p4raw-id: //depot/perl@9613 --- diff --git a/sv.c b/sv.c index a589e08..1737e8f 100644 --- a/sv.c +++ b/sv.c @@ -1430,12 +1430,12 @@ S_not_a_number(pTHX_ SV *sv) { char tmpbuf[64]; char *d = tmpbuf; - char *s; char *limit = tmpbuf + sizeof(tmpbuf) - 8; /* each *s can expand to 4 chars + "...\0", i.e. need room for 8 chars */ - for (s = SvPVX(sv); *s && d < limit; s++) { + char *s, *end; + for (s = SvPVX(sv), end = s + SvCUR(sv); s < end && d < limit; s++) { int ch = *s & 0xFF; if (ch & 128 && !isPRINT_LC(ch)) { *d++ = 'M'; @@ -1458,6 +1458,10 @@ S_not_a_number(pTHX_ SV *sv) *d++ = '\\'; *d++ = '\\'; } + else if (ch == '\0') { + *d++ = '\\'; + *d++ = '0'; + } else if (isPRINT_LC(ch)) *d++ = ch; else { diff --git a/t/pragma/warn/sv b/t/pragma/warn/sv index 2409589..b3929e2 100644 --- a/t/pragma/warn/sv +++ b/t/pragma/warn/sv @@ -226,6 +226,23 @@ EXPECT Argument "def" isn't numeric in bitwise and (&) at - line 3. ######## # sv.c +use warnings 'numeric' ; +my $x = pack i => "def" ; +no warnings 'numeric' ; +my $z = pack i => "def" ; +EXPECT +Argument "def" isn't numeric in pack at - line 3. +######## +# sv.c +use warnings 'numeric' ; +my $a = "d\0f" ; +my $x = 1 + $a ; +no warnings 'numeric' ; +my $z = 1 + $a ; +EXPECT +Argument "d\0f" isn't numeric in addition (+) at - line 4. +######## +# sv.c use warnings 'redefine' ; sub fred {} sub joe {}