summaryrefslogtreecommitdiff
path: root/sv.c
diff options
context:
space:
mode:
authorMarcus Holland-Moritz <mhx-perl@gmx.net>2008-11-09 13:42:58 +0000
committerMarcus Holland-Moritz <mhx-perl@gmx.net>2008-11-09 13:42:58 +0000
commit1d1ac7bc98334889587f2985125658b93a408866 (patch)
treecb779b504a24c0ec0aa0eac5515730f3ee101771 /sv.c
parentd85e265b2ae3a60df7d1fa65504e5ad351eac3c7 (diff)
downloadperl-1d1ac7bc98334889587f2985125658b93a408866.tar.gz
Fix warning code in Perl_sv_vcatpvfn() to make the TODO
tests introduced with #34781 pass. Add some more warning tests to t/lib/warnings/sv. p4raw-id: //depot/perl@34783
Diffstat (limited to 'sv.c')
-rw-r--r--sv.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/sv.c b/sv.c
index 000cfd2158..436f18fe44 100644
--- a/sv.c
+++ b/sv.c
@@ -9122,6 +9122,7 @@ Perl_sv_vcatpvfn(pTHX_ SV *const sv, const char *const pat, const STRLEN patlen,
STRLEN esignlen = 0;
const char *eptr = NULL;
+ const char *fmtstart;
STRLEN elen = 0;
SV *vecsv = NULL;
const U8 *vecstr = NULL;
@@ -9162,6 +9163,8 @@ Perl_sv_vcatpvfn(pTHX_ SV *const sv, const char *const pat, const STRLEN patlen,
if (q++ >= patend)
break;
+ fmtstart = q;
+
/*
We allow format specification elements in this order:
\d+\$ explicit format parameter index
@@ -9976,16 +9979,22 @@ Perl_sv_vcatpvfn(pTHX_ SV *const sv, const char *const pat, const STRLEN patlen,
SV * const msg = sv_newmortal();
Perl_sv_setpvf(aTHX_ msg, "Invalid conversion in %sprintf: ",
(PL_op->op_type == OP_PRTF) ? "" : "s");
- if (c) {
- if (isPRINT(c))
- Perl_sv_catpvf(aTHX_ msg,
- "\"%%%c\"", c & 0xFF);
- else
- Perl_sv_catpvf(aTHX_ msg,
- "\"%%\\%03"UVof"\"",
- (UV)c & 0xFF);
- } else
+ if (fmtstart < patend) {
+ const char * const fmtend = q < patend ? q : patend;
+ const char * f;
+ sv_catpvs(msg, "\"%");
+ for (f = fmtstart; f < fmtend; f++) {
+ if (isPRINT(*f)) {
+ sv_catpvn(msg, f, 1);
+ } else {
+ Perl_sv_catpvf(aTHX_ msg,
+ "\\%03"UVof, (UV)*f & 0xFF);
+ }
+ }
+ sv_catpvs(msg, "\"");
+ } else {
sv_catpvs(msg, "end of string");
+ }
Perl_warner(aTHX_ packWARN(WARN_PRINTF), "%"SVf, SVfARG(msg)); /* yes, this is reentrant */
}