This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Perl_sv_vcatpvfn_flags: warn on missing %v arg
authorDavid Mitchell <davem@iabyn.com>
Mon, 29 May 2017 15:53:06 +0000 (16:53 +0100)
committerDavid Mitchell <davem@iabyn.com>
Wed, 7 Jun 2017 08:11:07 +0000 (09:11 +0100)
The explicit arg variant, e.g. %3$vd, didn't give 'missing arg' warning.

sv.c
t/op/sprintf.t
t/op/sprintf2.t

diff --git a/sv.c b/sv.c
index 0ab3685..f5482b4 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -12197,7 +12197,8 @@ Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv, const char *const pat, const STRLEN p
                 vecsv = va_arg(*args, SV*);
            else {
                 efix = efix ? efix - 1 : svix++;
-                vecsv = efix < svmax ? svargs[efix] : &PL_sv_no;
+                vecsv = efix < svmax ? svargs[efix]
+                                     : (arg_missing = TRUE, &PL_sv_no);
             }
 
             /* if this is a version object, we need to convert
index af7ad42..a5304b5 100644 (file)
@@ -746,7 +746,7 @@ __END__
 >%#b<          >0<     >0<
 >%#o<          >0<     >0<
 >%#x<          >0<     >0<
->%1073741819$v2d<      >''<    ><
+>%1073741819$v2d<      >''<    > MISSING<
 >%*1073741819$v2d<     >''<    > MISSING<
 >%.3X<         >[11]<                  >00B<           >perl #83194: hex, zero-padded to 3 places<
 >%.*X<         >[3, 11]<               >00B<           >perl #83194: dynamic precision<
@@ -768,3 +768,4 @@ e>%vd<   >"version"<    >165.133.153.162.137.150.149<   >perl #102586: vector fl
 >%*%<  >[]<    >% MISSING<
 >%*1$%<        >[]<    >% MISSING<
 >%*2$d<        >123<   >123 MISSING<
+>%2$vd<>123<   > MISSING<
index 68add6e..4c9bcee 100644 (file)
@@ -468,7 +468,9 @@ for (int(~0/2+1), ~0, "9999999999999999999") {
     foreach my $ord (0 .. 255) {
        my $bad = 0;
        local $SIG{__WARN__} = sub {
-           if ($_[0] !~ /^Invalid conversion in sprintf/) {
+           if (  $_[0] !~ /^Invalid conversion in sprintf/
+               && $_[0] !~ /^Missing argument in sprintf/ )
+            {
                warn $_[0];
                $bad++;
            }