From: Gurusamy Sarathy Date: Wed, 12 Jul 2000 21:33:46 +0000 (+0000) Subject: fix bugs in processing %v-*d and similar format specs (from X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=bb2899ba824e18be66f3ca9d67696457ff235d98;p=p5sagit%2Fp5-mst-13.2.git fix bugs in processing %v-*d and similar format specs (from Avi Finkel ) p4raw-id: //depot/perl@6385 --- diff --git a/sv.c b/sv.c index 6ee91be..5f5d281 100644 --- a/sv.c +++ b/sv.c @@ -5963,17 +5963,6 @@ Perl_sv_vcatpvfn(pTHX_ SV *sv, const char *pat, STRLEN patlen, va_list *args, SV case 'v': vectorize = TRUE; q++; - if (args) - vecsv = va_arg(*args, SV*); - else if (svix < svmax) - vecsv = svargs[svix++]; - else { - vecstr = (U8*)""; - veclen = 0; - continue; - } - vecstr = (U8*)SvPVx(vecsv,veclen); - utf = DO_UTF8(vecsv); continue; default: @@ -6024,6 +6013,23 @@ Perl_sv_vcatpvfn(pTHX_ SV *sv, const char *pat, STRLEN patlen, va_list *args, SV has_precis = TRUE; } + if (vectorize) { + if (args) { + vecsv = va_arg(*args, SV*); + vecstr = (U8*)SvPVx(vecsv,veclen); + utf = DO_UTF8(vecsv); + } + else if (svix < svmax) { + vecsv = svargs[svix++]; + vecstr = (U8*)SvPVx(vecsv,veclen); + utf = DO_UTF8(vecsv); + } + else { + vecstr = (U8*)""; + veclen = 0; + } + } + /* SIZE */ switch (*q) { diff --git a/t/op/sprintf.t b/t/op/sprintf.t index b57eed9..2b0ecae 100755 --- a/t/op/sprintf.t +++ b/t/op/sprintf.t @@ -158,6 +158,13 @@ __END__ >%v4.3d< >"\01\02\03"< > 001. 002. 003< >%v04.3d< >"\01\02\03"< >0001.0002.0003< >%*v02d< >['-', "\0\7\13"]< >00-07-11< +>%v.*d< >[3, "\01\02\03"]< >001.002.003< +>%v0*d< >[3, "\01\02\03"]< >001.002.003< +>%v-*d< >[3, "\01\02\03"]< >1 .2 .3 < +>%v+-*d< >[3, "\01\02\03"]< >+1 .2 .3 < +>%v*.*d< >[4, 3, "\01\02\03"]< > 001. 002. 003< +>%v0*.*d< >[4, 3, "\01\02\03"]< >0001.0002.0003< +>%*v0*d< >['-', 2, "\0\7\13"]< >00-07-11< >%e< >1234.875< >1.234875e+03< >%e< >0.000012345< >1.234500e-05< >%e< >1234567E96< >1.234567e+102<