summaryrefslogtreecommitdiff
path: root/Src/exec.c
diff options
context:
space:
mode:
authorPeter Stephenson <pws@zsh.org>2017-09-29 16:46:01 +0100
committerPeter Stephenson <pws@zsh.org>2017-10-02 09:44:26 +0100
commit174e560a23e40725cd0b50669a52d831342e5246 (patch)
tree6ded2f3a9cf9dc2fbece05d867f4531c8e55f575 /Src/exec.c
parent728f2adfc8daf2c65c5d4130a903635a58c99fb5 (diff)
downloadzsh-174e560a23e40725cd0b50669a52d831342e5246.tar.gz
zsh-174e560a23e40725cd0b50669a52d831342e5246.zip
41787 (plus minor tweaks): use $FUNCSTACK for function nesting depth.
Initialised from existing configuration value.
Diffstat (limited to 'Src/exec.c')
-rw-r--r--Src/exec.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/Src/exec.c b/Src/exec.c
index 780998b1a..dfb50c3b3 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -5508,9 +5508,7 @@ doshfunc(Shfunc shfunc, LinkList doshargs, int noreturnval)
struct funcstack fstack;
static int oflags;
Emulation_options save_sticky = NULL;
-#ifdef MAX_FUNCTION_DEPTH
static int funcdepth;
-#endif
Heap funcheap;
queue_signals(); /* Lots of memory and global state changes coming */
@@ -5640,13 +5638,12 @@ doshfunc(Shfunc shfunc, LinkList doshargs, int noreturnval)
argzero = ztrdup(argzero);
}
}
-#ifdef MAX_FUNCTION_DEPTH
- if(++funcdepth > MAX_FUNCTION_DEPTH)
- {
- zerr("maximum nested function level reached");
- goto undoshfunc;
- }
-#endif
+ ++funcdepth;
+ if (zsh_funcnest >= 0 && funcdepth > zsh_funcnest) {
+ zerr("maximum nested function level reached; increase FUNCNEST?");
+ lastval = 1;
+ goto undoshfunc;
+ }
fstack.name = dupstring(name);
/*
* The caller is whatever is immediately before on the stack,
@@ -5685,10 +5682,8 @@ doshfunc(Shfunc shfunc, LinkList doshargs, int noreturnval)
runshfunc(prog, wrappers, fstack.name);
doneshfunc:
funcstack = fstack.prev;
-#ifdef MAX_FUNCTION_DEPTH
undoshfunc:
--funcdepth;
-#endif
if (retflag) {
retflag = 0;
breaks = obreaks;