Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: max-function-depth configure option
- X-seq: zsh-workers 10565
- From: Clint Adams <schizo@xxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxx
- Subject: PATCH: max-function-depth configure option
- Date: Thu, 6 Apr 2000 22:18:38 -0400
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
This allows someone to hardcode the number of nested functions
the shell will allow. The resulting behavior is hardly ideal,
but I can't figure out what would be ideal. Exiting completely?
Index: acconfig.h
===================================================================
RCS file: /cvsroot/zsh/zsh/acconfig.h,v
retrieving revision 1.1.1.14
diff -u -r1.1.1.14 acconfig.h
--- acconfig.h 2000/02/28 04:36:33 1.1.1.14
+++ acconfig.h 2000/04/07 02:02:18
@@ -169,6 +169,9 @@
/* Define for Maildir support */
#undef MAILDIR_SUPPORT
+/* Define for function depth limits */
+#undef MAX_FUNCTION_DEPTH
+
/* Define if you want locale features. By default this is defined. */
#undef CONFIG_LOCALE
Index: configure.in
===================================================================
RCS file: /cvsroot/zsh/zsh/configure.in,v
retrieving revision 1.2
diff -u -r1.2 configure.in
--- configure.in 2000/04/06 16:44:03 1.2
+++ configure.in 2000/04/07 02:02:18
@@ -271,6 +271,16 @@
AC_DEFINE(MAILDIR_SUPPORT)
fi])
+dnl Do you want to set a maximum function depth?
+undefine([max_function_depth])dnl
+AC_ARG_ENABLE(max-function-depth,
+[ --enable-max-function-depth=MAX Limit function depth to MAX],
+[if test x$enableval = xyes; then
+ AC_DEFINE(MAX_FUNCTION_DEPTH, 4096)
+else
+ AC_DEFINE_UNQUOTED(MAX_FUNCTION_DEPTH, $enableval)
+fi])
+
dnl ------------------
dnl CHECK THE COMPILER
dnl ------------------
Index: Src/exec.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/exec.c,v
retrieving revision 1.2
diff -u -r1.2 exec.c
--- Src/exec.c 2000/04/01 20:49:48 1.2
+++ Src/exec.c 2000/04/07 02:02:19
@@ -3251,6 +3251,9 @@
char saveopts[OPT_SIZE], *oldscriptname = NULL, *fname = dupstring(name);
int obreaks;
struct funcstack fstack;
+#ifdef MAX_FUNCTION_DEPTH
+ static int funcdepth;
+#endif
pushheap();
@@ -3300,6 +3303,13 @@
argzero = ztrdup(argzero);
}
}
+#ifdef MAX_FUNCTION_DEPTH
+ if(++funcdepth > MAX_FUNCTION_DEPTH)
+ {
+ zerr("maximum nested function level reached", NULL, 0);
+ return;
+ }
+#endif
fstack.name = dupstring(name);
fstack.prev = funcstack;
funcstack = &fstack;
@@ -3323,6 +3333,9 @@
}
runshfunc(prog, wrappers, fstack.name);
funcstack = fstack.prev;
+#ifdef MAX_FUNCTION_DEPTH
+ --funcdepth;
+#endif
if (retflag) {
retflag = 0;
breaks = obreaks;
Messages sorted by:
Reverse Date,
Date,
Thread,
Author