This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
pp_formline: FF_LINEGLOB: hoist 2 vars to fn scope
authorDavid Mitchell <davem@iabyn.com>
Sat, 28 May 2011 14:13:27 +0000 (15:13 +0100)
committerDavid Mitchell <davem@iabyn.com>
Sun, 29 May 2011 19:21:52 +0000 (20:21 +0100)
more groundwork for making the code in FF_LINEGLOB re-usable

pp_ctl.c

index 8d023c6..3304eac 100644 (file)
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -545,6 +545,8 @@ PP(pp_formline)
     SV * nsv = NULL;
     const char *fmt;
     MAGIC *mg = NULL;
+    U8 *source;                    /* source of bytes to append */
+    STRLEN to_copy;        /* how may bytes to append */
 
     mg = doparseform(tmpForm);
 
@@ -890,8 +892,6 @@ PP(pp_formline)
                const bool oneline = fpc[-1] == FF_LINESNGL;
                const char *s = item = SvPV_const(sv, len);
                const char *const send = s + len;
-               STRLEN to_copy = len;
-               const U8 *source = (const U8 *) s;
                U8 *tmp = NULL;
 
                item_is_utf8 = DO_UTF8(sv);
@@ -900,6 +900,8 @@ PP(pp_formline)
                    break;
                gotsome = TRUE;
                chophere = s + itemsize;
+               source = (U8 *) s;
+               to_copy = len;
                while (s < send) {
                    if (*s++ == '\n') {
                        if (oneline) {