Mercurial > octave-dspies
diff src/ov-usr-fcn.cc @ 3131:9c5160c83bd2
[project @ 1998-01-29 04:46:33 by jwe]
author | jwe |
---|---|
date | Thu, 29 Jan 1998 04:46:36 +0000 |
parents | 38de16594cb4 |
children | a494f93e60ff |
line wrap: on
line diff
--- a/src/ov-usr-fcn.cc Sun Jan 25 08:27:25 1998 +0000 +++ b/src/ov-usr-fcn.cc Thu Jan 29 04:46:36 1998 +0000 @@ -53,6 +53,9 @@ // if they are not explicitly initialized. static bool Vdefine_all_return_values; +// Maximum nesting level for functions called recursively. +static int Vmax_recursion_depth; + // If TRUE, the last computed value is returned from functions that // don't actually define any return variables. static bool Vreturn_last_computed_value; @@ -246,6 +249,12 @@ unwind_protect_int (call_depth); call_depth++; + if (call_depth > Vmax_recursion_depth) + { + ::error ("max_recursion_limit exceeded"); + return retval; + } + if (symtab_entry && ! symtab_entry->is_read_only ()) { symtab_entry->protect (); @@ -525,6 +534,14 @@ } static int +max_recursion_depth (void) +{ + Vmax_recursion_depth = check_preference ("max_recursion_depth"); + + return 0; +} + +static int return_last_computed_value (void) { Vreturn_last_computed_value @@ -546,6 +563,10 @@ value even if one has not been explicitly assigned. See also\n\ default_return_value"); + DEFVAR (max_recursion_depth, 256.0, 0, max_recursion_depth, + "maximum nesting level for functions called recursively.\n\ +The default value is 256."); + DEFVAR (return_last_computed_value, 0.0, 0, return_last_computed_value, "if a function does not return any values explicitly, return the\n\ last computed value");