summaryrefslogtreecommitdiff
path: root/doop.c
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2017-05-29 11:16:49 +0100
committerDavid Mitchell <davem@iabyn.com>2017-06-07 09:11:06 +0100
commit03a22d83037406c116b676033c0bd575b6e8ff8a (patch)
treec3bab2951208fa4f3c9ec7d8d992901c6bf36722 /doop.c
parent5860c1eebae0e97105f7ef5ebcb86d1c72654c51 (diff)
downloadperl-03a22d83037406c116b676033c0bd575b6e8ff8a.tar.gz
sv_vcatpvfn() family: make svmax arg Size_t
It was formerly I32. It should be unsigned since you can't have a negative number of args. And although you're unlikely to call sprintf with more than 0x7fffffff args, it makes it more consistent with other APIs which we've been gradually expanding to 64-bit/ptrsize. It also makes the code internal to Perl_sv_vcatpvfn_flags more consistent, when dealing with explict arg index formats like "%10$s". This function still has a mix of STRLEN (for string lengths) and Size_t (for arg indexes) but they are aliases for each other. I made Perl_do_sprintf()'s len arg SSize_t rather than Size_t, since it typically gets called with ptr diff arithmetic. Not sure if this is being overly cautious.
Diffstat (limited to 'doop.c')
-rw-r--r--doop.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/doop.c b/doop.c
index c97d9e3208..9b525ae53b 100644
--- a/doop.c
+++ b/doop.c
@@ -717,13 +717,14 @@ Perl_do_join(pTHX_ SV *sv, SV *delim, SV **mark, SV **sp)
}
void
-Perl_do_sprintf(pTHX_ SV *sv, I32 len, SV **sarg)
+Perl_do_sprintf(pTHX_ SV *sv, SSize_t len, SV **sarg)
{
STRLEN patlen;
const char * const pat = SvPV_const(*sarg, patlen);
bool do_taint = FALSE;
PERL_ARGS_ASSERT_DO_SPRINTF;
+ assert(len >= 1);
if (SvTAINTED(*sarg))
TAINT_PROPER(
@@ -736,7 +737,7 @@ Perl_do_sprintf(pTHX_ SV *sv, I32 len, SV **sarg)
SvUTF8_off(sv);
if (DO_UTF8(*sarg))
SvUTF8_on(sv);
- sv_vsetpvfn(sv, pat, patlen, NULL, sarg + 1, len - 1, &do_taint);
+ sv_vsetpvfn(sv, pat, patlen, NULL, sarg + 1, (Size_t)(len - 1), &do_taint);
SvSETMAGIC(sv);
if (do_taint)
SvTAINTED_on(sv);