This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
A more efficient way of expressing the MALLOC_WRAP conditional compile.
[perl5.git] / toke.c
diff --git a/toke.c b/toke.c
index d666ce2..a4898a2 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -26,9 +26,9 @@
 #define yychar (*PL_yycharp)
 #define yylval (*PL_yylvalp)
 
-static char ident_too_long[] = "Identifier too long";
-static char c_without_g[] = "Use of /c modifier is meaningless without /g";
-static char c_in_subst[] = "Use of /c modifier is meaningless in s///";
+static char const ident_too_long[] = "Identifier too long";
+static char const c_without_g[] = "Use of /c modifier is meaningless without /g";
+static char const c_in_subst[] = "Use of /c modifier is meaningless in s///";
 
 static void restore_rsfp(pTHX_ void *f);
 #ifndef PERL_NO_UTF16_FILTER
@@ -76,7 +76,7 @@ static I32 utf16rev_textfilter(pTHX_ int idx, SV *sv, int maxlen);
 #define LEX_KNOWNEXT            0
 
 #ifdef DEBUGGING
-static char* lex_state_names[] = {
+static char const* lex_state_names[] = {
     "KNOWNEXT",
     "FORMLINE",
     "INTERPCONST",
@@ -199,7 +199,7 @@ enum token_type {
     TOKENTYPE_GVVAL
 };
 
-static struct debug_tokens { int token, type; char *name;} debug_tokens[] =
+static struct debug_tokens { const int token, type; const char *name; } debug_tokens[] =
 {
     { ADDOP,           TOKENTYPE_OPNUM,        "ADDOP" },
     { ANDAND,          TOKENTYPE_NONE,         "ANDAND" },
@@ -269,13 +269,13 @@ static struct debug_tokens { int token, type; char *name;} debug_tokens[] =
 /* dump the returned token in rv, plus any optional arg in yylval */
 
 STATIC int
-S_tokereport(pTHX_ char* s, I32 rv)
+S_tokereport(pTHX_ const char* s, I32 rv)
 {
     if (DEBUG_T_TEST) {
-       char *name = Nullch;
+       const char *name = Nullch;
        enum token_type type = TOKENTYPE_NONE;
        struct debug_tokens *p;
-        SV* report = newSVpvn("<== ", 4);
+       SV* report = newSVpvn("<== ", 4);
 
        for (p = debug_tokens; p->token; p++) {
            if (p->token == (int)rv) {
@@ -297,7 +297,7 @@ S_tokereport(pTHX_ char* s, I32 rv)
        case TOKENTYPE_GVVAL: /* doesn't appear to be used */
            break;
        case TOKENTYPE_IVAL:
-           Perl_sv_catpvf(aTHX_ report, "(ival=%"IVdf")", yylval.ival);
+           Perl_sv_catpvf(aTHX_ report, "(ival=%"IVdf")", (IV)yylval.ival);
            break;
        case TOKENTYPE_OPNUM:
            Perl_sv_catpvf(aTHX_ report, "(ival=op_%s)",
@@ -314,7 +314,7 @@ S_tokereport(pTHX_ char* s, I32 rv)
                Perl_sv_catpv(aTHX_ report, "(opval=null)");
            break;
        }
-        Perl_sv_catpvf(aTHX_ report, " at line %d [", CopLINE(PL_curcop));
+        Perl_sv_catpvf(aTHX_ report, " at line %"IVdf" [", (IV)CopLINE(PL_curcop));
         if (s - PL_bufptr > 0)
             sv_catpvn(report, PL_bufptr, s - PL_bufptr);
         else {
@@ -365,7 +365,7 @@ S_ao(pTHX_ int toketype)
  */
 
 STATIC void
-S_no_op(pTHX_ char *what, char *s)
+S_no_op(pTHX_ const char *what, char *s)
 {
     char *oldbp = PL_bufptr;
     bool is_first = (PL_oldbufptr == PL_linestart);
@@ -424,7 +424,6 @@ S_missingterm(pTHX_ char *s)
        ) {
        *tmpbuf = '^';
        tmpbuf[1] = toCTRL(PL_multi_close);
-       s = "\\n";
        tmpbuf[2] = '\0';
        s = tmpbuf;
     }
@@ -442,14 +441,14 @@ S_missingterm(pTHX_ char *s)
  */
 
 void
-Perl_deprecate(pTHX_ char *s)
+Perl_deprecate(pTHX_ const char *s)
 {
     if (ckWARN(WARN_DEPRECATED))
        Perl_warner(aTHX_ packWARN(WARN_DEPRECATED), "Use of %s is deprecated", s);
 }
 
 void
-Perl_deprecate_old(pTHX_ char *s)
+Perl_deprecate_old(pTHX_ const char *s)
 {
     /* This function should NOT be called for any new deprecated warnings */
     /* Use Perl_deprecate instead                                         */
@@ -460,7 +459,7 @@ Perl_deprecate_old(pTHX_ char *s)
     /* in its own right.                                                  */
 
     if (ckWARN2(WARN_DEPRECATED, WARN_SYNTAX))
-       Perl_warner(aTHX_ packWARN2(WARN_DEPRECATED, WARN_SYNTAX), 
+       Perl_warner(aTHX_ packWARN2(WARN_DEPRECATED, WARN_SYNTAX),
                        "Use of %s is deprecated", s);
 }
 
@@ -776,7 +775,7 @@ S_skipspace(pTHX_ register char *s)
            sv_upgrade(sv, SVt_PVMG);
            sv_setpvn(sv,PL_bufptr,PL_bufend-PL_bufptr);
             (void)SvIOK_on(sv);
-            SvIVX(sv) = 0;
+            SvIV_set(sv, 0);
            av_store(CopFILEAV(PL_curcop),(I32)CopLINE(PL_curcop),sv);
        }
     }
@@ -874,7 +873,7 @@ STATIC SV *
 S_newSV_maybe_utf8(pTHX_ const char *start, STRLEN len)
 {
     SV *sv = newSVpvn(start,len);
-    if (UTF && !IN_BYTES && is_utf8_string((U8*)start, len))
+    if (UTF && !IN_BYTES && is_utf8_string((const U8*)start, len))
        SvUTF8_on(sv);
     return sv;
 }
@@ -937,10 +936,10 @@ S_force_word(pTHX_ register char *start, int token, int check_keyword, int allow
  */
 
 STATIC void
-S_force_ident(pTHX_ register char *s, int kind)
+S_force_ident(pTHX_ register const char *s, int kind)
 {
     if (s && *s) {
-       OP* o = (OP*)newSVOP(OP_CONST, 0, newSVpv(s,0));
+       OP* const o = (OP*)newSVOP(OP_CONST, 0, newSVpv(s,0));
        PL_nextval[PL_nexttoke].opval = o;
        force_next(WORD);
        if (kind) {
@@ -1012,7 +1011,7 @@ S_force_version(pTHX_ char *s, int guessing)
            ver = cSVOPx(version)->op_sv;
            if (SvPOK(ver) && !SvNIOK(ver)) {
                (void)SvUPGRADE(ver, SVt_PVNV);
-               SvNVX(ver) = str_to_version(ver);
+               SvNV_set(ver, str_to_version(ver));
                SvNOK_on(ver);          /* hint that it is a version */
            }
         }
@@ -1550,7 +1549,7 @@ S_scan_const(pTHX_ char *start)
            default:
                {
                    if (ckWARN(WARN_MISC) &&
-                       isALNUM(*s) && 
+                       isALNUM(*s) &&
                        *s != '_')
                        Perl_warner(aTHX_ packWARN(WARN_MISC),
                               "Unrecognized escape \\%c passed through",
@@ -2092,11 +2091,11 @@ S_intuit_method(pTHX_ char *start, GV *gv)
  * compile-time require of perl5db.pl.
  */
 
-STATIC char*
+STATIC const char*
 S_incl_perldb(pTHX)
 {
     if (PL_perldb) {
-       char *pdb = PerlEnv_getenv("PERL5DB");
+       const char *pdb = PerlEnv_getenv("PERL5DB");
 
        if (pdb)
            return pdb;
@@ -2247,7 +2246,7 @@ S_filter_gets(pTHX_ register SV *sv, register PerlIO *fp, STRLEN append)
 }
 
 STATIC HV *
-S_find_in_my_stash(pTHX_ char *pkgname, I32 len)
+S_find_in_my_stash(pTHX_ const char *pkgname, I32 len)
 {
     GV *gv;
 
@@ -2273,7 +2272,7 @@ S_find_in_my_stash(pTHX_ char *pkgname, I32 len)
 }
 
 #ifdef DEBUGGING
-    static char* exp_name[] =
+    static char const* exp_name[] =
        { "OPERATOR", "TERM", "REF", "STATE", "BLOCK", "ATTRBLOCK",
          "ATTRTERM", "TERMBLOCK", "TERMORDORDOR"
        };
@@ -2604,14 +2603,14 @@ Perl_yylex(pTHX)
                            /* The count here deliberately includes the NUL
                               that terminates the C string constant.  This
                               embeds the opening NUL into the string.  */
+                           const char *splits = PL_splitstr;
                            sv_catpvn(PL_linestr, "our @F=split(q", 15);
-                           s = PL_splitstr;
                            do {
                                /* Need to \ \s  */
-                               if (*s == '\\')
-                                   sv_catpvn(PL_linestr, s, 1);
-                               sv_catpvn(PL_linestr, s, 1);
-                           } while (*s++);
+                               if (*splits == '\\')
+                                   sv_catpvn(PL_linestr, splits, 1);
+                               sv_catpvn(PL_linestr, splits, 1);
+                           } while (*splits++);
                            /* This loop will embed the trailing NUL of
                               PL_linestr as the last thing it does before
                               terminating.  */
@@ -2632,7 +2631,7 @@ Perl_yylex(pTHX)
                sv_upgrade(sv, SVt_PVMG);
                sv_setsv(sv,PL_linestr);
                 (void)SvIOK_on(sv);
-                SvIVX(sv) = 0;
+                SvIV_set(sv, 0);
                av_store(CopFILEAV(PL_curcop),(I32)CopLINE(PL_curcop),sv);
            }
            goto retry;
@@ -2719,7 +2718,7 @@ Perl_yylex(pTHX)
            sv_upgrade(sv, SVt_PVMG);
            sv_setsv(sv,PL_linestr);
             (void)SvIOK_on(sv);
-            SvIVX(sv) = 0;
+            SvIV_set(sv, 0);
            av_store(CopFILEAV(PL_curcop),(I32)CopLINE(PL_curcop),sv);
        }
        PL_bufend = SvPVX(PL_linestr) + SvCUR(PL_linestr);
@@ -2735,7 +2734,7 @@ Perl_yylex(pTHX)
                    d = s + 2;
 #ifdef ALTERNATE_SHEBANG
                else {
-                   static char as[] = ALTERNATE_SHEBANG;
+                   static char const as[] = ALTERNATE_SHEBANG;
                    if (*s == as[0] && strnEQ(s, as, sizeof(as) - 1))
                        d = s + (sizeof(as) - 1);
                }
@@ -2867,7 +2866,7 @@ Perl_yylex(pTHX)
                    if (*d++ == '-') {
                        bool switches_done = PL_doswitches;
                        do {
-                           if (*d == 'M' || *d == 'm') {
+                           if (*d == 'M' || *d == 'm' || *d == 'C') {
                                char *m = d;
                                while (*d && !isSPACE(*d)) d++;
                                Perl_croak(aTHX_ "Too late for \"-%.*s\" option",
@@ -3179,7 +3178,7 @@ Perl_yylex(pTHX)
 #else
                            ; /* skip to avoid loading attributes.pm */
 #endif
-                       else 
+                       else
                            Perl_croak(aTHX_ "The 'unique' attribute may only be applied to 'our' variables");
                    }
 
@@ -4276,7 +4275,7 @@ Perl_yylex(pTHX)
                        while (*proto == ';')
                            proto++;
                        if (*proto == '&' && *s == '{') {
-                           sv_setpv(PL_subname, PL_curstash ? 
+                           sv_setpv(PL_subname, PL_curstash ?
                                        "__ANON__" : "__ANON__::__ANON__");
                            PREBLOCK(LSTOPSUB);
                        }
@@ -4339,7 +4338,7 @@ Perl_yylex(pTHX)
 
            /*SUPPRESS 560*/
            if (PL_rsfp && (!PL_in_eval || PL_tokenbuf[2] == 'D')) {
-               char *pname = "main";
+               const char *pname = "main";
                if (PL_tokenbuf[2] == 'D')
                    pname = HvNAME(PL_curstash ? PL_curstash : PL_defstash);
                gv = gv_fetchpv(Perl_form(aTHX_ "%s::DATA", pname), TRUE, SVt_PVIO);
@@ -4406,7 +4405,7 @@ Perl_yylex(pTHX)
                        SPAGAIN;
                        name = POPs;
                        PUTBACK;
-                       PerlIO_apply_layers(aTHX_ PL_rsfp, NULL, 
+                       PerlIO_apply_layers(aTHX_ PL_rsfp, NULL,
                                            Perl_form(aTHX_ ":encoding(%"SVf")",
                                                      name));
                        FREETMPS;
@@ -4991,7 +4990,7 @@ Perl_yylex(pTHX)
                missingterm((char*)0);
            yylval.ival = OP_STRINGIFY;
            if (SvIVX(PL_lex_stuff) == '\'')
-               SvIVX(PL_lex_stuff) = 0;        /* qq'$foo' should intepolate */
+               SvIV_set(PL_lex_stuff, 0);      /* qq'$foo' should intepolate */
            TERM(sublex_start());
 
        case KEY_qr:
@@ -5602,36 +5601,26 @@ Perl_keyword (pTHX_ char *name, I32 len)
             return KEY_m;
           }
 
-          goto unknown;
-
         case 'q':
           {                                       /* q          */
             return KEY_q;
           }
 
-          goto unknown;
-
         case 's':
           {                                       /* s          */
             return KEY_s;
           }
 
-          goto unknown;
-
         case 'x':
           {                                       /* x          */
             return -KEY_x;
           }
 
-          goto unknown;
-
         case 'y':
           {                                       /* y          */
             return KEY_y;
           }
 
-          goto unknown;
-
         default:
           goto unknown;
       }
@@ -5663,15 +5652,11 @@ Perl_keyword (pTHX_ char *name, I32 len)
                 return -KEY_ge;
               }
 
-              goto unknown;
-
             case 't':
               {                                   /* gt         */
                 return -KEY_gt;
               }
 
-              goto unknown;
-
             default:
               goto unknown;
           }
@@ -5692,22 +5677,16 @@ Perl_keyword (pTHX_ char *name, I32 len)
                 return -KEY_lc;
               }
 
-              goto unknown;
-
             case 'e':
               {                                   /* le         */
                 return -KEY_le;
               }
 
-              goto unknown;
-
             case 't':
               {                                   /* lt         */
                 return -KEY_lt;
               }
 
-              goto unknown;
-
             default:
               goto unknown;
           }
@@ -5728,15 +5707,11 @@ Perl_keyword (pTHX_ char *name, I32 len)
                 return -KEY_ne;
               }
 
-              goto unknown;
-
             case 'o':
               {                                   /* no         */
                 return KEY_no;
               }
 
-              goto unknown;
-
             default:
               goto unknown;
           }
@@ -5757,29 +5732,21 @@ Perl_keyword (pTHX_ char *name, I32 len)
                 return KEY_qq;
               }
 
-              goto unknown;
-
             case 'r':
               {                                   /* qr         */
                 return KEY_qr;
               }
 
-              goto unknown;
-
             case 'w':
               {                                   /* qw         */
                 return KEY_qw;
               }
 
-              goto unknown;
-
             case 'x':
               {                                   /* qx         */
                 return KEY_qx;
               }
 
-              goto unknown;
-
             default:
               goto unknown;
           }
@@ -6005,15 +5972,11 @@ Perl_keyword (pTHX_ char *name, I32 len)
                   return -KEY_pop;
                 }
 
-                goto unknown;
-
               case 's':
                 {                                 /* pos        */
                   return KEY_pos;
                 }
 
-                goto unknown;
-
               default:
                 goto unknown;
             }
@@ -6946,15 +6909,11 @@ Perl_keyword (pTHX_ char *name, I32 len)
                           return KEY_untie;
                         }
 
-                        goto unknown;
-
                       case 'l':
                         {                         /* until      */
                           return KEY_until;
                         }
 
-                        goto unknown;
-
                       default:
                         goto unknown;
                     }
@@ -8152,15 +8111,11 @@ Perl_keyword (pTHX_ char *name, I32 len)
                         return -KEY_readline;
                       }
 
-                      goto unknown;
-
                     case 'k':
                       {                           /* readlink   */
                         return -KEY_readlink;
                       }
 
-                      goto unknown;
-
                     default:
                       goto unknown;
                   }
@@ -8932,7 +8887,7 @@ unknown:
 }
 
 STATIC void
