summaryrefslogtreecommitdiffstats
path: root/generic/tclBasic.c
diff options
context:
space:
mode:
authorMiguel Sofer <miguel.sofer@gmail.com>2007-11-10 20:05:34 (GMT)
committerMiguel Sofer <miguel.sofer@gmail.com>2007-11-10 20:05:34 (GMT)
commite623ff4e6ad3a35bd8b2acbb416e56981286400a (patch)
tree9479d7c649628cc5f3bef02e2f89f17d371af926 /generic/tclBasic.c
parent1bb7bf057245c23fb001032ceb3df30a99b093ee (diff)
downloadtcl-e623ff4e6ad3a35bd8b2acbb416e56981286400a.zip
tcl-e623ff4e6ad3a35bd8b2acbb416e56981286400a.tar.gz
tcl-e623ff4e6ad3a35bd8b2acbb416e56981286400a.tar.bz2
Improved failure comments for stack checks (mistachkin).
Diffstat (limited to 'generic/tclBasic.c')
-rw-r--r--generic/tclBasic.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/generic/tclBasic.c b/generic/tclBasic.c
index 53cd4fd..893de64 100644
--- a/generic/tclBasic.c
+++ b/generic/tclBasic.c
@@ -14,7 +14,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclBasic.c,v 1.274 2007/11/10 19:01:34 msofer Exp $
+ * RCS: @(#) $Id: tclBasic.c,v 1.275 2007/11/10 20:05:34 msofer Exp $
*/
#include "tclInt.h"
@@ -340,13 +340,13 @@ static int stackGrowsDown = 1;
#define GetCStackParams(iPtr) \
stackGrowsDown = TclpGetCStackParams(&((iPtr)->stackBound))
-#define StackOverflow(iPtr, localIntPtr) \
+#define CheckCStack(iPtr, localIntPtr) \
(stackGrowsDown \
- ? ((localIntPtr) < (iPtr)->stackBound) \
- : ((localIntPtr) > (iPtr)->stackBound) \
+ ? ((localIntPtr) > (iPtr)->stackBound) \
+ : ((localIntPtr) < (iPtr)->stackBound) \
)
#else /* stack check disabled: make them noops */
-#define StackOverflow(interp, localIntPtr) 0
+#define CheckCStack(interp, localIntPtr) 1
#define GetCStackParams(iPtr)
#endif
@@ -3435,14 +3435,19 @@ TclInterpReady(
* probably because of an infinite loop somewhere.
*/
- if (((iPtr->numLevels) > iPtr->maxNestingDepth)
- || StackOverflow(iPtr, &localInt)) {
+ if (((iPtr->numLevels) <= iPtr->maxNestingDepth)
+ && CheckCStack(iPtr, &localInt)) {
+ return TCL_OK;
+ }
+
+ if (!CheckCStack(iPtr, &localInt)) {
+ Tcl_AppendResult(interp,
+ "out of stack space (infinite loop?)", NULL);
+ } else {
Tcl_AppendResult(interp,
"too many nested evaluations (infinite loop?)", NULL);
- return TCL_ERROR;
}
-
- return TCL_OK;
+ return TCL_ERROR;
}
/*