about summary refs log tree commit diff
path: root/Src/exec.c
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2008-08-01 13:53:43 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2008-08-01 13:53:43 +0000
commit506d73299cd5559b4d303260f2f05901886c937a (patch)
tree3333c417cb5813457fd8c7d5d4eeadfda4f42240 /Src/exec.c
parent5e7e797ca90cd1c1b7ab54d39118f0b7469f348f (diff)
downloadzsh-506d73299cd5559b4d303260f2f05901886c937a.tar.gz
zsh-506d73299cd5559b4d303260f2f05901886c937a.tar.xz
zsh-506d73299cd5559b4d303260f2f05901886c937a.zip
fix problems with trapreturn, in particular in source inside trap
Diffstat (limited to 'Src/exec.c')
-rw-r--r--Src/exec.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/Src/exec.c b/Src/exec.c
index 8edbf1dc9..daa7ba55c 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -64,7 +64,23 @@ int nohistsave;
 /**/
 mod_export int errflag;
  
-/* Status of return from a trap */
+/*
+ * Status of return from a trap.
+ * This is only active if we are inside a trap, else its value
+ * is irrelevant.  It is initialised to -1 for a function trap and
+ * -2 for a non-function trap and if negative is decremented as
+ * we go deeper into functions and incremented as we come back up.
+ * The value is used to decide if an explicit "return" should cause
+ * a return from the caller of the trap; it does this by setting
+ * trapreturn to a status (i.e. a non-negative value).
+ *
+ * In summary, trapreturn is
+ * - zero unless we are in a trap
+ * - negative in a trap unless it has triggered.  Code uses this
+ *   to detect an active trap.
+ * - non-negative in a trap once it was triggered.  It should remain
+ *   non-negative until restored after execution of the trap.
+ */
  
 /**/
 int trapreturn;