Attachment "errorscript.patch" to
ticket [1587317fff]
added by
ecky-l
2006-11-01 00:59:22.
0000: 64 69 66 66 20 2d 75 62 72 4e 20 74 63 6c 38 2e diff -ubrN tcl8.
0010: 35 61 35 2f 67 65 6e 65 72 69 63 2f 74 63 6c 42 5a5/generic/tclB
0020: 61 73 69 63 2e 63 20 74 63 6c 2f 67 65 6e 65 72 asic.c tcl/gener
0030: 69 63 2f 74 63 6c 42 61 73 69 63 2e 63 0a 2d 2d ic/tclBasic.c.--
0040: 2d 20 74 63 6c 38 2e 35 61 35 2f 67 65 6e 65 72 - tcl8.5a5/gener
0050: 69 63 2f 74 63 6c 42 61 73 69 63 2e 63 09 4d 6f ic/tclBasic.c.Mo
0060: 6e 20 4f 63 74 20 31 36 20 31 36 3a 35 32 3a 30 n Oct 16 16:52:0
0070: 32 20 32 30 30 36 0a 2b 2b 2b 20 74 63 6c 2f 67 2 2006.+++ tcl/g
0080: 65 6e 65 72 69 63 2f 74 63 6c 42 61 73 69 63 2e eneric/tclBasic.
0090: 63 09 54 75 65 20 4f 63 74 20 33 31 20 31 37 3a c.Tue Oct 31 17:
00a0: 34 35 3a 33 38 20 32 30 30 36 0a 40 40 20 2d 33 45:38 2006.@@ -3
00b0: 37 34 2c 36 20 2b 33 37 34 2c 31 33 20 40 40 0a 74,6 +374,13 @@.
00c0: 20 20 20 20 20 69 50 74 72 2d 3e 63 68 61 6e 4d iPtr->chanM
00d0: 73 67 20 3d 20 4e 55 4c 4c 3b 0a 20 0a 20 20 20 sg = NULL;. .
00e0: 20 20 2f 2a 0a 2b 09 20 2a 20 69 6e 69 74 69 61 /*.+. * initia
00f0: 6c 69 7a 65 20 74 68 65 20 65 72 72 6f 72 48 61 lize the errorHa
0100: 6e 64 6c 65 72 20 61 6e 64 20 65 72 72 6f 72 48 ndler and errorH
0110: 61 6e 64 6c 65 72 46 6c 61 67 73 20 6d 65 6d 62 andlerFlags memb
0120: 65 72 73 0a 2b 09 20 2a 2f 0a 2b 09 69 50 74 72 ers.+. */.+.iPtr
0130: 2d 3e 65 72 72 6f 72 48 61 6e 64 6c 65 72 20 3d ->errorHandler =
0140: 20 4e 55 4c 4c 3b 0a 2b 09 69 50 74 72 2d 3e 65 NULL;.+.iPtr->e
0150: 72 72 6f 72 48 61 6e 64 6c 65 72 46 6c 61 67 73 rrorHandlerFlags
0160: 20 3d 20 30 3b 0a 2b 20 20 20 20 69 50 74 72 2d = 0;.+ iPtr-
0170: 3e 63 61 74 63 68 4c 65 76 65 6c 20 3d 20 30 3b >catchLevel = 0;
0180: 0a 2b 09 0a 2b 20 20 20 20 2f 2a 0a 20 20 20 20 .+..+ /*.
0190: 20 20 2a 20 49 6e 69 74 69 61 6c 69 7a 65 20 74 * Initialize t
01a0: 68 65 20 63 6f 6d 70 69 6c 61 74 69 6f 6e 20 61 he compilation a
01b0: 6e 64 20 65 78 65 63 75 74 69 6f 6e 20 73 74 61 nd execution sta
01c0: 74 69 73 74 69 63 73 20 6b 65 70 74 20 66 6f 72 tistics kept for
01d0: 20 74 68 69 73 0a 20 20 20 20 20 20 2a 20 69 6e this. * in
01e0: 74 65 72 70 72 65 74 65 72 2e 0a 20 20 20 20 20 terpreter..
01f0: 20 2a 2f 0a 40 40 20 2d 34 39 38 2c 36 20 2b 35 */.@@ -498,6 +5
0200: 30 35 2c 31 32 20 40 40 0a 20 09 20 20 20 20 54 05,12 @@. . T
0210: 63 6c 44 65 66 61 75 6c 74 42 67 45 72 72 6f 72 clDefaultBgError
0220: 48 61 6e 64 6c 65 72 4f 62 6a 43 6d 64 2c 20 4e HandlerObjCmd, N
0230: 55 4c 4c 2c 20 4e 55 4c 4c 29 3b 0a 20 0a 20 20 ULL, NULL);. .
0240: 20 20 20 2f 2a 0a 2b 09 20 2a 20 52 65 67 69 73 /*.+. * Regis
0250: 74 65 72 20 74 68 65 20 65 72 72 6f 72 20 68 61 ter the error ha
0260: 6e 64 6c 65 72 20 72 65 67 69 73 74 72 61 74 69 ndler registrati
0270: 6f 6e 20 63 6f 6d 6d 61 6e 64 0a 2b 09 20 2a 2f on command.+. */
0280: 0a 2b 20 20 20 20 54 63 6c 5f 43 72 65 61 74 65 .+ Tcl_Create
0290: 4f 62 6a 43 6f 6d 6d 61 6e 64 28 69 6e 74 65 72 ObjCommand(inter
02a0: 70 2c 20 22 3a 3a 74 63 6c 3a 3a 73 65 74 65 72 p, "::tcl::seter
02b0: 72 6f 72 68 61 6e 64 6c 65 72 22 2c 0a 2b 09 20 rorhandler",.+.
02c0: 20 20 20 54 63 6c 53 65 74 45 72 72 6f 72 48 61 TclSetErrorHa
02d0: 6e 64 6c 65 72 4f 62 6a 43 6d 64 2c 20 4e 55 4c ndlerObjCmd, NUL
02e0: 4c 2c 20 4e 55 4c 4c 29 3b 0a 2b 09 0a 2b 20 20 L, NULL);.+..+
02f0: 20 20 2f 2a 0a 20 20 20 20 20 20 2a 20 52 65 67 /*. * Reg
0300: 69 73 74 65 72 20 74 68 65 20 62 75 69 6c 74 69 ister the builti
0310: 6e 20 6d 61 74 68 20 66 75 6e 63 74 69 6f 6e 73 n math functions
0320: 2e 0a 20 20 20 20 20 20 2a 2f 0a 20 0a 40 40 20 .. */. .@@
0330: 2d 33 32 37 36 2c 37 20 2b 33 32 38 39 2c 37 20 -3276,7 +3289,7
0340: 40 40 0a 20 20 20 20 20 20 2a 20 6e 65 65 64 20 @@. * need
0350: 28 61 74 20 6d 6f 73 74 29 20 74 77 6f 20 70 61 (at most) two pa
0360: 73 73 65 73 20 68 65 72 65 2e 0a 20 20 20 20 20 sses here..
0370: 20 2a 2f 0a 20 0a 2d 20 20 72 65 70 61 72 73 65 */. .- reparse
0380: 42 65 63 61 75 73 65 4f 66 54 72 61 63 65 73 3a BecauseOfTraces:
0390: 0a 2b 72 65 70 61 72 73 65 42 65 63 61 75 73 65 .+reparseBecause
03a0: 4f 66 54 72 61 63 65 73 3a 0a 20 20 20 20 20 63 OfTraces:. c
03b0: 6d 64 50 74 72 20 3d 20 28 43 6f 6d 6d 61 6e 64 mdPtr = (Command
03c0: 20 2a 29 20 54 63 6c 5f 47 65 74 43 6f 6d 6d 61 *) Tcl_GetComma
03d0: 6e 64 46 72 6f 6d 4f 62 6a 28 69 6e 74 65 72 70 ndFromObj(interp
03e0: 2c 20 6f 62 6a 76 5b 30 5d 29 3b 0a 20 20 20 20 , objv[0]);.
03f0: 20 69 66 20 28 63 6d 64 50 74 72 20 3d 3d 20 4e if (cmdPtr == N
0400: 55 4c 4c 29 20 7b 0a 20 09 4e 61 6d 65 73 70 61 ULL) {. .Namespa
0410: 63 65 20 2a 63 75 72 72 4e 73 50 74 72 20 3d 20 ce *currNsPtr =
0420: 4e 55 4c 4c 3b 09 2f 2a 20 55 73 65 64 20 74 6f NULL;./* Used to
0430: 20 63 68 65 63 6b 20 66 6f 72 20 61 6e 64 20 69 check for and i
0440: 6e 76 6f 6b 65 20 61 6e 79 0a 40 40 20 2d 33 34 nvoke any.@@ -34
0450: 32 36 2c 38 20 2b 33 34 33 39 2c 34 39 20 40 40 26,8 +3439,49 @@
0460: 0a 20 09 28 76 6f 69 64 29 20 54 63 6c 5f 47 65 . .(void) Tcl_Ge
0470: 74 4f 62 6a 52 65 73 75 6c 74 28 69 6e 74 65 72 tObjResult(inter
0480: 70 29 3b 0a 20 20 20 20 20 7d 0a 20 0a 2d 20 20 p);. }. .-
0490: 20 20 64 6f 6e 65 3a 0a 2b 64 6f 6e 65 3a 0a 20 done:.+done:.
04a0: 20 20 20 20 69 50 74 72 2d 3e 76 61 72 46 72 61 iPtr->varFra
04b0: 6d 65 50 74 72 20 3d 20 73 61 76 65 64 56 61 72 mePtr = savedVar
04c0: 46 72 61 6d 65 50 74 72 3b 0a 2b 20 20 20 20 2f FramePtr;.+ /
04d0: 2a 0a 2b 20 20 20 20 20 2a 20 45 78 65 63 75 74 *.+ * Execut
04e0: 65 20 74 68 65 20 65 72 72 6f 72 48 61 6e 64 6c e the errorHandl
04f0: 65 72 20 74 68 61 74 20 77 61 73 20 72 65 67 69 er that was regi
0500: 73 74 65 72 65 64 20 77 69 74 68 20 74 68 65 20 stered with the
0510: 69 6e 74 65 72 70 20 65 76 65 6e 74 75 61 6c 6c interp eventuall
0520: 79 2e 0a 2b 20 20 20 20 20 2a 20 54 68 69 73 20 y..+ * This
0530: 73 68 6f 75 6c 64 20 62 65 20 64 6f 6e 65 20 6f should be done o
0540: 6e 6c 79 20 69 66 20 74 68 65 20 65 72 72 6f 72 nly if the error
0550: 20 77 61 73 20 6e 6f 74 20 74 68 72 6f 77 6e 20 was not thrown
0560: 61 6c 72 65 61 64 79 20 75 70 77 61 72 64 73 0a already upwards.
0570: 2b 20 20 20 20 20 2a 20 74 68 65 20 65 78 65 63 + * the exec
0580: 75 74 69 6f 6e 20 73 74 61 63 6b 2c 20 69 66 20 ution stack, if
0590: 74 68 65 20 65 6e 76 69 72 6f 6e 6d 65 6e 74 20 the environment
05a0: 6d 61 74 63 68 65 73 20 74 68 65 20 66 6c 61 67 matches the flag
05b0: 73 20 2d 63 61 75 67 68 74 20 61 6e 64 0a 2b 20 s -caught and.+
05c0: 20 20 20 20 2a 20 2d 75 6e 63 61 75 67 68 74 20 * -uncaught
05d0: 61 6e 64 20 61 63 63 6f 72 64 69 6e 67 20 74 6f and according to
05e0: 20 77 68 65 74 68 65 72 20 74 68 65 20 65 72 72 whether the err
05f0: 6f 72 20 77 61 73 20 72 65 61 6c 6c 79 20 63 61 or was really ca
0600: 74 63 68 65 64 2e 0a 2b 20 20 20 20 20 2a 20 54 tched..+ * T
0610: 68 6f 73 65 20 66 6c 61 67 73 20 61 72 65 20 73 hose flags are s
0620: 74 6f 72 65 64 20 69 6e 20 65 72 72 6f 72 48 61 tored in errorHa
0630: 6e 64 6c 65 72 46 6c 61 67 73 20 6d 65 6d 62 65 ndlerFlags membe
0640: 72 2e 0a 2b 20 20 20 20 20 2a 2f 0a 2b 20 20 20 r..+ */.+
0650: 20 69 66 20 28 63 6f 64 65 20 3d 3d 20 54 43 4c if (code == TCL
0660: 5f 45 52 52 4f 52 20 26 26 20 69 50 74 72 2d 3e _ERROR && iPtr->
0670: 65 72 72 6f 72 48 61 6e 64 6c 65 72 20 21 3d 20 errorHandler !=
0680: 4e 55 4c 4c 20 0a 2b 20 20 20 20 20 20 20 20 20 NULL .+
0690: 20 20 20 26 26 20 21 28 69 50 74 72 2d 3e 65 72 && !(iPtr->er
06a0: 72 6f 72 48 61 6e 64 6c 65 72 46 6c 61 67 73 20 rorHandlerFlags
06b0: 26 20 45 52 52 48 41 4e 44 4c 45 52 5f 46 49 4e & ERRHANDLER_FIN
06c0: 49 53 48 45 44 29 0a 2b 20 20 20 20 20 20 20 20 ISHED).+
06d0: 20 20 20 20 26 26 20 21 28 69 50 74 72 2d 3e 65 && !(iPtr->e
06e0: 72 72 6f 72 48 61 6e 64 6c 65 72 46 6c 61 67 73 rrorHandlerFlags
06f0: 20 26 20 45 52 52 48 41 4e 44 4c 45 52 5f 52 55 & ERRHANDLER_RU
0700: 4e 4e 49 4e 47 29 29 20 7b 0a 2b 0a 2b 20 20 20 NNING)) {.+.+
0710: 20 20 20 20 20 69 6e 74 20 75 6e 63 61 74 63 68 int uncatch
0720: 65 64 20 3d 20 28 69 50 74 72 2d 3e 63 61 74 63 ed = (iPtr->catc
0730: 68 4c 65 76 65 6c 20 3c 3d 20 30 20 0a 2b 20 20 hLevel <= 0 .+
0740: 20 20 20 20 20 20 20 20 20 20 26 26 20 28 69 50 && (iP
0750: 74 72 2d 3e 65 72 72 6f 72 48 61 6e 64 6c 65 72 tr->errorHandler
0760: 46 6c 61 67 73 20 26 20 45 52 52 48 41 4e 44 4c Flags & ERRHANDL
0770: 45 52 5f 4f 4e 55 4e 43 41 55 47 48 54 29 29 3b ER_ONUNCAUGHT));
0780: 20 0a 2b 20 20 20 20 20 20 20 20 69 6e 74 20 63 .+ int c
0790: 61 74 63 68 65 64 20 3d 20 28 69 50 74 72 2d 3e atched = (iPtr->
07a0: 63 61 74 63 68 4c 65 76 65 6c 20 3e 20 30 20 0a catchLevel > 0 .
07b0: 2b 20 20 20 20 20 20 20 20 20 20 20 20 26 26 20 + &&
07c0: 28 69 50 74 72 2d 3e 65 72 72 6f 72 48 61 6e 64 (iPtr->errorHand
07d0: 6c 65 72 46 6c 61 67 73 20 26 20 45 52 52 48 41 lerFlags & ERRHA
07e0: 4e 44 4c 45 52 5f 4f 4e 43 41 55 47 48 54 29 29 NDLER_ONCAUGHT))
07f0: 3b 0a 2b 20 20 20 20 20 20 20 20 69 66 20 28 75 ;.+ if (u
0800: 6e 63 61 74 63 68 65 64 20 7c 7c 20 63 61 74 63 ncatched || catc
0810: 68 65 64 29 20 7b 0a 2b 20 20 20 20 20 20 20 20 hed) {.+
0820: 20 20 20 20 54 63 6c 5f 44 53 74 72 69 6e 67 20 Tcl_DString
0830: 63 6d 64 42 75 66 3b 0a 2b 20 20 20 20 20 20 20 cmdBuf;.+
0840: 20 20 20 20 20 69 6e 74 20 69 2c 20 63 6d 64 4c int i, cmdL
0850: 65 6e 3b 0a 2b 20 20 20 20 20 20 20 20 20 20 20 en;.+
0860: 20 63 68 61 72 20 2a 63 6d 64 53 74 72 69 6e 67 char *cmdString
0870: 3b 0a 2b 20 20 20 20 20 20 20 20 20 20 20 20 0a ;.+ .
0880: 2b 20 20 20 20 20 20 20 20 20 20 20 20 2f 2a 20 + /*
0890: 4c 6f 67 20 74 68 65 20 65 72 72 6f 72 2c 20 73 Log the error, s
08a0: 6f 20 74 68 61 74 20 69 74 20 69 73 20 61 76 61 o that it is ava
08b0: 69 6c 61 62 6c 65 20 69 6e 20 74 68 65 20 68 61 ilable in the ha
08c0: 6e 64 6c 65 72 20 2a 2f 0a 2b 20 20 20 20 20 20 ndler */.+
08d0: 20 20 20 20 20 20 54 63 6c 5f 44 53 74 72 69 6e Tcl_DStrin
08e0: 67 49 6e 69 74 28 26 63 6d 64 42 75 66 29 3b 0a gInit(&cmdBuf);.
08f0: 2b 20 20 20 20 20 20 20 20 20 20 20 20 66 6f 72 + for
0900: 20 28 69 20 3d 20 30 3b 20 69 20 3c 20 6f 62 6a (i = 0; i < obj
0910: 63 3b 20 69 2b 2b 29 20 7b 0a 2b 20 20 20 20 20 c; i++) {.+
0920: 20 20 20 20 20 20 20 20 20 20 20 54 63 6c 5f 44 Tcl_D
0930: 53 74 72 69 6e 67 41 70 70 65 6e 64 45 6c 65 6d StringAppendElem
0940: 65 6e 74 28 26 63 6d 64 42 75 66 2c 20 54 63 6c ent(&cmdBuf, Tcl
0950: 5f 47 65 74 53 74 72 69 6e 67 28 6f 62 6a 76 5b _GetString(objv[
0960: 69 5d 29 29 3b 0a 2b 20 20 20 20 20 20 20 20 20 i]));.+
0970: 20 20 20 7d 0a 2b 20 20 20 20 20 20 20 20 20 20 }.+
0980: 20 20 63 6d 64 53 74 72 69 6e 67 20 3d 20 54 63 cmdString = Tc
0990: 6c 5f 44 53 74 72 69 6e 67 56 61 6c 75 65 28 26 l_DStringValue(&
09a0: 63 6d 64 42 75 66 29 3b 0a 2b 20 20 20 20 20 20 cmdBuf);.+
09b0: 20 20 20 20 20 20 63 6d 64 4c 65 6e 20 3d 20 54 cmdLen = T
09c0: 63 6c 5f 44 53 74 72 69 6e 67 4c 65 6e 67 74 68 cl_DStringLength
09d0: 28 26 63 6d 64 42 75 66 29 3b 0a 2b 20 20 20 20 (&cmdBuf);.+
09e0: 20 20 20 20 20 20 20 20 54 63 6c 5f 4c 6f 67 43 Tcl_LogC
09f0: 6f 6d 6d 61 6e 64 49 6e 66 6f 28 69 6e 74 65 72 ommandInfo(inter
0a00: 70 2c 20 63 6d 64 53 74 72 69 6e 67 2c 20 63 6d p, cmdString, cm
0a10: 64 53 74 72 69 6e 67 2c 20 63 6d 64 4c 65 6e 29 dString, cmdLen)
0a20: 3b 0a 2b 20 20 20 20 20 20 20 20 20 20 20 20 0a ;.+ .
0a30: 2b 20 20 20 20 20 20 20 20 20 20 20 20 69 50 74 + iPt
0a40: 72 2d 3e 65 72 72 6f 72 48 61 6e 64 6c 65 72 46 r->errorHandlerF
0a50: 6c 61 67 73 20 7c 3d 20 45 52 52 48 41 4e 44 4c lags |= ERRHANDL
0a60: 45 52 5f 52 55 4e 4e 49 4e 47 3b 0a 2b 20 20 20 ER_RUNNING;.+
0a70: 20 20 20 20 20 20 20 20 20 63 6f 64 65 20 3d 20 code =
0a80: 54 63 6c 5f 45 76 61 6c 4f 62 6a 28 69 6e 74 65 Tcl_EvalObj(inte
0a90: 72 70 2c 20 69 50 74 72 2d 3e 65 72 72 6f 72 48 rp, iPtr->errorH
0aa0: 61 6e 64 6c 65 72 29 3b 0a 2b 20 20 20 20 20 20 andler);.+
0ab0: 20 20 20 20 20 20 69 50 74 72 2d 3e 65 72 72 6f iPtr->erro
0ac0: 72 48 61 6e 64 6c 65 72 46 6c 61 67 73 20 26 3d rHandlerFlags &=
0ad0: 20 7e 45 52 52 48 41 4e 44 4c 45 52 5f 52 55 4e ~ERRHANDLER_RUN
0ae0: 4e 49 4e 47 3b 0a 2b 20 20 20 20 20 20 20 20 20 NING;.+
0af0: 20 20 20 69 50 74 72 2d 3e 65 72 72 6f 72 48 61 iPtr->errorHa
0b00: 6e 64 6c 65 72 46 6c 61 67 73 20 7c 3d 20 45 52 ndlerFlags |= ER
0b10: 52 48 41 4e 44 4c 45 52 5f 46 49 4e 49 53 48 45 RHANDLER_FINISHE
0b20: 44 3b 0a 2b 20 20 20 20 20 20 20 20 20 20 20 20 D;.+
0b30: 0a 2b 20 20 20 20 20 20 20 20 20 20 20 20 69 66 .+ if
0b40: 20 28 63 6d 64 4c 65 6e 20 21 3d 20 30 29 20 7b (cmdLen != 0) {
0b50: 0a 2b 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .+
0b60: 20 20 54 63 6c 5f 44 53 74 72 69 6e 67 46 72 65 Tcl_DStringFre
0b70: 65 28 26 63 6d 64 42 75 66 29 3b 0a 2b 20 20 20 e(&cmdBuf);.+
0b80: 20 20 20 20 20 20 20 20 20 7d 0a 2b 20 20 20 20 }.+
0b90: 20 20 20 20 20 20 20 20 0a 2b 20 20 20 20 20 20 .+
0ba0: 20 20 7d 0a 2b 20 20 20 20 7d 0a 2b 0a 20 20 20 }.+ }.+.
0bb0: 20 20 72 65 74 75 72 6e 20 63 6f 64 65 3b 0a 20 return code;.
0bc0: 7d 0a 20 0c 0a 40 40 20 2d 33 38 32 36 2c 37 20 }. ..@@ -3826,7
0bd0: 2b 33 38 38 30 2c 37 20 40 40 0a 20 20 20 20 20 +3880,7 @@.
0be0: 69 50 74 72 2d 3e 76 61 72 46 72 61 6d 65 50 74 iPtr->varFramePt
0bf0: 72 20 3d 20 73 61 76 65 64 56 61 72 46 72 61 6d r = savedVarFram
0c00: 65 50 74 72 3b 0a 20 20 20 20 20 72 65 74 75 72 ePtr;. retur
0c10: 6e 20 54 43 4c 5f 4f 4b 3b 0a 20 0a 2d 20 20 65 n TCL_OK;. .- e
0c20: 72 72 6f 72 3a 0a 2b 65 72 72 6f 72 3a 0a 20 20 rror:.+error:.
0c30: 20 20 20 2f 2a 0a 20 20 20 20 20 20 2a 20 47 65 /*. * Ge
0c40: 6e 65 72 61 74 65 20 61 6e 64 20 6c 6f 67 20 76 nerate and log v
0c50: 61 72 69 6f 75 73 20 70 69 65 63 65 73 20 6f 66 arious pieces of
0c60: 20 65 72 72 6f 72 20 69 6e 66 6f 72 6d 61 74 69 error informati
0c70: 6f 6e 2e 0a 20 20 20 20 20 20 2a 2f 0a 64 69 66 on.. */.dif
0c80: 66 20 2d 75 62 72 4e 20 74 63 6c 38 2e 35 61 35 f -ubrN tcl8.5a5
0c90: 2f 67 65 6e 65 72 69 63 2f 74 63 6c 43 6d 64 41 /generic/tclCmdA
0ca0: 48 2e 63 20 74 63 6c 2f 67 65 6e 65 72 69 63 2f H.c tcl/generic/
0cb0: 74 63 6c 43 6d 64 41 48 2e 63 0a 2d 2d 2d 20 74 tclCmdAH.c.--- t
0cc0: 63 6c 38 2e 35 61 35 2f 67 65 6e 65 72 69 63 2f cl8.5a5/generic/
0cd0: 74 63 6c 43 6d 64 41 48 2e 63 09 54 68 75 20 41 tclCmdAH.c.Thu A
0ce0: 75 67 20 31 30 20 31 32 3a 31 35 3a 33 30 20 32 ug 10 12:15:30 2
0cf0: 30 30 36 0a 2b 2b 2b 20 74 63 6c 2f 67 65 6e 65 006.+++ tcl/gene
0d00: 72 69 63 2f 74 63 6c 43 6d 64 41 48 2e 63 09 53 ric/tclCmdAH.c.S
0d10: 75 6e 20 4f 63 74 20 32 39 20 31 30 3a 34 30 3a un Oct 29 10:40:
0d20: 30 31 20 32 30 30 36 0a 40 40 20 2d 32 32 38 2c 01 2006.@@ -228,
0d30: 36 20 2b 32 32 38 2c 37 20 40 40 0a 20 7b 0a 20 6 +228,7 @@. {.
0d40: 20 20 20 20 54 63 6c 5f 4f 62 6a 20 2a 76 61 72 Tcl_Obj *var
0d50: 4e 61 6d 65 50 74 72 20 3d 20 4e 55 4c 4c 3b 0a NamePtr = NULL;.
0d60: 20 20 20 20 20 54 63 6c 5f 4f 62 6a 20 2a 6f 70 Tcl_Obj *op
0d70: 74 69 6f 6e 56 61 72 4e 61 6d 65 50 74 72 20 3d tionVarNamePtr =
0d80: 20 4e 55 4c 4c 3b 0a 2b 20 20 20 20 49 6e 74 65 NULL;.+ Inte
0d90: 72 70 20 2a 69 50 74 72 20 3d 20 28 49 6e 74 65 rp *iPtr = (Inte
0da0: 72 70 2a 29 69 6e 74 65 72 70 3b 0a 20 20 20 20 rp*)interp;.
0db0: 20 69 6e 74 20 72 65 73 75 6c 74 3b 0a 20 0a 20 int result;. .
0dc0: 20 20 20 20 69 66 20 28 28 6f 62 6a 63 20 3c 20 if ((objc <
0dd0: 32 29 20 7c 7c 20 28 6f 62 6a 63 20 3e 20 34 29 2) || (objc > 4)
0de0: 29 20 7b 0a 40 40 20 2d 32 34 33 2c 37 20 2b 32 ) {.@@ -243,7 +2
0df0: 34 34 2c 39 20 40 40 0a 20 09 6f 70 74 69 6f 6e 44,9 @@. .option
0e00: 56 61 72 4e 61 6d 65 50 74 72 20 3d 20 6f 62 6a VarNamePtr = obj
0e10: 76 5b 33 5d 3b 0a 20 20 20 20 20 7d 0a 20 0a 2b v[3];. }. .+
0e20: 20 20 20 20 69 50 74 72 2d 3e 63 61 74 63 68 4c iPtr->catchL
0e30: 65 76 65 6c 2b 2b 3b 0a 20 20 20 20 20 72 65 73 evel++;. res
0e40: 75 6c 74 20 3d 20 54 63 6c 5f 45 76 61 6c 4f 62 ult = Tcl_EvalOb
0e50: 6a 45 78 28 69 6e 74 65 72 70 2c 20 6f 62 6a 76 jEx(interp, objv
0e60: 5b 31 5d 2c 20 30 29 3b 0a 2b 20 20 20 20 69 50 [1], 0);.+ iP
0e70: 74 72 2d 3e 63 61 74 63 68 4c 65 76 65 6c 2d 2d tr->catchLevel--
0e80: 3b 0a 20 0a 20 20 20 20 20 2f 2a 0a 20 20 20 20 ;. . /*.
0e90: 20 20 2a 20 57 65 20 64 69 73 61 62 6c 65 20 63 * We disable c
0ea0: 61 74 63 68 20 69 6e 20 69 6e 74 65 72 70 72 65 atch in interpre
0eb0: 74 65 72 73 20 77 68 65 72 65 20 74 68 65 20 6c ters where the l
0ec0: 69 6d 69 74 20 68 61 73 20 62 65 65 6e 20 65 78 imit has been ex
0ed0: 63 65 65 64 65 64 2e 0a 64 69 66 66 20 2d 75 62 ceeded..diff -ub
0ee0: 72 4e 20 74 63 6c 38 2e 35 61 35 2f 67 65 6e 65 rN tcl8.5a5/gene
0ef0: 72 69 63 2f 74 63 6c 45 76 65 6e 74 2e 63 20 74 ric/tclEvent.c t
0f00: 63 6c 2f 67 65 6e 65 72 69 63 2f 74 63 6c 45 76 cl/generic/tclEv
0f10: 65 6e 74 2e 63 0a 2d 2d 2d 20 74 63 6c 38 2e 35 ent.c.--- tcl8.5
0f20: 61 35 2f 67 65 6e 65 72 69 63 2f 74 63 6c 45 76 a5/generic/tclEv
0f30: 65 6e 74 2e 63 09 54 75 65 20 53 65 70 20 31 39 ent.c.Tue Sep 19
0f40: 20 32 32 3a 30 37 3a 33 34 20 32 30 30 36 0a 2b 22:07:34 2006.+
0f50: 2b 2b 20 74 63 6c 2f 67 65 6e 65 72 69 63 2f 74 ++ tcl/generic/t
0f60: 63 6c 45 76 65 6e 74 2e 63 09 53 75 6e 20 4f 63 clEvent.c.Sun Oc
0f70: 74 20 32 39 20 31 30 3a 33 33 3a 32 38 20 32 30 t 29 10:33:28 20
0f80: 30 36 0a 40 40 20 2d 33 38 30 2c 36 20 2b 33 38 06.@@ -380,6 +38
0f90: 30 2c 31 33 34 20 40 40 0a 20 20 20 20 20 72 65 0,134 @@. re
0fa0: 74 75 72 6e 20 63 6f 64 65 3b 0a 20 7d 0a 20 0c turn code;. }. .
0fb0: 0a 2b 0a 2b 2f 2a 0a 2b 20 2a 2d 2d 2d 2d 2d 2d .+.+/*.+ *------
0fc0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
0fd0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
0fe0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
0ff0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
1000: 0a 2b 20 2a 0a 2b 20 2a 20 54 63 6c 53 65 74 45 .+ *.+ * TclSetE
1010: 72 72 6f 72 48 61 6e 64 6c 65 72 4f 62 6a 43 6d rrorHandlerObjCm
1020: 64 20 2d 2d 0a 2b 20 2a 0a 2b 20 2a 09 54 68 69 d --.+ *.+ *.Thi
1030: 73 20 66 75 6e 63 74 69 6f 6e 20 69 73 20 69 6e s function is in
1040: 76 6f 6b 65 64 20 74 6f 20 70 72 6f 63 65 73 73 voked to process
1050: 20 74 68 65 20 22 3a 3a 74 63 6c 3a 3a 65 72 72 the "::tcl::err
1060: 6f 72 73 63 72 69 70 74 22 20 54 63 6c 20 63 6f orscript" Tcl co
1070: 6d 6d 61 6e 64 2e 0a 2b 20 2a 09 49 74 20 72 65 mmand..+ *.It re
1080: 67 69 73 74 65 72 73 20 61 6e 20 61 72 62 69 74 gisters an arbit
1090: 72 61 72 79 20 73 63 72 69 70 74 20 66 6f 72 20 rary script for
10a0: 65 78 65 63 75 74 69 6f 6e 2c 20 77 68 65 6e 20 execution, when
10b0: 54 63 6c 20 65 6e 63 6f 75 6e 74 65 72 73 20 61 Tcl encounters a
10c0: 6e 20 0a 2b 20 2a 20 20 65 72 72 6f 72 20 69 6e n .+ * error in
10d0: 20 74 68 65 20 65 78 65 63 75 74 69 6f 6e 2e 20 the execution.
10e0: 42 79 20 74 68 69 73 20 69 74 20 69 73 20 70 6f By this it is po
10f0: 73 73 69 62 6c 65 20 74 6f 20 62 72 65 61 6b 20 ssible to break
1100: 74 68 65 20 65 78 65 63 75 74 69 6f 6e 20 69 6e the execution in
1110: 0a 2b 20 2a 20 20 65 72 72 6f 72 20 63 61 73 65 .+ * error case
1120: 20 61 6e 64 20 69 6e 74 72 6f 73 70 65 63 74 20 and introspect
1130: 74 68 65 20 70 72 6f 67 72 61 6d 20 66 72 6f 6d the program from
1140: 20 77 69 74 68 69 6e 20 74 68 65 20 65 72 72 6f within the erro
1150: 72 20 70 6f 73 69 74 69 6f 6e 2e 20 49 66 0a 2b r position. If.+
1160: 20 2a 20 20 6e 6f 20 65 72 72 6f 72 73 63 72 69 * no errorscri
1170: 70 74 20 69 73 20 72 65 67 69 73 74 65 72 65 64 pt is registered
1180: 2c 20 74 68 65 20 65 72 72 6f 72 20 69 73 20 70 , the error is p
1190: 72 6f 63 65 73 73 65 64 20 61 73 20 75 73 75 61 rocessed as usua
11a0: 6c 2c 20 77 68 69 63 68 20 6d 65 61 6e 73 0a 2b l, which means.+
11b0: 20 2a 20 20 74 68 65 20 73 74 61 63 6b 20 74 72 * the stack tr
11c0: 61 63 65 20 69 73 20 75 6e 77 6f 75 6e 64 20 61 ace is unwound a
11d0: 6e 64 20 61 6e 20 65 72 72 6f 72 20 6d 65 73 73 nd an error mess
11e0: 61 67 65 20 69 73 20 63 72 65 61 74 65 64 2e 0a age is created..
11f0: 2b 20 2a 20 0a 2b 20 2a 20 55 73 61 67 65 3a 0a + * .+ * Usage:.
1200: 2b 20 2a 20 20 3a 3a 74 63 6c 3a 3a 65 72 72 6f + * ::tcl::erro
1210: 72 73 63 72 69 70 74 20 3f 2d 63 61 75 67 68 74 rscript ?-caught
1220: 3f 20 3f 2d 75 6e 63 61 75 67 68 74 3f 20 73 63 ? ?-uncaught? sc
1230: 72 69 70 74 0a 2b 20 2a 20 0a 2b 20 2a 20 41 72 ript.+ * .+ * Ar
1240: 67 75 6d 65 6e 74 73 3a 20 0a 2b 20 2a 20 2d 63 guments: .+ * -c
1250: 61 75 67 68 74 2c 20 2d 75 6e 63 61 75 67 68 74 aught, -uncaught
1260: 0a 2b 20 2a 20 20 49 64 65 6e 74 69 66 79 20 77 .+ * Identify w
1270: 68 65 74 68 65 72 20 63 61 75 67 68 74 20 6f 72 hether caught or
1280: 2f 61 6e 64 20 75 6e 63 61 75 67 68 74 20 65 72 /and uncaught er
1290: 72 6f 72 73 20 73 68 6f 75 6c 64 20 62 65 20 70 rors should be p
12a0: 72 6f 63 65 73 73 65 64 20 62 79 20 74 68 65 0a rocessed by the.
12b0: 2b 20 2a 20 20 73 63 72 69 70 74 2e 20 42 79 20 + * script. By
12c0: 64 65 66 61 75 6c 74 2c 20 6f 6e 6c 79 20 75 6e default, only un
12d0: 63 61 75 67 68 74 20 65 72 72 6f 72 73 20 61 72 caught errors ar
12e0: 65 20 70 72 6f 63 65 73 73 65 64 0a 2b 20 2a 20 e processed.+ *
12f0: 73 63 72 69 70 74 0a 2b 20 2a 20 20 54 68 65 20 script.+ * The
1300: 73 63 72 69 70 74 20 74 6f 20 65 78 65 63 75 74 script to execut
1310: 65 20 69 6e 20 65 72 72 6f 72 20 63 61 73 65 0a e in error case.
1320: 2b 20 2a 0a 2b 20 2a 20 52 65 73 75 6c 74 73 3a + *.+ * Results:
1330: 0a 2b 20 2a 09 45 6d 70 74 79 20 73 74 72 69 6e .+ *.Empty strin
1340: 67 0a 2b 20 2a 0a 2b 20 2a 20 53 69 64 65 20 65 g.+ *.+ * Side e
1350: 66 66 65 63 74 73 3a 0a 2b 20 2a 09 73 65 74 73 ffects:.+ *.sets
1360: 20 65 72 72 6f 72 48 61 6e 64 6c 65 72 20 61 6e errorHandler an
1370: 64 20 65 78 65 63 45 72 72 6f 72 53 63 72 69 70 d execErrorScrip
1380: 74 20 6d 65 6d 62 65 72 20 6f 66 20 74 68 65 20 t member of the
1390: 69 6e 74 65 72 70 72 65 74 65 72 20 73 74 72 75 interpreter stru
13a0: 63 74 75 72 65 0a 2b 20 2a 0a 2b 20 2a 2d 2d 2d cture.+ *.+ *---
13b0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
13c0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
13d0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
13e0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
13f0: 2d 2d 2d 0a 2b 20 2a 2f 0a 2b 0a 2b 69 6e 74 0a ---.+ */.+.+int.
1400: 2b 54 63 6c 53 65 74 45 72 72 6f 72 48 61 6e 64 +TclSetErrorHand
1410: 6c 65 72 4f 62 6a 43 6d 64 28 0a 2b 20 20 20 20 lerObjCmd(.+
1420: 43 6c 69 65 6e 74 44 61 74 61 20 64 75 6d 6d 79 ClientData dummy
1430: 2c 09 09 2f 2a 20 4e 6f 74 20 75 73 65 64 2e 20 ,../* Not used.
1440: 2a 2f 0a 2b 20 20 20 20 54 63 6c 5f 49 6e 74 65 */.+ Tcl_Inte
1450: 72 70 20 2a 69 6e 74 65 72 70 2c 09 09 2f 2a 20 rp *interp,../*
1460: 43 75 72 72 65 6e 74 20 69 6e 74 65 72 70 72 65 Current interpre
1470: 74 65 72 2e 20 2a 2f 0a 2b 20 20 20 20 69 6e 74 ter. */.+ int
1480: 20 6f 62 6a 63 2c 09 09 09 2f 2a 20 4e 75 6d 62 objc,.../* Numb
1490: 65 72 20 6f 66 20 61 72 67 75 6d 65 6e 74 73 2e er of arguments.
14a0: 20 2a 2f 0a 2b 20 20 20 20 54 63 6c 5f 4f 62 6a */.+ Tcl_Obj
14b0: 20 2a 43 4f 4e 53 54 20 6f 62 6a 76 5b 5d 29 09 *CONST objv[]).
14c0: 2f 2a 20 41 72 67 75 6d 65 6e 74 20 6f 62 6a 65 /* Argument obje
14d0: 63 74 73 2e 20 2a 2f 0a 2b 7b 0a 2b 20 20 20 20 cts. */.+{.+
14e0: 49 6e 74 65 72 70 20 2a 69 50 74 72 20 3d 20 28 Interp *iPtr = (
14f0: 49 6e 74 65 72 70 2a 29 69 6e 74 65 72 70 3b 0a Interp*)interp;.
1500: 2b 20 20 20 20 0a 2b 20 20 20 20 69 66 20 28 6f + .+ if (o
1510: 62 6a 63 20 3d 3d 20 31 29 20 7b 0a 2b 20 20 20 bjc == 1) {.+
1520: 20 20 20 20 20 2f 2a 0a 2b 20 20 20 20 20 20 20 /*.+
1530: 20 20 2a 20 52 65 74 75 72 6e 20 74 68 65 20 63 * Return the c
1540: 75 72 72 65 6e 74 6c 79 20 73 65 74 20 65 72 72 urrently set err
1550: 6f 72 20 73 63 72 69 70 74 20 70 6c 75 73 20 61 or script plus a
1560: 20 74 75 70 6c 65 20 66 6f 72 20 2d 63 61 75 67 tuple for -caug
1570: 68 74 20 61 6e 64 20 0a 2b 20 20 20 20 20 20 20 ht and .+
1580: 20 20 2a 20 2d 75 6e 63 61 75 67 68 74 20 74 68 * -uncaught th
1590: 61 74 20 69 6e 64 69 63 61 74 65 73 20 77 68 65 at indicates whe
15a0: 6e 20 74 68 65 20 73 63 72 69 70 74 20 69 73 20 n the script is
15b0: 65 78 65 63 75 74 65 64 0a 2b 20 20 20 20 20 20 executed.+
15c0: 20 20 20 2a 2f 0a 2b 20 20 20 20 20 20 20 20 54 */.+ T
15d0: 63 6c 5f 4f 62 6a 20 2a 72 65 73 75 6c 74 20 3d cl_Obj *result =
15e0: 20 54 63 6c 5f 4e 65 77 4f 62 6a 28 29 3b 0a 2b Tcl_NewObj();.+
15f0: 20 20 20 20 20 20 20 20 54 63 6c 5f 4c 69 73 74 Tcl_List
1600: 4f 62 6a 41 70 70 65 6e 64 45 6c 65 6d 65 6e 74 ObjAppendElement
1610: 28 69 6e 74 65 72 70 2c 20 72 65 73 75 6c 74 2c (interp, result,
1620: 20 54 63 6c 5f 4e 65 77 53 74 72 69 6e 67 4f 62 Tcl_NewStringOb
1630: 6a 28 22 2d 63 61 75 67 68 74 22 2c 20 2d 31 29 j("-caught", -1)
1640: 29 3b 0a 2b 20 20 20 20 20 20 20 20 54 63 6c 5f );.+ Tcl_
1650: 4c 69 73 74 4f 62 6a 41 70 70 65 6e 64 45 6c 65 ListObjAppendEle
1660: 6d 65 6e 74 28 69 6e 74 65 72 70 2c 20 72 65 73 ment(interp, res
1670: 75 6c 74 2c 20 0a 2b 20 20 20 20 20 20 20 20 20 ult, .+
1680: 20 20 20 54 63 6c 5f 4e 65 77 42 6f 6f 6c 65 61 Tcl_NewBoolea
1690: 6e 4f 62 6a 28 69 50 74 72 2d 3e 65 72 72 6f 72 nObj(iPtr->error
16a0: 48 61 6e 64 6c 65 72 46 6c 61 67 73 20 26 20 45 HandlerFlags & E
16b0: 52 52 48 41 4e 44 4c 45 52 5f 4f 4e 43 41 55 47 RRHANDLER_ONCAUG
16c0: 48 54 29 29 3b 0a 2b 20 20 20 20 20 20 20 20 54 HT));.+ T
16d0: 63 6c 5f 4c 69 73 74 4f 62 6a 41 70 70 65 6e 64 cl_ListObjAppend
16e0: 45 6c 65 6d 65 6e 74 28 69 6e 74 65 72 70 2c 20 Element(interp,
16f0: 72 65 73 75 6c 74 2c 20 54 63 6c 5f 4e 65 77 53 result, Tcl_NewS
1700: 74 72 69 6e 67 4f 62 6a 28 22 2d 75 6e 63 61 75 tringObj("-uncau
1710: 67 68 74 22 2c 20 2d 31 29 29 3b 0a 2b 20 20 20 ght", -1));.+
1720: 20 20 20 20 20 54 63 6c 5f 4c 69 73 74 4f 62 6a Tcl_ListObj
1730: 41 70 70 65 6e 64 45 6c 65 6d 65 6e 74 28 69 6e AppendElement(in
1740: 74 65 72 70 2c 20 72 65 73 75 6c 74 2c 20 0a 2b terp, result, .+
1750: 20 20 20 20 20 20 20 20 20 20 20 20 54 63 6c 5f Tcl_
1760: 4e 65 77 42 6f 6f 6c 65 61 6e 4f 62 6a 28 69 50 NewBooleanObj(iP
1770: 74 72 2d 3e 65 72 72 6f 72 48 61 6e 64 6c 65 72 tr->errorHandler
1780: 46 6c 61 67 73 20 26 20 45 52 52 48 41 4e 44 4c Flags & ERRHANDL
1790: 45 52 5f 4f 4e 55 4e 43 41 55 47 48 54 29 29 3b ER_ONUNCAUGHT));
17a0: 0a 2b 20 20 20 20 20 20 20 20 69 66 20 28 69 50 .+ if (iP
17b0: 74 72 2d 3e 65 72 72 6f 72 48 61 6e 64 6c 65 72 tr->errorHandler
17c0: 20 3d 3d 20 4e 55 4c 4c 29 20 7b 0a 2b 20 20 20 == NULL) {.+
17d0: 20 20 20 20 20 20 20 20 20 54 63 6c 5f 4c 69 73 Tcl_Lis
17e0: 74 4f 62 6a 41 70 70 65 6e 64 45 6c 65 6d 65 6e tObjAppendElemen
17f0: 74 28 69 6e 74 65 72 70 2c 20 72 65 73 75 6c 74 t(interp, result
1800: 2c 20 54 63 6c 5f 4e 65 77 53 74 72 69 6e 67 4f , Tcl_NewStringO
1810: 62 6a 28 22 22 2c 20 2d 31 29 29 3b 0a 2b 20 20 bj("", -1));.+
1820: 20 20 20 20 20 20 7d 20 65 6c 73 65 20 7b 0a 2b } else {.+
1830: 20 20 20 20 20 20 20 20 20 20 20 20 54 63 6c 5f Tcl_
1840: 4c 69 73 74 4f 62 6a 41 70 70 65 6e 64 45 6c 65 ListObjAppendEle
1850: 6d 65 6e 74 28 69 6e 74 65 72 70 2c 20 72 65 73 ment(interp, res
1860: 75 6c 74 2c 20 69 50 74 72 2d 3e 65 72 72 6f 72 ult, iPtr->error
1870: 48 61 6e 64 6c 65 72 29 3b 0a 2b 20 20 20 20 20 Handler);.+
1880: 20 20 20 7d 0a 2b 20 20 20 20 20 20 20 20 0a 2b }.+ .+
1890: 20 20 20 20 20 20 20 20 54 63 6c 5f 53 65 74 4f Tcl_SetO
18a0: 62 6a 52 65 73 75 6c 74 28 69 6e 74 65 72 70 2c bjResult(interp,
18b0: 20 72 65 73 75 6c 74 29 3b 0a 2b 20 20 20 20 20 result);.+
18c0: 20 20 20 72 65 74 75 72 6e 20 54 43 4c 5f 4f 4b return TCL_OK
18d0: 3b 0a 2b 20 20 20 20 7d 0a 2b 20 20 20 20 0a 2b ;.+ }.+ .+
18e0: 20 20 20 20 69 66 20 28 6f 62 6a 63 20 3d 3d 20 if (objc ==
18f0: 32 29 20 7b 0a 2b 20 20 20 20 20 20 20 20 63 68 2) {.+ ch
1900: 61 72 20 2a 73 63 72 69 70 74 20 3d 20 54 63 6c ar *script = Tcl
1910: 5f 47 65 74 53 74 72 69 6e 67 20 28 6f 62 6a 76 _GetString (objv
1920: 5b 31 5d 29 3b 0a 2b 20 20 20 20 20 20 20 20 69 [1]);.+ i
1930: 66 20 28 73 74 72 63 6d 70 28 73 63 72 69 70 74 f (strcmp(script
1940: 2c 20 22 22 29 20 3d 3d 20 30 20 26 26 20 69 50 , "") == 0 && iP
1950: 74 72 2d 3e 65 72 72 6f 72 48 61 6e 64 6c 65 72 tr->errorHandler
1960: 20 21 3d 20 4e 55 4c 4c 29 20 7b 0a 2b 20 20 20 != NULL) {.+
1970: 20 20 20 20 20 20 20 20 20 2f 2a 0a 2b 20 20 20 /*.+
1980: 20 20 20 20 20 20 20 20 20 20 2a 20 54 68 69 73 * This
1990: 20 69 73 20 74 68 65 20 73 69 67 6e 61 6c 20 74 is the signal t
19a0: 6f 20 72 65 73 65 74 20 74 68 65 20 65 72 72 6f o reset the erro
19b0: 72 20 73 63 72 69 70 74 2e 20 54 68 65 20 73 63 r script. The sc
19c0: 72 69 70 74 20 77 69 6c 6c 20 6e 6f 74 0a 2b 20 ript will not.+
19d0: 20 20 20 20 20 20 20 20 20 20 20 20 2a 20 62 65 * be
19e0: 20 65 78 65 63 75 74 65 64 2c 20 6e 65 69 74 68 executed, neith
19f0: 65 72 20 6f 6e 20 63 61 75 67 68 74 20 6e 6f 74 er on caught not
1a00: 20 6f 6e 20 75 6e 63 61 75 67 68 74 20 65 72 72 on uncaught err
1a10: 6f 72 73 0a 2b 20 20 20 20 20 20 20 20 20 20 20 ors.+
1a20: 20 20 2a 2f 0a 2b 20 20 20 20 20 20 20 20 20 20 */.+
1a30: 20 20 54 63 6c 5f 44 65 63 72 52 65 66 43 6f 75 Tcl_DecrRefCou
1a40: 6e 74 28 69 50 74 72 2d 3e 65 72 72 6f 72 48 61 nt(iPtr->errorHa
1a50: 6e 64 6c 65 72 29 3b 0a 2b 20 20 20 20 20 20 20 ndler);.+
1a60: 20 20 20 20 20 69 50 74 72 2d 3e 65 72 72 6f 72 iPtr->error
1a70: 48 61 6e 64 6c 65 72 20 3d 20 4e 55 4c 4c 3b 0a Handler = NULL;.
1a80: 2b 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 + ret
1a90: 75 72 6e 20 54 43 4c 5f 4f 4b 3b 0a 2b 20 20 20 urn TCL_OK;.+
1aa0: 20 20 20 20 20 7d 0a 2b 20 20 20 20 20 20 20 20 }.+
1ab0: 0a 2b 20 20 20 20 20 20 20 20 69 50 74 72 2d 3e .+ iPtr->
1ac0: 65 72 72 6f 72 48 61 6e 64 6c 65 72 20 3d 20 6f errorHandler = o
1ad0: 62 6a 76 5b 31 5d 3b 0a 2b 20 20 20 20 20 20 20 bjv[1];.+
1ae0: 20 54 63 6c 5f 49 6e 63 72 52 65 66 43 6f 75 6e Tcl_IncrRefCoun
1af0: 74 20 28 69 50 74 72 2d 3e 65 72 72 6f 72 48 61 t (iPtr->errorHa
1b00: 6e 64 6c 65 72 29 3b 0a 2b 20 20 20 20 20 20 20 ndler);.+
1b10: 20 0a 2b 20 20 20 20 20 20 20 20 72 65 74 75 72 .+ retur
1b20: 6e 20 54 43 4c 5f 4f 4b 3b 0a 2b 20 20 20 20 7d n TCL_OK;.+ }
1b30: 0a 2b 20 20 20 20 0a 2b 20 20 20 20 69 66 20 28 .+ .+ if (
1b40: 6f 62 6a 63 20 3d 3d 20 33 29 20 7b 0a 2b 20 20 objc == 3) {.+
1b50: 20 20 20 20 20 20 63 68 61 72 20 2a 66 6c 61 67 char *flag
1b60: 20 3d 20 54 63 6c 5f 47 65 74 53 74 72 69 6e 67 = Tcl_GetString
1b70: 28 6f 62 6a 76 5b 31 5d 29 3b 0a 2b 20 20 20 20 (objv[1]);.+
1b80: 20 20 20 20 0a 2b 20 20 20 20 20 20 20 20 69 66 .+ if
1b90: 20 28 2a 66 6c 61 67 20 21 3d 20 27 2d 27 29 20 (*flag != '-')
1ba0: 7b 0a 2b 20 20 20 20 20 20 20 20 20 20 20 20 67 {.+ g
1bb0: 6f 74 6f 20 65 72 72 6f 72 52 65 74 75 72 6e 3b oto errorReturn;
1bc0: 0a 2b 20 20 20 20 20 20 20 20 7d 0a 2b 20 20 20 .+ }.+
1bd0: 20 20 20 20 20 69 66 20 28 73 74 72 63 6d 70 28 if (strcmp(
1be0: 66 6c 61 67 2c 20 22 2d 63 61 75 67 68 74 22 29 flag, "-caught")
1bf0: 20 3d 3d 20 30 29 20 7b 0a 2b 20 20 20 20 20 20 == 0) {.+
1c00: 20 20 20 20 20 20 69 50 74 72 2d 3e 65 72 72 6f iPtr->erro
1c10: 72 48 61 6e 64 6c 65 72 46 6c 61 67 73 20 3d 20 rHandlerFlags =
1c20: 45 52 52 48 41 4e 44 4c 45 52 5f 4f 4e 43 41 55 ERRHANDLER_ONCAU
1c30: 47 48 54 3b 0a 2b 20 20 20 20 20 20 20 20 7d 20 GHT;.+ }
1c40: 65 6c 73 65 20 69 66 20 28 73 74 72 63 6d 70 28 else if (strcmp(
1c50: 66 6c 61 67 2c 20 22 2d 75 6e 63 61 75 67 68 74 flag, "-uncaught
1c60: 22 29 20 3d 3d 20 30 29 20 7b 0a 2b 20 20 20 20 ") == 0) {.+
1c70: 20 20 20 20 20 20 20 20 69 50 74 72 2d 3e 65 72 iPtr->er
1c80: 72 6f 72 48 61 6e 64 6c 65 72 46 6c 61 67 73 20 rorHandlerFlags
1c90: 3d 20 45 52 52 48 41 4e 44 4c 45 52 5f 4f 4e 55 = ERRHANDLER_ONU
1ca0: 4e 43 41 55 47 48 54 3b 0a 2b 20 20 20 20 20 20 NCAUGHT;.+
1cb0: 20 20 7d 20 65 6c 73 65 20 7b 0a 2b 20 20 20 20 } else {.+
1cc0: 20 20 20 20 20 20 20 20 67 6f 74 6f 20 65 72 72 goto err
1cd0: 6f 72 52 65 74 75 72 6e 3b 0a 2b 20 20 20 20 20 orReturn;.+
1ce0: 20 20 20 7d 0a 2b 20 20 20 20 20 20 20 20 0a 2b }.+ .+
1cf0: 20 20 20 20 20 20 20 20 69 50 74 72 2d 3e 65 72 iPtr->er
1d00: 72 6f 72 48 61 6e 64 6c 65 72 20 3d 20 6f 62 6a rorHandler = obj
1d10: 76 5b 32 5d 3b 0a 2b 20 20 20 20 20 20 20 20 54 v[2];.+ T
1d20: 63 6c 5f 49 6e 63 72 52 65 66 43 6f 75 6e 74 28 cl_IncrRefCount(
1d30: 69 50 74 72 2d 3e 65 72 72 6f 72 48 61 6e 64 6c iPtr->errorHandl
1d40: 65 72 29 3b 0a 2b 20 20 20 20 20 20 20 20 0a 2b er);.+ .+
1d50: 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 54 return T
1d60: 43 4c 5f 4f 4b 3b 0a 2b 20 20 20 20 7d 0a 2b 20 CL_OK;.+ }.+
1d70: 20 20 20 0a 2b 20 20 20 20 69 66 20 28 6f 62 6a .+ if (obj
1d80: 63 20 3d 3d 20 34 29 20 7b 0a 2b 20 20 20 20 20 c == 4) {.+
1d90: 20 20 20 63 68 61 72 20 2a 66 6c 61 67 31 20 3d char *flag1 =
1da0: 20 54 63 6c 5f 47 65 74 53 74 72 69 6e 67 28 6f Tcl_GetString(o
1db0: 62 6a 76 5b 31 5d 29 2c 20 2a 66 6c 61 67 32 20 bjv[1]), *flag2
1dc0: 3d 20 54 63 6c 5f 47 65 74 53 74 72 69 6e 67 28 = Tcl_GetString(
1dd0: 6f 62 6a 76 5b 32 5d 29 3b 0a 2b 20 20 20 20 20 objv[2]);.+
1de0: 20 20 20 69 6e 74 20 76 61 6c 69 64 20 3d 20 30 int valid = 0
1df0: 3b 0a 2b 20 20 20 20 20 20 20 20 69 66 20 28 2a ;.+ if (*
1e00: 66 6c 61 67 31 20 21 3d 20 27 2d 27 20 7c 7c 20 flag1 != '-' ||
1e10: 2a 66 6c 61 67 32 20 21 3d 20 27 2d 27 29 20 7b *flag2 != '-') {
1e20: 0a 2b 20 20 20 20 20 20 20 20 20 20 20 20 67 6f .+ go
1e30: 74 6f 20 65 72 72 6f 72 52 65 74 75 72 6e 3b 0a to errorReturn;.
1e40: 2b 20 20 20 20 20 20 20 20 7d 0a 2b 20 20 20 20 + }.+
1e50: 20 20 20 20 0a 2b 20 20 20 20 20 20 20 20 76 61 .+ va
1e60: 6c 69 64 20 3d 20 28 73 74 72 63 6d 70 28 66 6c lid = (strcmp(fl
1e70: 61 67 31 2c 20 22 2d 63 61 75 67 68 74 22 29 20 ag1, "-caught")
1e80: 3d 3d 20 30 20 26 26 20 73 74 72 63 6d 70 28 66 == 0 && strcmp(f
1e90: 6c 61 67 32 2c 20 22 2d 75 6e 63 61 75 67 68 74 lag2, "-uncaught
1ea0: 22 29 20 3d 3d 20 30 29 0a 2b 20 20 20 20 20 20 ") == 0).+
1eb0: 20 20 20 20 20 20 7c 7c 20 28 73 74 72 63 6d 70 || (strcmp
1ec0: 28 66 6c 61 67 31 2c 20 22 2d 75 6e 63 61 75 67 (flag1, "-uncaug
1ed0: 68 74 22 29 20 3d 3d 20 30 20 26 26 20 73 74 72 ht") == 0 && str
1ee0: 63 6d 70 28 66 6c 61 67 32 2c 20 22 2d 63 61 75 cmp(flag2, "-cau
1ef0: 67 68 74 22 29 20 3d 3d 20 30 29 3b 0a 2b 20 20 ght") == 0);.+
1f00: 20 20 20 20 20 20 69 66 20 28 21 76 61 6c 69 64 if (!valid
1f10: 29 20 7b 0a 2b 20 20 20 20 20 20 20 20 20 20 20 ) {.+
1f20: 20 67 6f 74 6f 20 65 72 72 6f 72 52 65 74 75 72 goto errorRetur
1f30: 6e 3b 0a 2b 20 20 20 20 20 20 20 20 7d 0a 2b 20 n;.+ }.+
1f40: 20 20 20 20 20 20 20 0a 2b 20 20 20 20 20 20 20 .+
1f50: 20 69 50 74 72 2d 3e 65 72 72 6f 72 48 61 6e 64 iPtr->errorHand
1f60: 6c 65 72 46 6c 61 67 73 20 3d 20 45 52 52 48 41 lerFlags = ERRHA
1f70: 4e 44 4c 45 52 5f 4f 4e 43 41 55 47 48 54 7c 45 NDLER_ONCAUGHT|E
1f80: 52 52 48 41 4e 44 4c 45 52 5f 4f 4e 55 4e 43 41 RRHANDLER_ONUNCA
1f90: 55 47 48 54 3b 0a 2b 20 20 20 20 20 20 20 20 69 UGHT;.+ i
1fa0: 50 74 72 2d 3e 65 72 72 6f 72 48 61 6e 64 6c 65 Ptr->errorHandle
1fb0: 72 20 3d 20 6f 62 6a 76 5b 33 5d 3b 0a 2b 20 20 r = objv[3];.+
1fc0: 20 20 20 20 20 20 54 63 6c 5f 49 6e 63 72 52 65 Tcl_IncrRe
1fd0: 66 43 6f 75 6e 74 28 69 50 74 72 2d 3e 65 72 72 fCount(iPtr->err
1fe0: 6f 72 48 61 6e 64 6c 65 72 29 3b 0a 2b 20 20 20 orHandler);.+
1ff0: 20 20 20 20 20 0a 2b 20 20 20 20 20 20 20 20 72 .+ r
2000: 65 74 75 72 6e 20 54 43 4c 5f 4f 4b 3b 0a 2b 20 eturn TCL_OK;.+
2010: 20 20 20 7d 0a 2b 20 20 20 20 0a 2b 65 72 72 6f }.+ .+erro
2020: 72 52 65 74 75 72 6e 3a 0a 2b 20 20 20 20 69 50 rReturn:.+ iP
2030: 74 72 2d 3e 65 72 72 6f 72 48 61 6e 64 6c 65 72 tr->errorHandler
2040: 20 3d 20 4e 55 4c 4c 3b 0a 2b 20 20 20 20 69 50 = NULL;.+ iP
2050: 74 72 2d 3e 65 72 72 6f 72 48 61 6e 64 6c 65 72 tr->errorHandler
2060: 46 6c 61 67 73 20 3d 20 30 3b 0a 2b 20 20 20 20 Flags = 0;.+
2070: 54 63 6c 5f 57 72 6f 6e 67 4e 75 6d 41 72 67 73 Tcl_WrongNumArgs
2080: 28 69 6e 74 65 72 70 2c 20 31 2c 20 6f 62 6a 76 (interp, 1, objv
2090: 2c 20 22 3f 2d 63 61 75 67 68 74 3f 20 3f 2d 75 , "?-caught? ?-u
20a0: 6e 63 61 75 67 68 74 3f 20 3f 73 63 72 69 70 74 ncaught? ?script
20b0: 3f 22 29 3b 0a 2b 20 20 20 20 72 65 74 75 72 6e ?");.+ return
20c0: 20 54 43 4c 5f 45 52 52 4f 52 3b 0a 2b 7d 0a 2b TCL_ERROR;.+}.+
20d0: 0a 20 2f 2a 0a 20 20 2a 2d 2d 2d 2d 2d 2d 2d 2d . /*. *--------
20e0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
20f0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
2100: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
2110: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0a 20 --------------.
2120: 20 2a 0a 64 69 66 66 20 2d 75 62 72 4e 20 74 63 *.diff -ubrN tc
2130: 6c 38 2e 35 61 35 2f 67 65 6e 65 72 69 63 2f 74 l8.5a5/generic/t
2140: 63 6c 45 78 65 63 75 74 65 2e 63 20 74 63 6c 2f clExecute.c tcl/
2150: 67 65 6e 65 72 69 63 2f 74 63 6c 45 78 65 63 75 generic/tclExecu
2160: 74 65 2e 63 0a 2d 2d 2d 20 74 63 6c 38 2e 35 61 te.c.--- tcl8.5a
2170: 35 2f 67 65 6e 65 72 69 63 2f 74 63 6c 45 78 65 5/generic/tclExe
2180: 63 75 74 65 2e 63 09 54 68 75 20 53 65 70 20 32 cute.c.Thu Sep 2
2190: 38 20 32 30 3a 30 36 3a 34 32 20 32 30 30 36 0a 8 20:06:42 2006.
21a0: 2b 2b 2b 20 74 63 6c 2f 67 65 6e 65 72 69 63 2f +++ tcl/generic/
21b0: 74 63 6c 45 78 65 63 75 74 65 2e 63 09 53 75 6e tclExecute.c.Sun
21c0: 20 4f 63 74 20 32 39 20 31 30 3a 33 37 3a 32 38 Oct 29 10:37:28
21d0: 20 32 30 30 36 0a 40 40 20 2d 31 38 36 2c 31 31 2006.@@ -186,11
21e0: 20 2b 31 38 36 2c 31 34 20 40 40 0a 20 20 2a 2f +186,14 @@. */
21f0: 0a 20 0a 20 23 64 65 66 69 6e 65 20 43 41 43 48 . . #define CACH
2200: 45 5f 53 54 41 43 4b 5f 49 4e 46 4f 28 29 20 5c E_STACK_INFO() \
2210: 0a 2d 20 20 20 20 74 6f 73 50 74 72 20 3d 20 65 .- tosPtr = e
2220: 65 50 74 72 2d 3e 74 6f 73 50 74 72 0a 2b 20 20 ePtr->tosPtr.+
2230: 20 20 74 6f 73 50 74 72 20 3d 20 65 65 50 74 72 tosPtr = eePtr
2240: 2d 3e 74 6f 73 50 74 72 3b 5c 0a 2b 20 20 20 20 ->tosPtr;\.+
2250: 69 66 20 28 63 61 74 63 68 54 6f 70 20 21 3d 20 if (catchTop !=
2260: 69 6e 69 74 43 61 74 63 68 54 6f 70 29 20 69 50 initCatchTop) iP
2270: 74 72 2d 3e 63 61 74 63 68 4c 65 76 65 6c 2d 2d tr->catchLevel--
2280: 0a 20 0a 20 23 64 65 66 69 6e 65 20 44 45 43 41 . . #define DECA
2290: 43 48 45 5f 53 54 41 43 4b 5f 49 4e 46 4f 28 29 CHE_STACK_INFO()
22a0: 20 5c 0a 20 20 20 20 20 65 65 50 74 72 2d 3e 74 \. eePtr->t
22b0: 6f 73 50 74 72 20 3d 20 74 6f 73 50 74 72 3b 5c osPtr = tosPtr;\
22c0: 0a 2d 20 20 20 20 63 68 65 63 6b 49 6e 74 65 72 .- checkInter
22d0: 70 20 3d 20 31 0a 2b 20 20 20 20 63 68 65 63 6b p = 1.+ check
22e0: 49 6e 74 65 72 70 20 3d 20 31 3b 5c 0a 2b 20 20 Interp = 1;\.+
22f0: 20 20 69 66 20 28 63 61 74 63 68 54 6f 70 20 21 if (catchTop !
2300: 3d 20 69 6e 69 74 43 61 74 63 68 54 6f 70 29 20 = initCatchTop)
2310: 69 50 74 72 2d 3e 63 61 74 63 68 4c 65 76 65 6c iPtr->catchLevel
2320: 2b 2b 0a 2b 20 20 20 20 0a 20 0a 20 0a 20 2f 2a ++.+ . . . /*
2330: 0a 40 40 20 2d 31 37 39 36 2c 36 20 2b 31 37 39 .@@ -1796,6 +179
2340: 39 2c 31 34 20 40 40 0a 20 09 20 20 20 20 43 41 9,14 @@. . CA
2350: 43 48 45 5f 53 54 41 43 4b 5f 49 4e 46 4f 28 29 CHE_STACK_INFO()
2360: 3b 0a 20 0a 20 09 20 20 20 20 2f 2a 0a 2b 20 20 ;. . . /*.+
2370: 20 20 20 20 20 20 20 2a 20 45 4c 3a 20 72 65 73 * EL: res
2380: 65 74 20 74 68 65 20 45 52 52 48 41 4e 44 4c 45 et the ERRHANDLE
2390: 52 5f 46 49 4e 49 53 48 45 44 20 66 6c 61 67 20 R_FINISHED flag
23a0: 77 68 65 6e 20 77 65 20 61 72 65 20 61 74 20 74 when we are at t
23b0: 68 65 20 74 6f 70 20 6f 66 0a 2b 20 20 20 20 20 he top of.+
23c0: 20 20 20 20 2a 20 74 68 65 20 63 61 74 63 68 20 * the catch
23d0: 73 74 61 63 6b 0a 2b 20 20 20 20 20 20 20 20 20 stack.+
23e0: 2a 2f 0a 2b 20 20 20 20 20 20 20 20 69 66 20 28 */.+ if (
23f0: 63 61 74 63 68 54 6f 70 20 3c 20 30 29 20 7b 0a catchTop < 0) {.
2400: 2b 20 20 20 20 20 20 20 20 20 20 20 20 69 50 74 + iPt
2410: 72 2d 3e 65 72 72 6f 72 48 61 6e 64 6c 65 72 46 r->errorHandlerF
2420: 6c 61 67 73 20 26 3d 20 7e 45 52 52 48 41 4e 44 lags &= ~ERRHAND
2430: 4c 45 52 5f 46 49 4e 49 53 48 45 44 3b 0a 2b 20 LER_FINISHED;.+
2440: 20 20 20 20 20 20 20 7d 0a 2b 0a 2b 09 20 20 20 }.+.+.
2450: 20 2f 2a 0a 20 09 20 20 20 20 20 2a 20 49 66 20 /*. . * If
2460: 74 68 65 20 6f 6c 64 20 73 74 61 63 6b 20 69 73 the old stack is
2470: 20 67 6f 69 6e 67 20 74 6f 20 62 65 20 72 65 6c going to be rel
2480: 65 61 73 65 64 2c 20 69 74 20 69 73 20 73 61 66 eased, it is saf
2490: 65 20 74 6f 20 64 6f 20 73 6f 0a 20 09 20 20 20 e to do so. .
24a0: 20 20 2a 20 6e 6f 77 2c 20 73 69 6e 63 65 20 6e * now, since n
24b0: 6f 20 72 65 66 65 72 65 6e 63 65 73 20 74 6f 20 o references to
24c0: 6f 62 6a 76 20 61 72 65 20 67 6f 69 6e 67 20 74 objv are going t
24d0: 6f 20 62 65 20 75 73 65 64 20 66 72 6f 6d 20 6e o be used from n
24e0: 6f 77 0a 20 09 20 20 20 20 20 2a 20 6f 6e 2e 0a ow. . * on..
24f0: 64 69 66 66 20 2d 75 62 72 4e 20 74 63 6c 38 2e diff -ubrN tcl8.
2500: 35 61 35 2f 67 65 6e 65 72 69 63 2f 74 63 6c 49 5a5/generic/tclI
2510: 6e 74 2e 68 20 74 63 6c 2f 67 65 6e 65 72 69 63 nt.h tcl/generic
2520: 2f 74 63 6c 49 6e 74 2e 68 0a 2d 2d 2d 20 74 63 /tclInt.h.--- tc
2530: 6c 38 2e 35 61 35 2f 67 65 6e 65 72 69 63 2f 74 l8.5a5/generic/t
2540: 63 6c 49 6e 74 2e 68 09 53 61 74 20 53 65 70 20 clInt.h.Sat Sep
2550: 33 30 20 31 39 3a 30 30 3a 31 32 20 32 30 30 36 30 19:00:12 2006
2560: 0a 2b 2b 2b 20 74 63 6c 2f 67 65 6e 65 72 69 63 .+++ tcl/generic
2570: 2f 74 63 6c 49 6e 74 2e 68 09 53 75 6e 20 4f 63 /tclInt.h.Sun Oc
2580: 74 20 32 39 20 31 30 3a 33 39 3a 31 30 20 32 30 t 29 10:39:10 20
2590: 30 36 0a 40 40 20 2d 31 32 37 36 2c 36 20 2b 31 06.@@ -1276,6 +1
25a0: 32 37 36 2c 31 30 20 40 40 0a 20 20 2a 20 74 63 276,10 @@. * tc
25b0: 6c 42 61 73 69 63 2e 63 2c 20 62 75 74 20 61 6c lBasic.c, but al
25c0: 6d 6f 73 74 20 65 76 65 72 79 20 54 63 6c 20 73 most every Tcl s
25d0: 6f 75 72 63 65 20 66 69 6c 65 20 75 73 65 73 20 ource file uses
25e0: 73 6f 6d 65 74 68 69 6e 67 20 69 6e 20 68 65 72 something in her
25f0: 65 2e 0a 20 20 2a 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d e.. *----------
2600: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
2610: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
2620: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
2630: 2d 2d 2d 2d 2d 2d 0a 20 20 2a 2f 0a 2b 23 64 65 ------. */.+#de
2640: 66 69 6e 65 20 45 52 52 48 41 4e 44 4c 45 52 5f fine ERRHANDLER_
2650: 4f 4e 43 41 55 47 48 54 20 20 20 20 20 20 31 0a ONCAUGHT 1.
2660: 2b 23 64 65 66 69 6e 65 20 45 52 52 48 41 4e 44 +#define ERRHAND
2670: 4c 45 52 5f 4f 4e 55 4e 43 41 55 47 48 54 20 20 LER_ONUNCAUGHT
2680: 20 20 32 0a 2b 23 64 65 66 69 6e 65 20 45 52 52 2.+#define ERR
2690: 48 41 4e 44 4c 45 52 5f 46 49 4e 49 53 48 45 44 HANDLER_FINISHED
26a0: 20 20 20 20 34 0a 2b 23 64 65 66 69 6e 65 20 45 4.+#define E
26b0: 52 52 48 41 4e 44 4c 45 52 5f 52 55 4e 4e 49 4e RRHANDLER_RUNNIN
26c0: 47 20 20 20 20 20 38 0a 20 0a 20 74 79 70 65 64 G 8. . typed
26d0: 65 66 20 73 74 72 75 63 74 20 49 6e 74 65 72 70 ef struct Interp
26e0: 20 7b 0a 20 20 20 20 20 2f 2a 0a 40 40 20 2d 31 {. /*.@@ -1
26f0: 35 34 31 2c 36 20 2b 31 35 34 35 2c 31 35 20 40 541,6 +1545,15 @
2700: 40 0a 20 20 20 20 20 42 79 74 65 43 6f 64 65 53 @. ByteCodeS
2710: 74 61 74 73 20 73 74 61 74 73 3b 09 2f 2a 20 48 tats stats;./* H
2720: 6f 6c 64 73 20 63 6f 6d 70 69 6c 61 74 69 6f 6e olds compilation
2730: 20 61 6e 64 20 65 78 65 63 75 74 69 6f 6e 20 73 and execution s
2740: 74 61 74 69 73 74 69 63 73 0a 20 09 09 09 09 20 tatistics. ....
2750: 2a 20 66 6f 72 20 74 68 69 73 20 69 6e 74 65 72 * for this inter
2760: 70 72 65 74 65 72 2e 20 2a 2f 0a 20 23 65 6e 64 preter. */. #end
2770: 69 66 20 2f 2a 20 54 43 4c 5f 43 4f 4d 50 49 4c if /* TCL_COMPIL
2780: 45 5f 53 54 41 54 53 20 2a 2f 0a 2b 0a 2b 09 54 E_STATS */.+.+.T
2790: 63 6c 5f 4f 62 6a 2a 20 65 72 72 6f 72 48 61 6e cl_Obj* errorHan
27a0: 64 6c 65 72 3b 20 2f 2a 20 41 20 73 63 72 69 70 dler; /* A scrip
27b0: 74 20 74 68 61 74 20 69 73 20 65 78 65 63 75 74 t that is execut
27c0: 65 64 20 6f 6e 20 65 72 72 6f 72 73 20 2a 2f 0a ed on errors */.
27d0: 2b 09 69 6e 74 20 65 72 72 6f 72 48 61 6e 64 6c +.int errorHandl
27e0: 65 72 46 6c 61 67 73 3b 20 2f 2a 20 46 6c 61 67 erFlags; /* Flag
27f0: 73 20 66 6f 72 20 65 78 65 63 75 74 69 6e 67 20 s for executing
2800: 74 68 65 20 45 72 72 6f 72 20 53 63 72 69 70 74 the Error Script
2810: 2e 20 2a 2f 0a 2b 20 20 20 20 69 6e 74 20 63 61 . */.+ int ca
2820: 74 63 68 4c 65 76 65 6c 3b 20 2f 2a 20 4c 65 76 tchLevel; /* Lev
2830: 65 6c 20 6f 66 20 5b 63 61 74 63 68 5d 20 63 6f el of [catch] co
2840: 6d 6d 61 6e 64 73 20 2e 20 49 73 20 69 6e 63 72 mmands . Is incr
2850: 65 6d 65 6e 74 65 64 20 0a 2b 20 20 20 20 20 20 emented .+
2860: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
2870: 20 20 20 20 20 20 20 2a 20 6f 6e 20 65 61 63 68 * on each
2880: 20 65 6e 63 6f 75 6e 74 65 72 65 64 20 5b 63 61 encountered [ca
2890: 74 63 68 5d 2e 20 49 66 20 69 74 20 69 73 20 67 tch]. If it is g
28a0: 72 65 61 74 65 72 0a 2b 20 20 20 20 20 20 20 20 reater.+
28b0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
28c0: 20 20 20 20 20 2a 20 74 68 61 6e 20 30 20 64 75 * than 0 du
28d0: 72 69 6e 67 20 61 6e 20 65 72 72 6f 72 20 69 73 ring an error is
28e0: 20 74 68 72 6f 77 6e 20 74 68 69 73 20 6d 65 61 thrown this mea
28f0: 6e 73 20 74 68 61 74 0a 2b 20 20 20 20 20 20 20 ns that.+
2900: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
2910: 20 20 20 20 20 20 2a 20 74 68 65 20 65 72 72 6f * the erro
2920: 72 20 77 61 73 20 63 61 74 63 68 65 64 20 65 6c r was catched el
2930: 73 65 77 68 65 72 65 2e 20 57 65 20 63 61 6e 20 sewhere. We can
2940: 72 65 61 63 74 0a 2b 20 20 20 20 20 20 20 20 20 react.+
2950: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
2960: 20 20 20 20 2a 20 61 63 63 6f 72 64 69 6e 67 6c * accordingl
2970: 79 0a 2b 20 20 20 20 20 20 20 20 20 20 20 20 20 y.+
2980: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
2990: 2a 2f 0a 20 7d 20 49 6e 74 65 72 70 3b 0a 20 0a */. } Interp;. .
29a0: 20 2f 2a 0a 40 40 20 2d 32 33 30 36 2c 36 20 2b /*.@@ -2306,6 +
29b0: 32 33 31 39 2c 39 20 40 40 0a 20 09 09 09 20 20 2319,9 @@. ...
29c0: 20 20 54 63 6c 5f 54 69 6d 65 20 2a 74 69 6d 65 Tcl_Time *time
29d0: 50 74 72 2c 20 54 63 6c 5f 54 69 6d 65 72 50 72 Ptr, Tcl_TimerPr
29e0: 6f 63 20 2a 70 72 6f 63 2c 0a 20 09 09 09 20 20 oc *proc,. ...
29f0: 20 20 43 6c 69 65 6e 74 44 61 74 61 20 63 6c 69 ClientData cli
2a00: 65 6e 74 44 61 74 61 29 3b 0a 20 4d 4f 44 55 4c entData);. MODUL
2a10: 45 5f 53 43 4f 50 45 20 69 6e 74 09 54 63 6c 44 E_SCOPE int.TclD
2a20: 65 66 61 75 6c 74 42 67 45 72 72 6f 72 48 61 6e efaultBgErrorHan
2a30: 64 6c 65 72 4f 62 6a 43 6d 64 28 0a 2b 09 09 09 dlerObjCmd(.+...
2a40: 20 20 20 20 43 6c 69 65 6e 74 44 61 74 61 20 63 ClientData c
2a50: 6c 69 65 6e 74 44 61 74 61 2c 20 54 63 6c 5f 49 lientData, Tcl_I
2a60: 6e 74 65 72 70 20 2a 69 6e 74 65 72 70 2c 0a 2b nterp *interp,.+
2a70: 09 09 09 20 20 20 20 69 6e 74 20 6f 62 6a 63 2c ... int objc,
2a80: 20 54 63 6c 5f 4f 62 6a 20 2a 43 4f 4e 53 54 20 Tcl_Obj *CONST
2a90: 6f 62 6a 76 5b 5d 29 3b 0a 2b 4d 4f 44 55 4c 45 objv[]);.+MODULE
2aa0: 5f 53 43 4f 50 45 20 69 6e 74 09 54 63 6c 53 65 _SCOPE int.TclSe
2ab0: 74 45 72 72 6f 72 48 61 6e 64 6c 65 72 4f 62 6a tErrorHandlerObj
2ac0: 43 6d 64 28 0a 20 09 09 09 20 20 20 20 43 6c 69 Cmd(. ... Cli
2ad0: 65 6e 74 44 61 74 61 20 63 6c 69 65 6e 74 44 61 entData clientDa
2ae0: 74 61 2c 20 54 63 6c 5f 49 6e 74 65 72 70 20 2a ta, Tcl_Interp *
2af0: 69 6e 74 65 72 70 2c 0a 20 09 09 09 20 20 20 20 interp,. ...
2b00: 69 6e 74 20 6f 62 6a 63 2c 20 54 63 6c 5f 4f 62 int objc, Tcl_Ob
2b10: 6a 20 2a 43 4f 4e 53 54 20 6f 62 6a 76 5b 5d 29 j *CONST objv[])
2b20: 3b 0a 20 4d 4f 44 55 4c 45 5f 53 43 4f 50 45 20 ;. MODULE_SCOPE
2b30: 69 6e 74 09 54 63 6c 5f 44 69 63 74 4f 62 6a 43 int.Tcl_DictObjC
2b40: 6d 64 28 43 6c 69 65 6e 74 44 61 74 61 20 63 6c md(ClientData cl
2b50: 69 65 6e 74 44 61 74 61 2c 0a ientData,.