This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Perl_sv_vcatpvfn_flags: rename 'p' var 's'
authorDavid Mitchell <davem@iabyn.com>
Fri, 2 Jun 2017 10:41:41 +0000 (11:41 +0100)
committerDavid Mitchell <davem@iabyn.com>
Wed, 7 Jun 2017 08:11:09 +0000 (09:11 +0100)
In the 'append # block of code at the end of the loop, don't re-use the
widely-scoped 'p' pointer; instead use a tightly scope var instead
(named 's' do it doesn't clash with p which is still valid in an outer
scope.)

sv.c

diff --git a/sv.c b/sv.c
index a345396..58a5311 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -13256,6 +13256,7 @@ Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv, const char *const pat, const STRLEN p
         {
             STRLEN need, have, gap;
             STRLEN i;
+            char *s;
 
             /* signed value that's wrapped? */
             assert(elen  <= ((~(STRLEN)0) >> 1));
@@ -13279,40 +13280,40 @@ Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv, const char *const pat, const STRLEN p
 
             SvGROW(sv, need);
 
-            p = SvEND(sv);
+            s = SvEND(sv);
 
             if (left) {
                 for (i = 0; i < esignlen; i++)
-                    *p++ = esignbuf[i];
+                    *s++ = esignbuf[i];
                 for (i = zeros; i; i--)
-                    *p++ = '0';
-                Copy(eptr, p, elen, char);
-                p += elen;
+                    *s++ = '0';
+                Copy(eptr, s, elen, char);
+                s += elen;
                 for (i = gap; i; i--)
-                    *p++ = ' ';
+                    *s++ = ' ';
             }
             else {
                 if (fill) {
                     for (i = 0; i < esignlen; i++)
-                        *p++ = esignbuf[i];
+                        *s++ = esignbuf[i];
                     assert(!zeros);
                     zeros = gap;
                 }
                 else {
                     for (i = gap; i; i--)
-                        *p++ = ' ';
+                        *s++ = ' ';
                     for (i = 0; i < esignlen; i++)
-                        *p++ = esignbuf[i];
+                        *s++ = esignbuf[i];
                 }
 
                 for (i = zeros; i; i--)
-                    *p++ = '0';
-                Copy(eptr, p, elen, char);
-                p += elen;
+                    *s++ = '0';
+                Copy(eptr, s, elen, char);
+                s += elen;
             }
 
-            *p = '\0';
-            SvCUR_set(sv, p - SvPVX_const(sv));
+            *s = '\0';
+            SvCUR_set(sv, s - SvPVX_const(sv));
 
             if (is_utf8)
                 has_utf8 = TRUE;