Overview
| Artifact ID: | c5ac18373442112747bb3a2438ffbb7c412ccd98 |
|---|---|
| Ticket: | 219184ffffffffffffffffffffffffffffffffff |
| Date: | 2001-08-21 23:36:10 |
| User: | msofer |
| Artifact Attached: | 1f77503e750d1279de35da02ac03863b5b5894e0 |
| Filename: | patch219184.txt |
| Description: | new patch |
Content:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39Index: generic/tclCompCmds.c =================================================================== RCS file: /cvsroot/tcl/tcl/generic/tclCompCmds.c,v retrieving revision 1.9 diff -u -r1.9 tclCompCmds.c --- generic/tclCompCmds.c 2001/06/28 00:42:39 1.9 +++ generic/tclCompCmds.c 2001/08/21 16:27:35 @@ -317,10 +317,28 @@ range = TclCreateExceptRange(CATCH_EXCEPTION_RANGE, envPtr); TclEmitInstInt4(INST_BEGIN_CATCH4, range, envPtr); - startOffset = (envPtr->codeNext - envPtr->codeStart); + /* + * If the body is a simple word, compile the instructions to + * eval it. Otherwise, compile instructions to substitute its + * text without catching, a catch instruction that resets the + * stack to what it was before substituting the body, and then + * an instruction to eval the body. Care has to be taken to + * register the correct startOffset for the catch range so that + * errors in the substitution are not catched [Bug 219184] + */ + + if (cmdTokenPtr->type == TCL_TOKEN_SIMPLE_WORD) { + startOffset = (envPtr->codeNext - envPtr->codeStart); + code = TclCompileCmdWord(interp, cmdTokenPtr+1, + cmdTokenPtr->numComponents, envPtr); + } else { + code = TclCompileTokens(interp, cmdTokenPtr+1, + cmdTokenPtr->numComponents, envPtr); + startOffset = (envPtr->codeNext - envPtr->codeStart); + TclEmitOpcode(INST_EVAL_STK, envPtr); + } envPtr->exceptArrayPtr[range].codeOffset = startOffset; - code = TclCompileCmdWord(interp, cmdTokenPtr+1, - cmdTokenPtr->numComponents, envPtr); + if (code != TCL_OK) { if (code == TCL_ERROR) { sprintf(buffer, "\n (\"catch\" body line %d)",