Update Changes.
[p5sagit/p5-mst-13.2.git] / toke.c
diff --git a/toke.c b/toke.c
index 9d03733..ddf052e 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -209,10 +209,8 @@ S_no_op(pTHX_ char *what, char *s)
 
     if (!s)
        s = oldbp;
-    else {
-       assert(s >= oldbp);
+    else
        PL_bufptr = s;
-    }
     yywarn(Perl_form(aTHX_ "%s found where operator expected", what));
     if (is_first)
        Perl_warn(aTHX_ "\t(Missing semicolon on previous line?)\n");
@@ -223,8 +221,10 @@ S_no_op(pTHX_ char *what, char *s)
            Perl_warn(aTHX_ "\t(Do you need to predeclare %.*s?)\n",
                t - PL_oldoldbufptr, PL_oldoldbufptr);
     }
-    else
+    else {
+       assert(s >= oldbp);
        Perl_warn(aTHX_ "\t(Missing operator before %.*s?)\n", s - oldbp, oldbp);
+    }
     PL_bufptr = oldbp;
 }
 
@@ -3980,11 +3980,11 @@ Perl_yylex(pTHX)
                /* Mark this internal pseudo-handle as clean */
                IoFLAGS(GvIOp(gv)) |= IOf_UNTAINT;
                if (PL_preprocess)
-                   IoTYPE(GvIOp(gv)) = '|';
+                   IoTYPE(GvIOp(gv)) = IoTYPE_PIPE;
                else if ((PerlIO*)PL_rsfp == PerlIO_stdin())
-                   IoTYPE(GvIOp(gv)) = '-';
+                   IoTYPE(GvIOp(gv)) = IoTYPE_STD;
                else
-                   IoTYPE(GvIOp(gv)) = '<';
+                   IoTYPE(GvIOp(gv)) = IoTYPE_RDONLY;
 #if defined(WIN32) && !defined(PERL_TEXTMODE_SCRIPTS)
                /* if the script was opened in binmode, we need to revert
                 * it to text mode for compatibility; but only iff it has CRs
@@ -3993,7 +3993,7 @@ Perl_yylex(pTHX)
                    && PL_bufend[-1] == '\n' && PL_bufend[-2] == '\r')
                {
                    Off_t loc = 0;
-                   if (IoTYPE(GvIOp(gv)) == '<') {
+                   if (IoTYPE(GvIOp(gv)) == IoTYPE_RDONLY) {
                        loc = PerlIO_tell(PL_rsfp);
                        (void)PerlIO_seek(PL_rsfp, 0L, 0);
                    }
@@ -5742,13 +5742,12 @@ S_new_constant(pTHX_ char *s, STRLEN len, const char *key, SV *sv, SV *pv,
     SAVETMPS;
     
     PUSHMARK(SP) ;
-    EXTEND(sp, 4);
+    EXTEND(sp, 3);
     if (pv)
        PUSHs(pv);
     PUSHs(sv);
     if (pv)
        PUSHs(typesv);
-    PUSHs(cv);
     PUTBACK;
     call_sv(cv, G_SCALAR | ( PL_in_eval ? 0 : G_EVAL));
     
@@ -7386,8 +7385,8 @@ S_swallow_bom(pTHX_ U8 *s)
 
                filter_add(utf16rev_textfilter, NULL);
                New(898, news, (PL_bufend - (char*)s) * 3 / 2 + 1, U8);
-               PL_bufend = (char*)utf16_to_utf8(s, news,
-                                                PL_bufend - (char*)s,
+               PL_bufend = (char*)utf16_to_utf8_reversed(s, news,
+                                                PL_bufend - (char*)s - 1,
                                                 &newlen);
                Copy(news, s, newlen, U8);
                SvCUR_set(PL_linestr, newlen);
@@ -7472,6 +7471,10 @@ utf16_textfilter(pTHXo_ int idx, SV *sv, int maxlen)
        U8* tend;
        I32 newlen;
        New(898, tmps, SvCUR(sv) * 3 / 2 + 1, U8);
+       if (!*SvPV_nolen(sv))
+       /* Game over, but don't feed an odd-length string to utf16_to_utf8 */
+       return count;
+       
        tend = utf16_to_utf8((U8*)SvPVX(sv), tmps, SvCUR(sv), &newlen);
        sv_usepvn(sv, (char*)tmps, tend - tmps);
     }
@@ -7486,6 +7489,10 @@ utf16rev_textfilter(pTHXo_ int idx, SV *sv, int maxlen)
        U8* tmps;
        U8* tend;
        I32 newlen;
+       if (!*SvPV_nolen(sv))
+       /* Game over, but don't feed an odd-length string to utf16_to_utf8 */
+       return count;
+
        New(898, tmps, SvCUR(sv) * 3 / 2 + 1, U8);
        tend = utf16_to_utf8_reversed((U8*)SvPVX(sv), tmps, SvCUR(sv), &newlen);
        sv_usepvn(sv, (char*)tmps, tend - tmps);