Fix a syntax error in test
[p5sagit/p5-mst-13.2.git] / regexec.c
index 747b61b..0f5d6fb 100644 (file)
--- a/regexec.c
+++ b/regexec.c
            : (U8*)(pos + off)))
 #define HOPBACKc(pos, off) ((char*)    \
     ((PL_reg_match_utf8)               \
-       ? reghopmaybe3((U8*)pos, -off, ((U8*)(off < 0 ? PL_regeol : PL_bostr))) \
+       ? reghopmaybe3((U8*)pos, -off, (U8*)PL_bostr) \
     : (pos - off >= PL_bostr)          \
        ? (U8*)(pos - off)              \
     : (U8*)NULL)                       \
 )
 
-#define reghopmaybe3_c(pos,off,lim) ((char*)reghopmaybe3((U8*)pos, off, (U8*)lim))
 #define HOP3(pos,off,lim) (PL_reg_match_utf8 ? reghop3((U8*)pos, off, (U8*)lim) : (U8*)(pos + off))
 #define HOP3c(pos,off,lim) ((char*)HOP3(pos,off,lim))
 
@@ -233,7 +232,7 @@ S_regcppop(pTHX_ const regexp *rex)
        );
     }
     DEBUG_EXECUTE_r(
-       if ((I32)(*PL_reglastparen + 1) <= rex->nparens) {
+       if (*PL_reglastparen + 1 <= rex->nparens) {
            PerlIO_printf(Perl_debug_log,
                          "     restoring \\%"IVdf"..\\%"IVdf" to undef\n",
                          (IV)(*PL_reglastparen + 1), (IV)rex->nparens);
@@ -250,7 +249,7 @@ S_regcppop(pTHX_ const regexp *rex)
      * building DynaLoader will fail:
      * "Error: '*' not in typemap in DynaLoader.xs, line 164"
      * --jhi */
-    for (i = *PL_reglastparen + 1; i <= rex->nparens; i++) {
+    for (i = *PL_reglastparen + 1; (U32)i <= rex->nparens; i++) {
        if (i > PL_regsize)
            PL_regstartp[i] = -1;
        PL_regendp[i] = -1;
@@ -383,7 +382,7 @@ Perl_re_intuit_start(pTHX_ regexp *prog, SV *sv, char *strpos,
                         sv_uni_display(dsv, sv, 60, UNI_DISPLAY_REGEX) :
                         strpos;
         const int   len = PL_reg_match_utf8 ?
-                        strlen(s) : strend - strpos;
+                        (int)strlen(s) : strend - strpos;
         if (!PL_colorset)
              reginitcolors();
         if (PL_reg_match_utf8)
@@ -572,9 +571,9 @@ Perl_re_intuit_start(pTHX_ regexp *prog, SV *sv, char *strpos,
                t = s - prog->check_offset_max;
                if (s - strpos > prog->check_offset_max  /* signed-corrected t > strpos */
                    && (!do_utf8
-                       || ((t = reghopmaybe3_c(s, -(prog->check_offset_max), strpos))
+                       || ((t = (char*)reghopmaybe3((U8*)s, -(prog->check_offset_max), (U8*)strpos))
                            && t > strpos)))
-                   /* EMPTY */;
+                   NOOP;
                else
                    t = strpos;
                t = HOP3c(t, prog->anchored_offset, strend);
@@ -692,7 +691,7 @@ Perl_re_intuit_start(pTHX_ regexp *prog, SV *sv, char *strpos,
     t = s - prog->check_offset_max;
     if (s - strpos > prog->check_offset_max  /* signed-corrected t > strpos */
         && (!do_utf8
-           || ((t = reghopmaybe3_c(s, -prog->check_offset_max, strpos))
+           || ((t = (char*)reghopmaybe3((U8*)s, -prog->check_offset_max, (U8*)strpos))
                 && t > strpos))) {
        /* Fixed substring is found far enough so that the match
           cannot start at strpos. */
@@ -1146,7 +1145,7 @@ S_find_byclass(pTHX_ regexp * prog, const regnode *c, char *s, const char
                LOAD_UTF8_CHARCLASS_ALNUM();
                while (s + (uskip = UTF8SKIP(s)) <= strend) {
                    if (tmp == !(OP(c) == BOUND ?
-                                swash_fetch(PL_utf8_alnum, (U8*)s, do_utf8) :
+                                (bool)swash_fetch(PL_utf8_alnum, (U8*)s, do_utf8) :
                                 isALNUM_LC_utf8((U8*)s)))
                    {
                        tmp = !tmp;
@@ -1188,7 +1187,7 @@ S_find_byclass(pTHX_ regexp * prog, const regnode *c, char *s, const char
                LOAD_UTF8_CHARCLASS_ALNUM();
                while (s + (uskip = UTF8SKIP(s)) <= strend) {
                    if (tmp == !(OP(c) == NBOUND ?
-                                swash_fetch(PL_utf8_alnum, (U8*)s, do_utf8) :
+                                (bool)swash_fetch(PL_utf8_alnum, (U8*)s, do_utf8) :
                                 isALNUM_LC_utf8((U8*)s)))
                        tmp = !tmp;
                    else if ((!reginfo || regtry(reginfo, s)))
@@ -1689,10 +1688,10 @@ Perl_regexec_flags(pTHX_ register regexp *prog, char *stringarg, register char *
            ? pv_uni_display(dsv0, (U8*)prog->precomp, prog->prelen, 60,
                          UNI_DISPLAY_REGEX)
            : prog->precomp;
-       const int len0 = UTF ? SvCUR(dsv0) : prog->prelen;
+       const int len0 = UTF ? (int)SvCUR(dsv0) : prog->prelen;
        const char * const s1 = do_utf8 ? sv_uni_display(dsv1, sv, 60,
                                               UNI_DISPLAY_REGEX) : startpos;
-       const int len1 = do_utf8 ? SvCUR(dsv1) : strend - startpos;
+       const int len1 = do_utf8 ? (int)SvCUR(dsv1) : strend - startpos;
         if (!PL_colorset)
             reginitcolors();
         PerlIO_printf(Perl_debug_log,
@@ -1910,7 +1909,7 @@ Perl_regexec_flags(pTHX_ register regexp *prog, char *stringarg, register char *
            len0 = UTF ? SvCUR(dsv0) : SvCUR(prop);
            s1 = UTF ?
              sv_uni_display(dsv1, sv, 60, UNI_DISPLAY_REGEX) : s;
-           len1 = UTF ? SvCUR(dsv1) : strend - s;
+           len1 = UTF ? (int)SvCUR(dsv1) : strend - s;
            PerlIO_printf(Perl_debug_log,
                          "Matching stclass \"%*.*s\" against \"%*.*s\"\n",
                          len0, len0, s0,
@@ -2561,18 +2560,18 @@ S_regmatch(pTHX_ const regmatch_info *reginfo, regnode *prog)
                pv_uni_display(PERL_DEBUG_PAD(0), (U8*)(locinput - pref_len),
                               pref0_len, 60, UNI_DISPLAY_REGEX) :
                locinput - pref_len;
-             const int len0 = do_utf8 ? strlen(s0) : pref0_len;
+             const int len0 = do_utf8 ? (int)strlen(s0) : pref0_len;
              const char * const s1 = do_utf8 && OP(scan) != CANY ?
                pv_uni_display(PERL_DEBUG_PAD(1),
                               (U8*)(locinput - pref_len + pref0_len),
                               pref_len - pref0_len, 60, UNI_DISPLAY_REGEX) :
                locinput - pref_len + pref0_len;
-             const int len1 = do_utf8 ? strlen(s1) : pref_len - pref0_len;
+             const int len1 = do_utf8 ? (int)strlen(s1) : pref_len - pref0_len;
              const char * const s2 = do_utf8 && OP(scan) != CANY ?
                pv_uni_display(PERL_DEBUG_PAD(2), (U8*)locinput,
                               PL_regeol - locinput, 60, UNI_DISPLAY_REGEX) :
                locinput;
-             const int len2 = do_utf8 ? strlen(s2) : l;
+             const int len2 = do_utf8 ? (int)strlen(s2) : l;
              PerlIO_printf(Perl_debug_log,
                            "%4"IVdf" <%s%.*s%s%s%.*s%s%s%s%.*s%s>%*s|%3"IVdf":%*s%s\n",
                            (IV)(locinput - PL_bostr),
@@ -2866,7 +2865,7 @@ S_regmatch(pTHX_ const regmatch_info *reginfo, regnode *prog)
                            PerlIO_printf( Perl_debug_log, "%*s  %strying alternation #%d <%s> at 0x%p%s\n",
                                REPORT_CODE_OFF+PL_regindent*2, "", PL_colors[4],
                                st->u.trie.accept_buff[best].wordnum,
-                               tmp ? SvPV_nolen_const( *tmp ) : "not compiled under -Dr",scan,
+                               tmp ? SvPV_nolen_const( *tmp ) : "not compiled under -Dr", (void*)scan,
                                PL_colors[5] );
                        });
                        if ( best<st->u.trie.accepted ) {
@@ -3041,7 +3040,7 @@ S_regmatch(pTHX_ const regmatch_info *reginfo, regnode *prog)
            if (do_utf8) {
                LOAD_UTF8_CHARCLASS_ALNUM();
                if (!(OP(scan) == ALNUM
-                     ? swash_fetch(PL_utf8_alnum, (U8*)locinput, do_utf8)
+                     ? (bool)swash_fetch(PL_utf8_alnum, (U8*)locinput, do_utf8)
                      : isALNUM_LC_utf8((U8*)locinput)))
                {
                    sayNO;
@@ -3064,7 +3063,7 @@ S_regmatch(pTHX_ const regmatch_info *reginfo, regnode *prog)
            if (do_utf8) {
                LOAD_UTF8_CHARCLASS_ALNUM();
                if (OP(scan) == NALNUM
-                   ? swash_fetch(PL_utf8_alnum, (U8*)locinput, do_utf8)
+                   ? (bool)swash_fetch(PL_utf8_alnum, (U8*)locinput, do_utf8)
                    : isALNUM_LC_utf8((U8*)locinput))
                {
                    sayNO;
@@ -3129,7 +3128,7 @@ S_regmatch(pTHX_ const regmatch_info *reginfo, regnode *prog)
                if (UTF8_IS_CONTINUED(nextchr)) {
                    LOAD_UTF8_CHARCLASS_SPACE();
                    if (!(OP(scan) == SPACE
-                         ? swash_fetch(PL_utf8_space, (U8*)locinput, do_utf8)
+                         ? (bool)swash_fetch(PL_utf8_space, (U8*)locinput, do_utf8)
                          : isSPACE_LC_utf8((U8*)locinput)))
                    {
                        sayNO;
@@ -3159,7 +3158,7 @@ S_regmatch(pTHX_ const regmatch_info *reginfo, regnode *prog)
            if (do_utf8) {
                LOAD_UTF8_CHARCLASS_SPACE();
                if (OP(scan) == NSPACE
-                   ? swash_fetch(PL_utf8_space, (U8*)locinput, do_utf8)
+                   ? (bool)swash_fetch(PL_utf8_space, (U8*)locinput, do_utf8)
                    : isSPACE_LC_utf8((U8*)locinput))
                {
                    sayNO;
@@ -3182,7 +3181,7 @@ S_regmatch(pTHX_ const regmatch_info *reginfo, regnode *prog)
            if (do_utf8) {
                LOAD_UTF8_CHARCLASS_DIGIT();
                if (!(OP(scan) == DIGIT
-                     ? swash_fetch(PL_utf8_digit, (U8*)locinput, do_utf8)
+                     ? (bool)swash_fetch(PL_utf8_digit, (U8*)locinput, do_utf8)
                      : isDIGIT_LC_utf8((U8*)locinput)))
                {
                    sayNO;
@@ -3205,7 +3204,7 @@ S_regmatch(pTHX_ const regmatch_info *reginfo, regnode *prog)
            if (do_utf8) {
                LOAD_UTF8_CHARCLASS_DIGIT();
                if (OP(scan) == NDIGIT
-                   ? swash_fetch(PL_utf8_digit, (U8*)locinput, do_utf8)
+                   ? (bool)swash_fetch(PL_utf8_digit, (U8*)locinput, do_utf8)
                    : isDIGIT_LC_utf8((U8*)locinput))
                {
                    sayNO;
@@ -3653,6 +3652,9 @@ S_regmatch(pTHX_ const regmatch_info *reginfo, regnode *prog)
                        *that* much linear. */
                if (!PL_reg_maxiter) {
                    PL_reg_maxiter = (PL_regeol - PL_bostr + 1) * (scan->flags>>4);
+                   /* possible overflow for long strings and many CURLYX's */
+                   if (PL_reg_maxiter < 0)
+                       PL_reg_maxiter = I32_MAX;
                    PL_reg_leftiter = PL_reg_maxiter;
                }
                if (PL_reg_leftiter-- == 0) {
@@ -5102,7 +5104,7 @@ S_reginclass(pTHX_ const regexp *prog, register const regnode *n, register const
 }
 
 STATIC U8 *
-S_reghop3(U8 *s, I32 off, U8* lim)
+S_reghop3(U8 *s, I32 off, const U8* lim)
 {
     dVAR;
     if (off >= 0) {
@@ -5127,7 +5129,7 @@ S_reghop3(U8 *s, I32 off, U8* lim)
 }
 
 STATIC U8 *
-S_reghopmaybe3(U8* s, I32 off, U8* lim)
+S_reghopmaybe3(U8* s, I32 off, const U8* lim)
 {
     dVAR;
     if (off >= 0) {