don't longjmp() in pp_goto() (regressive bug from old single-stack
[p5sagit/p5-mst-13.2.git] / util.c
diff --git a/util.c b/util.c
index 3788de2..0a70c6b 100644 (file)
--- a/util.c
+++ b/util.c
@@ -897,13 +897,14 @@ mem_collxfrm(const char *s, STRLEN len, STRLEN *xlen)
 void
 fbm_compile(SV *sv, U32 flags /* not used yet */)
 {
-    register unsigned char *s;
-    register unsigned char *table;
+    register U8 *s;
+    register U8 *table;
     register U32 i;
-    register U32 len = SvCUR(sv);
+    STRLEN len;
     I32 rarest = 0;
     U32 frequency = 256;
 
+    s = (U8*)SvPV_force(sv, len);
     sv_upgrade(sv, SVt_PVBM);
     if (len > 255 || len == 0) /* TAIL might be on on a zero-length string. */
        return;                 /* can't have offsets that big */
@@ -1410,6 +1411,7 @@ warn(const char* pat,...)
 void
 warner(U32  err, const char* pat,...)
 {
+    dTHR;
     va_list args;
     char *message;
     HV *stash;
@@ -1422,7 +1424,7 @@ warner(U32  err, const char* pat,...)
 
     if (ckDEAD(err)) {
 #ifdef USE_THREADS
-        DEBUG_L(PerlIO_printf(PerlIO_stderr(), "croak: 0x%lx %s", (unsigned long) thr, message));
+        DEBUG_S(PerlIO_printf(PerlIO_stderr(), "croak: 0x%lx %s", (unsigned long) thr, message));
 #endif /* USE_THREADS */
         if (PL_diehook) {
             /* sv_2cv might call croak() */
@@ -2428,8 +2430,11 @@ scan_oct(char *start, I32 len, I32 *retlen)
        retval = n | (*s++ - '0');
        len--;
     }
-    if (len && (*s == '8' || *s == '9') && ckWARN(WARN_OCTAL))
-       warner(WARN_OCTAL, "Illegal octal digit ignored");
+    if (len && (*s == '8' || *s == '9')) {
+       dTHR;
+       if (ckWARN(WARN_OCTAL))
+           warner(WARN_OCTAL, "Illegal octal digit ignored");
+    }
     *retlen = s - start;
     return retval;
 }
@@ -2449,6 +2454,7 @@ scan_hex(char *start, I32 len, I32 *retlen)
            if (*s == '_')
                continue;
            else {
+               dTHR;
                --s;
                if (ckWARN(WARN_UNSAFE))
                    warner(WARN_UNSAFE,"Illegal hex digit ignored");
@@ -2564,7 +2570,8 @@ find_script(char *scriptname, bool dosearch, char **search_ext, I32 flags)
 #endif
            DEBUG_p(PerlIO_printf(Perl_debug_log,
                                  "Looking for %s\n",cur));
-           if (PerlLIO_stat(cur,&PL_statbuf) >= 0) {
+           if (PerlLIO_stat(cur,&PL_statbuf) >= 0
+               && !S_ISDIR(PL_statbuf.st_mode)) {
                dosearch = 0;
                scriptname = cur;
 #ifdef SEARCH_EXTS
@@ -2633,6 +2640,9 @@ find_script(char *scriptname, bool dosearch, char **search_ext, I32 flags)
 #endif
                DEBUG_p(PerlIO_printf(Perl_debug_log, "Looking for %s\n",tmpbuf));
                retval = PerlLIO_stat(tmpbuf,&PL_statbuf);
+               if (S_ISDIR(PL_statbuf.st_mode)) {
+                   retval = -1;
+               }
 #ifdef SEARCH_EXTS
            } while (  retval < 0               /* not there */
                    && extidx>=0 && ext[extidx] /* try an extension? */
@@ -2655,7 +2665,9 @@ find_script(char *scriptname, bool dosearch, char **search_ext, I32 flags)
                xfailed = savepv(tmpbuf);
        }
 #ifndef DOSISH
-       if (!xfound && !seen_dot && !xfailed && (PerlLIO_stat(scriptname,&PL_statbuf) < 0))
+       if (!xfound && !seen_dot && !xfailed &&
+           (PerlLIO_stat(scriptname,&PL_statbuf) < 0 
+            || S_ISDIR(PL_statbuf.st_mode)))
 #endif
            seen_dot = 1;                       /* Disable message. */
        if (!xfound) {
@@ -2824,7 +2836,7 @@ new_struct_thread(struct perl_thread *t)
     SvGROW(sv, sizeof(struct perl_thread) + 1);
     SvCUR_set(sv, sizeof(struct perl_thread));
     thr = (Thread) SvPVX(sv);
-    /* debug */
+#ifdef DEBUGGING
     memset(thr, 0xab, sizeof(struct perl_thread));
     PL_markstack = 0;
     PL_scopestack = 0;
@@ -2832,7 +2844,10 @@ new_struct_thread(struct perl_thread *t)
     PL_retstack = 0;
     PL_dirty = 0;
     PL_localizing = 0;
-    /* end debug */
+    Zero(&PL_hv_fetch_ent_mh, 1, HE);
+#else
+    Zero(thr, 1, struct perl_thread);
+#endif
 
     thr->oursv = sv;
     init_stacks(ARGS);