More printf-fixes (see also #4426).
[p5sagit/p5-mst-13.2.git] / regexec.c
index 6981424..7b5a488 100644 (file)
--- a/regexec.c
+++ b/regexec.c
@@ -176,10 +176,10 @@ S_regcppop(pTHX)
            PL_regendp[paren] = tmps;
        DEBUG_r(
            PerlIO_printf(Perl_debug_log,
-                         "     restoring \\%d to %d(%d)..%d%s\n",
-                         paren, PL_regstartp[paren], 
-                         PL_reg_start_tmp[paren] - PL_bostr,
-                         PL_regendp[paren], 
+                         "     restoring \\%"UVuf" to %"IVdf"(%"IVdf")..%"IVdf"%s\n",
+                         (UV)paren, (IV)PL_regstartp[paren], 
+                         (IV)(PL_reg_start_tmp[paren] - PL_bostr),
+                         (IV)PL_regendp[paren], 
                          (paren > *PL_reglastparen ? "(no)" : ""));
        );
     }
@@ -314,7 +314,7 @@ Perl_re_intuit_start(pTHX_ regexp *prog, SV *sv, char *strpos,
                      PL_colors[1],
                      (strlen(prog->precomp) > 60 ? "..." : ""),
                      PL_colors[0],
-                     (strend - strpos > 60 ? 60 : strend - strpos),
+                     (int)(strend - strpos > 60 ? 60 : strend - strpos),
                      strpos, PL_colors[1],
                      (strend - strpos > 60 ? "..." : ""))
        );
@@ -424,7 +424,8 @@ Perl_re_intuit_start(pTHX_ regexp *prog, SV *sv, char *strpos,
                          (s ? "Found" : "Did not find"),
                          ((check == prog->anchored_substr) ? "anchored" : "floating"),
                          PL_colors[0],
-                         SvCUR(check) - (SvTAIL(check)!=0), SvPVX(check),
+                         (int)(SvCUR(check) - (SvTAIL(check)!=0)),
+                         SvPVX(check),
                          PL_colors[1], (SvTAIL(check) ? "$" : ""),
                          (s ? " at offset " : "...\n") ) );
 
@@ -480,8 +481,8 @@ Perl_re_intuit_start(pTHX_ regexp *prog, SV *sv, char *strpos,
                DEBUG_r(PerlIO_printf(Perl_debug_log, "%s anchored substr `%s%.*s%s'%s",
                        (s ? "Found" : "Contradicts"),
                        PL_colors[0],
-                         SvCUR(prog->anchored_substr)
-                         - (SvTAIL(prog->anchored_substr)!=0),
+                         (int)(SvCUR(prog->anchored_substr)
+                         - (SvTAIL(prog->anchored_substr)!=0)),
                          SvPVX(prog->anchored_substr),
                          PL_colors[1], (SvTAIL(prog->anchored_substr) ? "$" : "")));
                if (!s) {
@@ -532,8 +533,8 @@ Perl_re_intuit_start(pTHX_ regexp *prog, SV *sv, char *strpos,
                DEBUG_r(PerlIO_printf(Perl_debug_log, "%s floating substr `%s%.*s%s'%s",
                        (s ? "Found" : "Contradicts"),
                        PL_colors[0],
-                         SvCUR(prog->float_substr)
-                         - (SvTAIL(prog->float_substr)!=0),
+                         (int)(SvCUR(prog->float_substr)
+                         - (SvTAIL(prog->float_substr)!=0)),
                          SvPVX(prog->float_substr),
                          PL_colors[1], (SvTAIL(prog->float_substr) ? "$" : "")));
                if (!s) {
@@ -742,7 +743,7 @@ Perl_regexec_flags(pTHX_ register regexp *prog, char *stringarg, register char *
     if (prog->reganch & ROPT_GPOS_SEEN) { /* Need to have PL_reg_ganch */
        MAGIC *mg;
 
-       if (flags & REXEC_IGNOREPOS)
+       if (flags & REXEC_IGNOREPOS)    /* Means: check only at start */
            PL_reg_ganch = startpos;
        else if (sv && SvTYPE(sv) >= SVt_PVMG
                  && SvMAGIC(sv)
@@ -754,7 +755,7 @@ Perl_regexec_flags(pTHX_ register regexp *prog, char *stringarg, register char *
                s = PL_reg_ganch;
            }
        }
-       else
+       else                            /* pos() not defined */
            PL_reg_ganch = strbeg;
     }
 
@@ -776,7 +777,7 @@ Perl_regexec_flags(pTHX_ register regexp *prog, char *stringarg, register char *
                      PL_colors[1],
                      (strlen(prog->precomp) > 60 ? "..." : ""),
                      PL_colors[0],
-                     (strend - startpos > 60 ? 60 : strend - startpos),
+                     (int)(strend - startpos > 60 ? 60 : strend - startpos),
                      startpos, PL_colors[1],
                      (strend - startpos > 60 ? "..." : ""))
        );
@@ -1481,8 +1482,8 @@ S_regtry(pTHX_ regexp *prog, char *startpos)
 
        PL_reg_eval_set = RS_init;
        DEBUG_r(DEBUG_s(
-           PerlIO_printf(Perl_debug_log, "  setting stack tmpbase at %i\n",
-                         PL_stack_sp - PL_stack_base);
+           PerlIO_printf(Perl_debug_log, "  setting stack tmpbase at %"IVdf"\n",
+                         (IV)(PL_stack_sp - PL_stack_base));
            ));
        SAVEINT(cxstack[cxstack_ix].blk_oldsp);
        cxstack[cxstack_ix].blk_oldsp = PL_stack_sp - PL_stack_base;
@@ -1509,7 +1510,7 @@ S_regtry(pTHX_ regexp *prog, char *startpos)
            }
            PL_reg_magic    = mg;
            PL_reg_oldpos   = mg->mg_len;
-           SAVEDESTRUCTOR(restore_pos, 0);
+           SAVEDESTRUCTOR_X(restore_pos, 0);
         }
        if (!PL_reg_curpm)
            New(22,PL_reg_curpm, 1, PMOP);
@@ -1645,8 +1646,8 @@ S_regmatch(pTHX_ regnode *prog)
                pref0_len = pref_len;
            regprop(prop, scan);
            PerlIO_printf(Perl_debug_log, 
-                         "%4i <%s%.*s%s%s%.*s%s%s%s%.*s%s>%*s|%3d:%*s%s\n",
-                         locinput - PL_bostr, 
+                         "%4"IVdf" <%s%.*s%s%s%.*s%s%s%s%.*s%s>%*s|%3"IVdf":%*s%s\n",
+                         (IV)(locinput - PL_bostr), 
                          PL_colors[4], pref0_len, 
                          locinput - pref_len, PL_colors[5],
                          PL_colors[2], pref_len - pref0_len, 
@@ -1655,7 +1656,7 @@ S_regmatch(pTHX_ regnode *prog)
                          PL_colors[0], l, locinput, PL_colors[1],
                          15 - l - pref_len + 1,
                          "",
-                         scan - PL_regprogram, PL_regindent*2, "",
+                         (IV)(scan - PL_regprogram), PL_regindent*2, "",
                          SvPVX(prop));
        } );
 
