]> git.vpit.fr Git - perl/modules/Scope-Upper.git/commitdiff
A somewhat more robust handling of debugging frames
authorVincent Pit <vince@profvince.com>
Mon, 18 Jan 2010 22:50:25 +0000 (23:50 +0100)
committerVincent Pit <vince@profvince.com>
Mon, 18 Jan 2010 22:50:25 +0000 (23:50 +0100)
Upper.xs

index 61f8560e5bf4b957971e31d2d65260f41984ef66..42f457e4302a5f46294c457612e79477aafb1634 100644 (file)
--- a/Upper.xs
+++ b/Upper.xs
@@ -706,18 +706,21 @@ STATIC void su_unwind(pTHX_ void *ud_) {
 
 #define SU_SKIP_DB(C) \
  STMT_START {         \
-  I32 i = 1;          \
-  PERL_CONTEXT *cx = cxstack + (C); \
-  do {                              \
-   if (CxTYPE(cx) == CXt_BLOCK && (C) >= i) { \
-    --cx;                                     \
-    if (CxTYPE(cx) == CXt_SUB && cx->blk_sub.cv == GvCV(PL_DBsub)) { \
-     (C) -= i + 1;                 \
-     break;                        \
-    }                              \
-   } else                          \
-    break;                         \
-  } while (++i <= SU_SKIP_DB_MAX); \
+  I32 skipped = 0;    \
+  PERL_CONTEXT *base = cxstack;      \
+  PERL_CONTEXT *cx   = base + (C);   \
+  while (cx >= base && (C) > skipped && CxTYPE(cx) == CXt_BLOCK) \
+   --cx, ++skipped;                  \
+  if (cx >= base && (C) > skipped) { \
+   switch (CxTYPE(cx)) {  \
+    case CXt_SUB:         \
+     if (skipped <= SU_SKIP_DB_MAX && cx->blk_sub.cv == GvCV(PL_DBsub)) \
+      (C) -= skipped + 1; \
+      break;              \
+    default:              \
+     break;               \
+   }                      \
+  }                       \
  } STMT_END
 
 #define SU_GET_CONTEXT(A, B)   \