diff options
author | David Mitchell <davem@iabyn.com> | 2017-05-29 11:16:49 +0100 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2017-06-07 09:11:06 +0100 |
commit | 03a22d83037406c116b676033c0bd575b6e8ff8a (patch) | |
tree | c3bab2951208fa4f3c9ec7d8d992901c6bf36722 /doop.c | |
parent | 5860c1eebae0e97105f7ef5ebcb86d1c72654c51 (diff) | |
download | perl-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.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -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); |