diff options
author | Chet Ramey <chet.ramey@case.edu> | 2011-11-22 19:11:26 -0500 |
---|---|---|
committer | Chet Ramey <chet.ramey@case.edu> | 2011-11-22 19:11:26 -0500 |
commit | 495aee441b75276e38c75694ccb455bb6463fdb9 (patch) | |
tree | f12907dbf62388e6c65dfa1c5e1199509936707e /unwind_prot.c | |
parent | 30d188c2932d6ef609d894fefeb7e7b03ccff463 (diff) | |
download | bash-495aee441b75276e38c75694ccb455bb6463fdb9.tar.gz |
Bash-4.2 distribution sources and documentationbash-4.2
Diffstat (limited to 'unwind_prot.c')
-rw-r--r-- | unwind_prot.c | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/unwind_prot.c b/unwind_prot.c index 9e150a66..a477c03a 100644 --- a/unwind_prot.c +++ b/unwind_prot.c @@ -48,6 +48,7 @@ #include "unwind_prot.h" #include "quit.h" #include "sig.h" +#include "error.h" /* for internal_warning */ /* Structure describing a saved variable and the value to restore it to. */ typedef struct { @@ -240,18 +241,24 @@ unwind_frame_discard_internal (tag, ignore) char *tag, *ignore; { UNWIND_ELT *elt; + int found; + found = 0; while (elt = unwind_protect_list) { unwind_protect_list = unwind_protect_list->head.next; if (elt->head.cleanup == 0 && (STREQ (elt->arg.v, tag))) { uwpfree (elt); + found = 1; break; } else uwpfree (elt); } + + if (found == 0) + internal_warning ("unwind_frame_discard: %s: frame not found", tag); } /* Restore the value of a variable, based on the contents of SV. @@ -269,17 +276,20 @@ unwind_frame_run_internal (tag, ignore) char *tag, *ignore; { UNWIND_ELT *elt; + int found; + found = 0; while (elt = unwind_protect_list) { unwind_protect_list = elt->head.next; /* If tag, then compare. */ - if (!elt->head.cleanup) + if (elt->head.cleanup == 0) { if (tag && STREQ (elt->arg.v, tag)) { uwpfree (elt); + found = 1; break; } } @@ -293,6 +303,8 @@ unwind_frame_run_internal (tag, ignore) uwpfree (elt); } + if (tag && found == 0) + internal_warning ("unwind_frame_run: %s: frame not found", tag); } static void @@ -324,3 +336,22 @@ unwind_protect_mem (var, size) { without_interrupts (unwind_protect_mem_internal, var, (char *) &size); } + +#if defined (DEBUG) +#include <stdio.h> + +void +print_unwind_protect_tags () +{ + UNWIND_ELT *elt; + + elt = unwind_protect_list; + while (elt) + { + unwind_protect_list = unwind_protect_list->head.next; + if (elt->head.cleanup == 0) + fprintf(stderr, "tag: %s\n", elt->arg.v); + elt = unwind_protect_list; + } +} +#endif |