summaryrefslogtreecommitdiff
path: root/sv.c
diff options
context:
space:
mode:
authorRobin Barker <RMBarker@cpan.org>2003-06-11 19:10:14 +0100
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2003-06-12 20:49:25 +0000
commitdca6e23fb83957e896abba24cceb553cbf56fb78 (patch)
tree5c250bf50f16eda93a9c311c1ff60f94f728bdd9 /sv.c
parentf93414403b07cda0cb271cd283f020f4981ff2c8 (diff)
downloadperl-dca6e23fb83957e896abba24cceb553cbf56fb78.tar.gz
Add a new warning, "Newline in left-justified string for printf/sprintf"
to be issued if the string to be left-justified by s?printf contains a newline. Subject: [PATCH] RE: [perl #22599] Strange behaviour when combining foreac h and printf Message-ID: <533D273D4014D411AB1D00062938C4D904046571@hotel.npl.co.uk> p4raw-id: //depot/perl@19752
Diffstat (limited to 'sv.c')
-rw-r--r--sv.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/sv.c b/sv.c
index 932438b862..d1324fc60f 100644
--- a/sv.c
+++ b/sv.c
@@ -9329,6 +9329,11 @@ Perl_sv_vcatpvfn(pTHX_ SV *sv, const char *pat, STRLEN patlen, va_list *args, SV
p = SvEND(sv);
*p = '\0';
}
+ if (left && ckWARN(WARN_PRINTF) && strchr(eptr, '\n') &&
+ (PL_op->op_type == OP_PRTF || PL_op->op_type == OP_SPRINTF))
+ Perl_warner(aTHX_ packWARN(WARN_PRINTF),
+ "Newline in left-justified string for %sprintf",
+ (PL_op->op_type == OP_PRTF) ? "" : "s");
have = esignlen + zeros + elen;
need = (have > width ? have : width);