@@ -2141,7 +2142,7 @@ S_regmatch(pTHX_ regnode *prog)
            
            n = ARG(scan);
            PL_op = (OP_4tree*)PL_regdata->data[n];
-           DEBUG_r( PerlIO_printf(Perl_debug_log, "  re_eval 0x%x\n", PL_op) );
+           DEBUG_r( PerlIO_printf(Perl_debug_log, "  re_eval 0x%"UVxf"\n", (UV)PL_op) );
            PL_curpad = AvARRAY((AV*)PL_regdata->data[n + 2]);
            PL_regendp[0] = PL_reg_magic->mg_len = locinput - PL_bostr;
 
@@ -2704,8 +2705,9 @@ S_regmatch(pTHX_ regnode *prog)
                locinput = PL_reginput;
                DEBUG_r(
                    PerlIO_printf(Perl_debug_log,
-                                 "%*s  matched %ld times, len=%ld...\n",
-                                 REPORT_CODE_OFF+PL_regindent*2, "", n, l)
+                                 "%*s  matched %d times, len=%"IVdf"...\n",
+                                 (int)(REPORT_CODE_OFF+PL_regindent*2), "",
+                                 n, (IV)l)
                    );
                if (n >= ln) {
                    if (PL_regkind[(U8)OP(next)] == EXACT) {
@@ -2729,8 +2731,8 @@ S_regmatch(pTHX_ regnode *prog)
                    {
                        DEBUG_r(
                                PerlIO_printf(Perl_debug_log,
-                                             "%*s  trying tail with n=%ld...\n",
-                                             REPORT_CODE_OFF+PL_regindent*2, "", n)
+                                             "%*s  trying tail with n=%"IVdf"...\n",
+                                             (int)(REPORT_CODE_OFF+PL_regindent*2), "", (IV)n)
                            );
                        if (paren) {
                            if (n) {
@@ -3051,8 +3053,8 @@ S_regmatch(pTHX_ regnode *prog)
                next = NULL;
            break;
        default:
-           PerlIO_printf(PerlIO_stderr(), "%lx %d\n",
-                         (unsigned long)scan, OP(scan));
+           PerlIO_printf(Perl_error_log, "%"UVxf" %d\n",
+                         (UV)scan, OP(scan));
            Perl_croak(aTHX_ "regexp memory corruption");
        }
        scan = next;
@@ -3306,8 +3308,8 @@ S_regrepeat(pTHX_ regnode *p, I32 max)
 
                regprop(prop, p);
                PerlIO_printf(Perl_debug_log, 
-                             "%*s  %s can match %ld times out of %ld...\n", 
-                             REPORT_CODE_OFF+1, "", SvPVX(prop),c,max);
+                             "%*s  %s can match %"IVdf" times out of %"IVdf"...\n", 
+                             REPORT_CODE_OFF+1, "", SvPVX(prop),(IV)c,(IV)max);
        });
     
     return(c);