-S_checkcomma(pTHX_ register char *s, char *name, char *what)
+S_checkcomma(pTHX_ register char *s, char *name, const char *what)
 {
     char *w;
 
@@ -8982,7 +8937,7 @@ S_checkcomma(pTHX_ register char *s, char *name, char *what)
    and type is used with error messages only. */
 
 STATIC SV *
-S_new_constant(pTHX_ char *s, STRLEN len, const char *key, SV *sv, SV *pv,
+S_new_constant(pTHX_ const char *s, STRLEN len, const char *key, SV *sv, SV *pv,
               const char *type)
 {
     dSP;
@@ -9315,7 +9270,7 @@ S_scan_pat(pTHX_ char *start, I32 type)
            pmflag(&pm->op_pmflags,*s++);
     }
     /* issue a warning if /c is specified,but /g is not */
-    if (ckWARN(WARN_REGEXP) && 
+    if (ckWARN(WARN_REGEXP) &&
         (pm->op_pmflags & PMf_CONTINUE) && !(pm->op_pmflags & PMf_GLOBAL))
     {
         Perl_warner(aTHX_ packWARN(WARN_REGEXP), c_without_g);
@@ -9464,6 +9419,8 @@ S_scan_heredoc(pTHX_ register char *s)
     I32 len;
     SV *tmpstr;
     char term;
+    const char newline[] = "\n";
+    const char *found_newline;
     register char *d;
     register char *e;
     char *peek;
@@ -9524,22 +9481,24 @@ S_scan_heredoc(pTHX_ register char *s)
        s = olds;
     }
 #endif
-    d = "\n";
-    if (outer || !(d=ninstr(s,PL_bufend,d,d+1)))
-       herewas = newSVpvn(s,PL_bufend-s);
-    else
-       s--, herewas = newSVpvn(s,d-s);
+    if ( outer || !(found_newline = ninstr(s,PL_bufend,newline,newline+1)) ) {
+        herewas = newSVpvn(s,PL_bufend-s);
+    }
+    else {
+        s--;
+        herewas = newSVpvn(s,found_newline-s);
+    }
     s += SvCUR(herewas);
 
     tmpstr = NEWSV(87,79);
     sv_upgrade(tmpstr, SVt_PVIV);
     if (term == '\'') {
        op_type = OP_CONST;
-       SvIVX(tmpstr) = -1;
+       SvIV_set(tmpstr, -1);
     }
     else if (term == '`') {
        op_type = OP_BACKTICK;
-       SvIVX(tmpstr) = '\\';
+       SvIV_set(tmpstr, '\\');
     }
 
     CLINE;
@@ -9625,7 +9584,7 @@ S_scan_heredoc(pTHX_ register char *s)
            sv_upgrade(sv, SVt_PVMG);
            sv_setsv(sv,PL_linestr);
             (void)SvIOK_on(sv);
-            SvIVX(sv) = 0;
+            SvIV_set(sv, 0);
            av_store(CopFILEAV(PL_curcop), (I32)CopLINE(PL_curcop),sv);
        }
        if (*s == term && memEQ(s,PL_tokenbuf,len)) {
@@ -9911,7 +9870,7 @@ S_scan_str(pTHX_ char *start, int keep_quoted, int keep_delims)
        assuming.  79 is the SV's initial length.  What a random number. */
     sv = NEWSV(87,79);
     sv_upgrade(sv, SVt_PVIV);
-    SvIVX(sv) = termcode;
+    SvIV_set(sv, termcode);
     (void)SvPOK_only(sv);              /* validate pointer */
 
     /* move past delimiter and try to read a complete string */
@@ -10097,7 +10056,7 @@ S_scan_str(pTHX_ char *start, int keep_quoted, int keep_delims)
            sv_upgrade(sv, SVt_PVMG);
            sv_setsv(sv,PL_linestr);
             (void)SvIOK_on(sv);
-            SvIVX(sv) = 0;
+            SvIV_set(sv, 0);
            av_store(CopFILEAV(PL_curcop), (I32)CopLINE(PL_curcop), sv);
        }
 
@@ -10158,16 +10117,16 @@ S_scan_str(pTHX_ char *start, int keep_quoted, int keep_delims)
 */
 
 char *
-Perl_scan_num(pTHX_ char *start, YYSTYPE* lvalp)
+Perl_scan_num(pTHX_ const char *start, YYSTYPE* lvalp)
 {
-    register char *s = start;          /* current position in buffer */
+    register const char *s = start;    /* current position in buffer */
     register char *d;                  /* destination in temp buffer */
     register char *e;                  /* end of temp buffer */
     NV nv;                             /* number read, as a double */
     SV *sv = Nullsv;                   /* place to put the converted number */
     bool floatit;                      /* boolean: int or float? */
-    char *lastub = 0;                  /* position of last underbar */
-    static char number_too_long[] = "Number too long";
+    const char *lastub = 0;            /* position of last underbar */
+    static char const number_too_long[] = "Number too long";
 
     /* We use the first character to decide what type of number this is */
 
@@ -10195,16 +10154,16 @@ Perl_scan_num(pTHX_ char *start, YYSTYPE* lvalp)
            bool overflowed = FALSE;
            bool just_zero  = TRUE;     /* just plain 0 or binary number? */
            static NV nvshift[5] = { 1.0, 2.0, 4.0, 8.0, 16.0 };
-           static char* bases[5] = { "", "binary", "", "octal",
+           static char const* bases[5] = { "", "binary", "", "octal",
                                      "hexadecimal" };
-           static char* Bases[5] = { "", "Binary", "", "Octal",
+           static char const* Bases[5] = { "", "Binary", "", "Octal",
                                      "Hexadecimal" };
-           static char *maxima[5] = { "",
+           static char const *maxima[5] = { "",
                                       "0b11111111111111111111111111111111",
                                       "",
                                       "037777777777",
                                       "0xffffffff" };
-           char *base, *Base, *max;
+           const char *base, *Base, *max;
 
            /* check for hex */
            if (s[1] == 'x') {
@@ -10346,7 +10305,7 @@ Perl_scan_num(pTHX_ char *start, YYSTYPE* lvalp)
                sv_setuv(sv, u);
            }
            if (just_zero && (PL_hints & HINT_NEW_INTEGER))
-               sv = new_constant(start, s - start, "integer", 
+               sv = new_constant(start, s - start, "integer",
                                  sv, Nullsv, NULL);
            else if (PL_hints & HINT_NEW_BINARY)
                sv = new_constant(start, s - start, "binary", sv, Nullsv, NULL);
@@ -10534,7 +10493,7 @@ vstring:
     else
        lvalp->opval = Nullop;
 
-    return s;
+    return (char *)s;
 }
 
 STATIC char *
@@ -10560,7 +10519,7 @@ S_scan_formline(pTHX_ register char *s)
             }
        }
        if (PL_in_eval && !PL_rsfp) {
-           eol = memchr(s,'\n',PL_bufend-s);
+           eol = (char *) memchr(s,'\n',PL_bufend-s);
            if (!eol++)
                eol = PL_bufend;
        }
@@ -10670,7 +10629,7 @@ Perl_start_subparse(pTHX_ I32 is_format, U32 flags)
 #pragma segment Perl_yylex
 #endif
 int
-Perl_yywarn(pTHX_ char *s)
+Perl_yywarn(pTHX_ const char *s)
 {
     PL_in_eval |= EVAL_WARNONLY;
     yyerror(s);
@@ -10679,10 +10638,10 @@ Perl_yywarn(pTHX_ char *s)
 }
 
 int
-Perl_yyerror(pTHX_ char *s)
+Perl_yyerror(pTHX_ const char *s)
 {
-    char *where = NULL;
-    char *context = NULL;
+    const char *where = NULL;
+    const char *context = NULL;
     int contlen = -1;
     SV *msg;
 
@@ -10945,22 +10904,22 @@ passed in, for performance reasons.
 */
 
 char *
-Perl_scan_vstring(pTHX_ char *s, SV *sv)
+Perl_scan_vstring(pTHX_ const char *s, SV *sv)
 {
-    char *pos = s;
-    char *start = s;
+    const char *pos = s;
+    const char *start = s;
     if (*pos == 'v') pos++;  /* get past 'v' */
     while (pos < PL_bufend && (isDIGIT(*pos) || *pos == '_'))
        pos++;
     if ( *pos != '.') {
        /* this may not be a v-string if followed by => */
-       char *next = pos;
+       const char *next = pos;
        while (next < PL_bufend && isSPACE(*next))
            ++next;
        if ((PL_bufend - next) >= 2 && *next == '=' && next[1] == '>' ) {
            /* return string not v-string */
            sv_setpvn(sv,(char *)s,pos-s);
-           return pos;
+           return (char *)pos;
        }
     }
 
@@ -10977,7 +10936,7 @@ Perl_scan_vstring(pTHX_ char *s, SV *sv)
            rev = 0;
            {
                /* this is atoi() that tolerates underscores */
-               char *end = pos;
+               const char *end = pos;
                UV mult = 1;
                while (--end >= s) {
                    UV orev;
@@ -11013,6 +10972,6 @@ Perl_scan_vstring(pTHX_ char *s, SV *sv)
        sv_magic(sv,NULL,PERL_MAGIC_vstring,(const char*)start, pos-start);
        SvRMAGICAL_on(sv);
     }
-    return s;
+    return (char *)s;
 }