Attachment "290-4-20061106.diff" to
ticket [1587317fff]
added by
ecky-l
2006-11-07 02:56:00.
0000: 4f 6e 6c 79 20 69 6e 20 74 63 6c 2e 32 39 30 2f Only in tcl.290/
0010: 3a 20 2e 63 64 74 70 72 6f 6a 65 63 74 0a 4f 6e : .cdtproject.On
0020: 6c 79 20 69 6e 20 74 63 6c 2e 32 39 30 2f 3a 20 ly in tcl.290/:
0030: 2e 70 72 6f 6a 65 63 74 0a 4f 6e 6c 79 20 69 6e .project.Only in
0040: 20 74 63 6c 2e 32 39 30 2f 3a 20 2e 73 65 74 74 tcl.290/: .sett
0050: 69 6e 67 73 0a 64 69 66 66 20 2d 75 62 72 20 74 ings.diff -ubr t
0060: 63 6c 2e 6f 72 69 67 2f 67 65 6e 65 72 69 63 2f cl.orig/generic/
0070: 74 63 6c 42 61 73 69 63 2e 63 20 74 63 6c 2e 32 tclBasic.c tcl.2
0080: 39 30 2f 67 65 6e 65 72 69 63 2f 74 63 6c 42 61 90/generic/tclBa
0090: 73 69 63 2e 63 0a 2d 2d 2d 20 74 63 6c 2e 6f 72 sic.c.--- tcl.or
00a0: 69 67 2f 67 65 6e 65 72 69 63 2f 74 63 6c 42 61 ig/generic/tclBa
00b0: 73 69 63 2e 63 09 53 61 74 20 4e 6f 76 20 20 34 sic.c.Sat Nov 4
00c0: 20 30 30 3a 30 39 3a 33 33 20 32 30 30 36 0a 2b 00:09:33 2006.+
00d0: 2b 2b 20 74 63 6c 2e 32 39 30 2f 67 65 6e 65 72 ++ tcl.290/gener
00e0: 69 63 2f 74 63 6c 42 61 73 69 63 2e 63 09 53 61 ic/tclBasic.c.Sa
00f0: 74 20 4e 6f 76 20 20 34 20 31 36 3a 32 34 3a 31 t Nov 4 16:24:1
0100: 37 20 32 30 30 36 0a 40 40 20 2d 33 39 39 2c 36 7 2006.@@ -399,6
0110: 20 2b 33 39 39 2c 31 33 20 40 40 0a 20 20 20 20 +399,13 @@.
0120: 20 69 50 74 72 2d 3e 63 68 61 6e 4d 73 67 20 3d iPtr->chanMsg =
0130: 20 4e 55 4c 4c 3b 0a 20 0a 20 20 20 20 20 2f 2a NULL;. . /*
0140: 0a 2b 09 20 2a 20 54 49 50 20 32 39 30 3a 20 69 .+. * TIP 290: i
0150: 6e 69 74 69 61 6c 69 7a 65 20 74 68 65 20 65 78 nitialize the ex
0160: 63 65 70 74 69 6f 6e 43 6f 6d 6d 61 6e 64 20 61 ceptionCommand a
0170: 6e 64 20 65 78 63 65 70 74 69 6f 6e 43 6f 6d 6d nd exceptionComm
0180: 61 6e 64 46 6c 61 67 73 20 6d 65 6d 62 65 72 73 andFlags members
0190: 0a 2b 09 20 2a 2f 0a 2b 09 69 50 74 72 2d 3e 65 .+. */.+.iPtr->e
01a0: 78 63 65 70 74 69 6f 6e 43 6f 6d 6d 61 6e 64 20 xceptionCommand
01b0: 3d 20 4e 55 4c 4c 3b 0a 2b 09 69 50 74 72 2d 3e = NULL;.+.iPtr->
01c0: 65 78 63 65 70 74 69 6f 6e 43 6f 6d 6d 61 6e 64 exceptionCommand
01d0: 46 6c 61 67 73 20 3d 20 30 3b 0a 2b 20 20 20 20 Flags = 0;.+
01e0: 69 50 74 72 2d 3e 63 61 74 63 68 4c 65 76 65 6c iPtr->catchLevel
01f0: 20 3d 20 30 3b 0a 2b 09 0a 2b 20 20 20 20 2f 2a = 0;.+..+ /*
0200: 0a 20 20 20 20 20 20 2a 20 49 6e 69 74 69 61 6c . * Initial
0210: 69 7a 65 20 74 68 65 20 63 6f 6d 70 69 6c 61 74 ize the compilat
0220: 69 6f 6e 20 61 6e 64 20 65 78 65 63 75 74 69 6f ion and executio
0230: 6e 20 73 74 61 74 69 73 74 69 63 73 20 6b 65 70 n statistics kep
0240: 74 20 66 6f 72 20 74 68 69 73 0a 20 20 20 20 20 t for this.
0250: 20 2a 20 69 6e 74 65 72 70 72 65 74 65 72 2e 0a * interpreter..
0260: 20 20 20 20 20 20 2a 2f 0a 40 40 20 2d 33 35 31 */.@@ -351
0270: 39 2c 36 20 2b 33 35 32 36 2c 35 33 20 40 40 0a 9,6 +3526,53 @@.
0280: 20 20 20 20 20 69 66 20 28 73 61 76 65 64 56 61 if (savedVa
0290: 72 46 72 61 6d 65 50 74 72 29 20 7b 0a 20 09 69 rFramePtr) {. .i
02a0: 50 74 72 2d 3e 76 61 72 46 72 61 6d 65 50 74 72 Ptr->varFramePtr
02b0: 20 3d 20 73 61 76 65 64 56 61 72 46 72 61 6d 65 = savedVarFrame
02c0: 50 74 72 3b 0a 20 20 20 20 20 7d 0a 2b 0a 2b 20 Ptr;. }.+.+
02d0: 20 20 20 2f 2a 20 0a 2b 20 20 20 20 20 2a 20 54 /* .+ * T
02e0: 49 50 20 32 39 30 20 45 78 65 63 75 74 65 20 74 IP 290 Execute t
02f0: 68 65 20 65 78 63 65 70 74 48 61 6e 64 6c 65 72 he exceptHandler
0300: 20 74 68 61 74 20 77 61 73 20 72 65 67 69 73 74 that was regist
0310: 65 72 65 64 20 77 69 74 68 20 74 68 65 20 69 6e ered with the in
0320: 74 65 72 70 2e 0a 2b 20 20 20 20 20 2a 0a 2b 20 terp..+ *.+
0330: 20 20 20 20 2a 20 44 6f 20 74 68 69 73 20 6f 6e * Do this on
0340: 6c 79 20 69 66 20 74 68 65 20 65 72 72 6f 72 20 ly if the error
0350: 77 61 73 20 6e 6f 74 20 74 68 72 6f 77 6e 20 61 was not thrown a
0360: 6c 72 65 61 64 79 20 61 6e 64 20 64 65 70 65 6e lready and depen
0370: 64 65 6e 64 20 6f 6e 20 0a 2b 20 20 20 20 20 2a dend on .+ *
0380: 20 2d 63 61 75 67 68 74 2f 2d 75 6e 63 61 75 67 -caught/-uncaug
0390: 68 74 20 28 73 74 6f 72 65 64 20 69 6e 20 65 78 ht (stored in ex
03a0: 63 65 70 74 69 6f 6e 43 6f 6d 6d 61 6e 64 46 6c ceptionCommandFl
03b0: 61 67 73 29 2e 0a 2b 20 20 20 20 20 2a 0a 2b 20 ags)..+ *.+
03c0: 20 20 20 20 2a 20 54 68 65 20 72 65 74 75 72 6e * The return
03d0: 20 63 6f 64 65 20 6f 66 20 74 68 65 20 65 78 63 code of the exc
03e0: 65 70 74 69 6f 6e 20 61 6e 64 20 74 68 65 20 72 eption and the r
03f0: 65 73 75 6c 74 20 61 72 65 20 61 70 70 65 6e 64 esult are append
0400: 65 64 20 74 6f 20 74 68 65 0a 2b 20 20 20 20 20 ed to the.+
0410: 2a 20 63 6f 6d 6d 61 6e 64 20 62 65 66 6f 72 65 * command before
0420: 20 65 78 65 63 75 74 69 6f 6e 0a 2b 20 20 20 20 execution.+
0430: 20 2a 2f 0a 2b 20 20 20 20 69 66 20 28 63 6f 64 */.+ if (cod
0440: 65 20 21 3d 20 54 43 4c 5f 4f 4b 20 26 26 20 69 e != TCL_OK && i
0450: 50 74 72 2d 3e 65 78 63 65 70 74 69 6f 6e 43 6f Ptr->exceptionCo
0460: 6d 6d 61 6e 64 20 21 3d 20 4e 55 4c 4c 20 0a 2b mmand != NULL .+
0470: 20 20 20 20 20 20 20 20 20 20 20 20 26 26 20 21 && !
0480: 28 69 50 74 72 2d 3e 65 78 63 65 70 74 69 6f 6e (iPtr->exception
0490: 43 6f 6d 6d 61 6e 64 46 6c 61 67 73 20 26 20 45 CommandFlags & E
04a0: 58 43 45 50 54 43 4d 44 5f 46 49 4e 49 53 48 45 XCEPTCMD_FINISHE
04b0: 44 29 0a 2b 20 20 20 20 20 20 20 20 20 20 20 20 D).+
04c0: 26 26 20 21 28 69 50 74 72 2d 3e 65 78 63 65 70 && !(iPtr->excep
04d0: 74 69 6f 6e 43 6f 6d 6d 61 6e 64 46 6c 61 67 73 tionCommandFlags
04e0: 20 26 20 45 58 43 45 50 54 43 4d 44 5f 52 55 4e & EXCEPTCMD_RUN
04f0: 4e 49 4e 47 29 29 20 7b 0a 2b 0a 2b 20 20 20 20 NING)) {.+.+
0500: 20 20 20 20 69 6e 74 20 75 6e 63 61 74 63 68 65 int uncatche
0510: 64 20 3d 20 28 69 50 74 72 2d 3e 63 61 74 63 68 d = (iPtr->catch
0520: 4c 65 76 65 6c 20 3c 3d 20 30 20 0a 2b 20 20 20 Level <= 0 .+
0530: 20 20 20 20 20 20 20 20 20 26 26 20 28 69 50 74 && (iPt
0540: 72 2d 3e 65 78 63 65 70 74 69 6f 6e 43 6f 6d 6d r->exceptionComm
0550: 61 6e 64 46 6c 61 67 73 20 26 20 45 58 43 45 50 andFlags & EXCEP
0560: 54 43 4d 44 5f 4f 4e 55 4e 43 41 55 47 48 54 29 TCMD_ONUNCAUGHT)
0570: 29 3b 20 0a 2b 20 20 20 20 20 20 20 20 69 6e 74 ); .+ int
0580: 20 63 61 74 63 68 65 64 20 3d 20 28 69 50 74 72 catched = (iPtr
0590: 2d 3e 63 61 74 63 68 4c 65 76 65 6c 20 3e 20 30 ->catchLevel > 0
05a0: 20 0a 2b 20 20 20 20 20 20 20 20 20 20 20 20 26 .+ &
05b0: 26 20 28 69 50 74 72 2d 3e 65 78 63 65 70 74 69 & (iPtr->excepti
05c0: 6f 6e 43 6f 6d 6d 61 6e 64 46 6c 61 67 73 20 26 onCommandFlags &
05d0: 20 45 58 43 45 50 54 43 4d 44 5f 4f 4e 43 41 55 EXCEPTCMD_ONCAU
05e0: 47 48 54 29 29 3b 0a 2b 20 20 20 20 20 20 20 20 GHT));.+
05f0: 69 66 20 28 75 6e 63 61 74 63 68 65 64 20 7c 7c if (uncatched ||
0600: 20 63 61 74 63 68 65 64 29 20 7b 0a 2b 20 20 20 catched) {.+
0610: 20 20 20 20 20 20 20 20 20 54 63 6c 5f 44 53 74 Tcl_DSt
0620: 72 69 6e 67 20 63 6d 64 42 75 66 3b 0a 2b 20 20 ring cmdBuf;.+
0630: 20 20 20 20 20 20 20 20 20 20 69 6e 74 20 69 2c int i,
0640: 20 63 6d 64 4c 65 6e 3b 0a 2b 20 20 20 20 20 20 cmdLen;.+
0650: 20 20 20 20 20 20 63 68 61 72 20 2a 63 6d 64 53 char *cmdS
0660: 74 72 69 6e 67 3b 0a 2b 20 20 20 20 20 20 20 20 tring;.+
0670: 20 20 20 20 54 63 6c 5f 4f 62 6a 20 2a 65 78 63 Tcl_Obj *exc
0680: 65 70 74 43 6d 64 20 3d 20 54 63 6c 5f 44 75 70 eptCmd = Tcl_Dup
0690: 6c 69 63 61 74 65 4f 62 6a 28 69 50 74 72 2d 3e licateObj(iPtr->
06a0: 65 78 63 65 70 74 69 6f 6e 43 6f 6d 6d 61 6e 64 exceptionCommand
06b0: 29 3b 0a 2b 20 20 20 20 20 20 20 20 20 20 20 20 );.+
06c0: 54 63 6c 5f 4c 69 73 74 4f 62 6a 41 70 70 65 6e Tcl_ListObjAppen
06d0: 64 45 6c 65 6d 65 6e 74 20 28 69 6e 74 65 72 70 dElement (interp
06e0: 2c 20 65 78 63 65 70 74 43 6d 64 2c 20 54 63 6c , exceptCmd, Tcl
06f0: 5f 4e 65 77 49 6e 74 4f 62 6a 28 63 6f 64 65 29 _NewIntObj(code)
0700: 29 3b 0a 2b 20 20 20 20 20 20 20 20 20 20 20 20 );.+
0710: 54 63 6c 5f 4c 69 73 74 4f 62 6a 41 70 70 65 6e Tcl_ListObjAppen
0720: 64 45 6c 65 6d 65 6e 74 20 28 69 6e 74 65 72 70 dElement (interp
0730: 2c 20 65 78 63 65 70 74 43 6d 64 2c 20 54 63 6c , exceptCmd, Tcl
0740: 5f 47 65 74 4f 62 6a 52 65 73 75 6c 74 28 69 6e _GetObjResult(in
0750: 74 65 72 70 29 29 3b 0a 2b 20 20 20 20 20 20 20 terp));.+
0760: 20 20 20 20 20 0a 2b 20 20 20 20 20 20 20 20 20 .+
0770: 20 20 20 2f 2a 20 4c 6f 67 20 74 68 65 20 65 72 /* Log the er
0780: 72 6f 72 2c 20 73 6f 20 74 68 61 74 20 69 74 20 ror, so that it
0790: 69 73 20 61 76 61 69 6c 61 62 6c 65 20 69 6e 20 is available in
07a0: 74 68 65 20 68 61 6e 64 6c 65 72 20 2a 2f 0a 2b the handler */.+
07b0: 20 20 20 20 20 20 20 20 20 20 20 20 54 63 6c 5f Tcl_
07c0: 44 53 74 72 69 6e 67 49 6e 69 74 28 26 63 6d 64 DStringInit(&cmd
07d0: 42 75 66 29 3b 0a 2b 20 20 20 20 20 20 20 20 20 Buf);.+
07e0: 20 20 20 66 6f 72 20 28 69 20 3d 20 30 3b 20 69 for (i = 0; i
07f0: 20 3c 20 6f 62 6a 63 3b 20 69 2b 2b 29 20 7b 0a < objc; i++) {.
0800: 2b 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 +
0810: 20 54 63 6c 5f 44 53 74 72 69 6e 67 41 70 70 65 Tcl_DStringAppe
0820: 6e 64 45 6c 65 6d 65 6e 74 28 26 63 6d 64 42 75 ndElement(&cmdBu
0830: 66 2c 20 54 63 6c 5f 47 65 74 53 74 72 69 6e 67 f, Tcl_GetString
0840: 28 6f 62 6a 76 5b 69 5d 29 29 3b 0a 2b 20 20 20 (objv[i]));.+
0850: 20 20 20 20 20 20 20 20 20 7d 0a 2b 20 20 20 20 }.+
0860: 20 20 20 20 20 20 20 20 63 6d 64 53 74 72 69 6e cmdStrin
0870: 67 20 3d 20 54 63 6c 5f 44 53 74 72 69 6e 67 56 g = Tcl_DStringV
0880: 61 6c 75 65 28 26 63 6d 64 42 75 66 29 3b 0a 2b alue(&cmdBuf);.+
0890: 20 20 20 20 20 20 20 20 20 20 20 20 63 6d 64 4c cmdL
08a0: 65 6e 20 3d 20 54 63 6c 5f 44 53 74 72 69 6e 67 en = Tcl_DString
08b0: 4c 65 6e 67 74 68 28 26 63 6d 64 42 75 66 29 3b Length(&cmdBuf);
08c0: 0a 2b 20 20 20 20 20 20 20 20 20 20 20 20 54 63 .+ Tc
08d0: 6c 5f 4c 6f 67 43 6f 6d 6d 61 6e 64 49 6e 66 6f l_LogCommandInfo
08e0: 28 69 6e 74 65 72 70 2c 20 63 6d 64 53 74 72 69 (interp, cmdStri
08f0: 6e 67 2c 20 63 6d 64 53 74 72 69 6e 67 2c 20 63 ng, cmdString, c
0900: 6d 64 4c 65 6e 29 3b 0a 2b 20 20 20 20 20 20 20 mdLen);.+
0910: 20 20 20 20 20 0a 2b 20 20 20 20 20 20 20 20 20 .+
0920: 20 20 20 69 50 74 72 2d 3e 65 78 63 65 70 74 69 iPtr->excepti
0930: 6f 6e 43 6f 6d 6d 61 6e 64 46 6c 61 67 73 20 7c onCommandFlags |
0940: 3d 20 45 58 43 45 50 54 43 4d 44 5f 52 55 4e 4e = EXCEPTCMD_RUNN
0950: 49 4e 47 3b 0a 2b 20 20 20 20 20 20 20 20 20 20 ING;.+
0960: 20 20 63 6f 64 65 20 3d 20 54 63 6c 5f 45 76 61 code = Tcl_Eva
0970: 6c 4f 62 6a 28 69 6e 74 65 72 70 2c 20 65 78 63 lObj(interp, exc
0980: 65 70 74 43 6d 64 29 3b 0a 2b 20 20 20 20 20 20 eptCmd);.+
0990: 20 20 20 20 20 20 69 50 74 72 2d 3e 65 78 63 65 iPtr->exce
09a0: 70 74 69 6f 6e 43 6f 6d 6d 61 6e 64 46 6c 61 67 ptionCommandFlag
09b0: 73 20 26 3d 20 7e 45 58 43 45 50 54 43 4d 44 5f s &= ~EXCEPTCMD_
09c0: 52 55 4e 4e 49 4e 47 3b 0a 2b 20 20 20 20 20 20 RUNNING;.+
09d0: 20 20 20 20 20 20 69 50 74 72 2d 3e 65 78 63 65 iPtr->exce
09e0: 70 74 69 6f 6e 43 6f 6d 6d 61 6e 64 46 6c 61 67 ptionCommandFlag
09f0: 73 20 7c 3d 20 45 58 43 45 50 54 43 4d 44 5f 46 s |= EXCEPTCMD_F
0a00: 49 4e 49 53 48 45 44 3b 0a 2b 20 20 20 20 20 20 INISHED;.+
0a10: 20 20 20 20 20 20 0a 2b 20 20 20 20 20 20 20 20 .+
0a20: 20 20 20 20 69 66 20 28 63 6d 64 4c 65 6e 20 21 if (cmdLen !
0a30: 3d 20 30 29 20 7b 0a 2b 20 20 20 20 20 20 20 20 = 0) {.+
0a40: 20 20 20 20 20 20 20 20 54 63 6c 5f 44 53 74 72 Tcl_DStr
0a50: 69 6e 67 46 72 65 65 28 26 63 6d 64 42 75 66 29 ingFree(&cmdBuf)
0a60: 3b 0a 2b 20 20 20 20 20 20 20 20 20 20 20 20 7d ;.+ }
0a70: 0a 2b 20 20 20 20 20 20 20 20 20 20 20 20 0a 2b .+ .+
0a80: 20 20 20 20 20 20 20 20 7d 0a 2b 20 20 20 20 7d }.+ }
0a90: 0a 2b 0a 20 20 20 20 20 72 65 74 75 72 6e 20 63 .+. return c
0aa0: 6f 64 65 3b 0a 20 7d 0a 20 0c 0a 64 69 66 66 20 ode;. }. ..diff
0ab0: 2d 75 62 72 20 74 63 6c 2e 6f 72 69 67 2f 67 65 -ubr tcl.orig/ge
0ac0: 6e 65 72 69 63 2f 74 63 6c 43 6d 64 41 48 2e 63 neric/tclCmdAH.c
0ad0: 20 74 63 6c 2e 32 39 30 2f 67 65 6e 65 72 69 63 tcl.290/generic
0ae0: 2f 74 63 6c 43 6d 64 41 48 2e 63 0a 2d 2d 2d 20 /tclCmdAH.c.---
0af0: 74 63 6c 2e 6f 72 69 67 2f 67 65 6e 65 72 69 63 tcl.orig/generic
0b00: 2f 74 63 6c 43 6d 64 41 48 2e 63 09 54 68 75 20 /tclCmdAH.c.Thu
0b10: 4e 6f 76 20 20 32 20 31 36 3a 35 37 3a 35 34 20 Nov 2 16:57:54
0b20: 32 30 30 36 0a 2b 2b 2b 20 74 63 6c 2e 32 39 30 2006.+++ tcl.290
0b30: 2f 67 65 6e 65 72 69 63 2f 74 63 6c 43 6d 64 41 /generic/tclCmdA
0b40: 48 2e 63 09 53 61 74 20 4e 6f 76 20 20 34 20 31 H.c.Sat Nov 4 1
0b50: 33 3a 31 33 3a 35 30 20 32 30 30 36 0a 40 40 20 3:13:50 2006.@@
0b60: 2d 32 32 39 2c 36 20 2b 32 32 39 2c 37 20 40 40 -229,6 +229,7 @@
0b70: 0a 20 7b 0a 20 20 20 20 20 54 63 6c 5f 4f 62 6a . {. Tcl_Obj
0b80: 20 2a 76 61 72 4e 61 6d 65 50 74 72 20 3d 20 4e *varNamePtr = N
0b90: 55 4c 4c 3b 0a 20 20 20 20 20 54 63 6c 5f 4f 62 ULL;. Tcl_Ob
0ba0: 6a 20 2a 6f 70 74 69 6f 6e 56 61 72 4e 61 6d 65 j *optionVarName
0bb0: 50 74 72 20 3d 20 4e 55 4c 4c 3b 0a 2b 20 20 20 Ptr = NULL;.+
0bc0: 20 49 6e 74 65 72 70 20 2a 69 50 74 72 20 3d 20 Interp *iPtr =
0bd0: 28 49 6e 74 65 72 70 2a 29 69 6e 74 65 72 70 3b (Interp*)interp;
0be0: 0a 20 20 20 20 20 69 6e 74 20 72 65 73 75 6c 74 . int result
0bf0: 3b 0a 20 0a 20 20 20 20 20 69 66 20 28 28 6f 62 ;. . if ((ob
0c00: 6a 63 20 3c 20 32 29 20 7c 7c 20 28 6f 62 6a 63 jc < 2) || (objc
0c10: 20 3e 20 34 29 29 20 7b 0a 40 40 20 2d 32 34 34 > 4)) {.@@ -244
0c20: 2c 37 20 2b 32 34 35 2c 39 20 40 40 0a 20 09 6f ,7 +245,9 @@. .o
0c30: 70 74 69 6f 6e 56 61 72 4e 61 6d 65 50 74 72 20 ptionVarNamePtr
0c40: 3d 20 6f 62 6a 76 5b 33 5d 3b 0a 20 20 20 20 20 = objv[3];.
0c50: 7d 0a 20 0a 2b 20 20 20 20 69 50 74 72 2d 3e 63 }. .+ iPtr->c
0c60: 61 74 63 68 4c 65 76 65 6c 2b 2b 3b 0a 20 20 20 atchLevel++;.
0c70: 20 20 72 65 73 75 6c 74 20 3d 20 54 63 6c 5f 45 result = Tcl_E
0c80: 76 61 6c 4f 62 6a 45 78 28 69 6e 74 65 72 70 2c valObjEx(interp,
0c90: 20 6f 62 6a 76 5b 31 5d 2c 20 30 29 3b 0a 2b 20 objv[1], 0);.+
0ca0: 20 20 20 69 50 74 72 2d 3e 63 61 74 63 68 4c 65 iPtr->catchLe
0cb0: 76 65 6c 2d 2d 3b 0a 20 0a 20 20 20 20 20 2f 2a vel--;. . /*
0cc0: 0a 20 20 20 20 20 20 2a 20 57 65 20 64 69 73 61 . * We disa
0cd0: 62 6c 65 20 63 61 74 63 68 20 69 6e 20 69 6e 74 ble catch in int
0ce0: 65 72 70 72 65 74 65 72 73 20 77 68 65 72 65 20 erpreters where
0cf0: 74 68 65 20 6c 69 6d 69 74 20 68 61 73 20 62 65 the limit has be
0d00: 65 6e 20 65 78 63 65 65 64 65 64 2e 0a 64 69 66 en exceeded..dif
0d10: 66 20 2d 75 62 72 20 74 63 6c 2e 6f 72 69 67 2f f -ubr tcl.orig/
0d20: 67 65 6e 65 72 69 63 2f 74 63 6c 45 76 65 6e 74 generic/tclEvent
0d30: 2e 63 20 74 63 6c 2e 32 39 30 2f 67 65 6e 65 72 .c tcl.290/gener
0d40: 69 63 2f 74 63 6c 45 76 65 6e 74 2e 63 0a 2d 2d ic/tclEvent.c.--
0d50: 2d 20 74 63 6c 2e 6f 72 69 67 2f 67 65 6e 65 72 - tcl.orig/gener
0d60: 69 63 2f 74 63 6c 45 76 65 6e 74 2e 63 09 54 75 ic/tclEvent.c.Tu
0d70: 65 20 53 65 70 20 31 39 20 32 32 3a 30 37 3a 33 e Sep 19 22:07:3
0d80: 34 20 32 30 30 36 0a 2b 2b 2b 20 74 63 6c 2e 32 4 2006.+++ tcl.2
0d90: 39 30 2f 67 65 6e 65 72 69 63 2f 74 63 6c 45 76 90/generic/tclEv
0da0: 65 6e 74 2e 63 09 53 61 74 20 4e 6f 76 20 20 34 ent.c.Sat Nov 4
0db0: 20 31 36 3a 30 37 3a 33 34 20 32 30 30 36 0a 40 16:07:34 2006.@
0dc0: 40 20 2d 33 38 30 2c 36 20 2b 33 38 30 2c 37 20 @ -380,6 +380,7
0dd0: 40 40 0a 20 20 20 20 20 72 65 74 75 72 6e 20 63 @@. return c
0de0: 6f 64 65 3b 0a 20 7d 0a 20 0c 0a 2b 0a 20 2f 2a ode;. }. ..+. /*
0df0: 0a 20 20 2a 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d . *------------
0e00: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
0e10: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
0e20: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
0e30: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0a 20 20 2a 0a 64 ----------. *.d
0e40: 69 66 66 20 2d 75 62 72 20 74 63 6c 2e 6f 72 69 iff -ubr tcl.ori
0e50: 67 2f 67 65 6e 65 72 69 63 2f 74 63 6c 45 78 65 g/generic/tclExe
0e60: 63 75 74 65 2e 63 20 74 63 6c 2e 32 39 30 2f 67 cute.c tcl.290/g
0e70: 65 6e 65 72 69 63 2f 74 63 6c 45 78 65 63 75 74 eneric/tclExecut
0e80: 65 2e 63 0a 2d 2d 2d 20 74 63 6c 2e 6f 72 69 67 e.c.--- tcl.orig
0e90: 2f 67 65 6e 65 72 69 63 2f 74 63 6c 45 78 65 63 /generic/tclExec
0ea0: 75 74 65 2e 63 09 54 68 75 20 4e 6f 76 20 20 32 ute.c.Thu Nov 2
0eb0: 20 31 35 3a 35 38 3a 30 38 20 32 30 30 36 0a 2b 15:58:08 2006.+
0ec0: 2b 2b 20 74 63 6c 2e 32 39 30 2f 67 65 6e 65 72 ++ tcl.290/gener
0ed0: 69 63 2f 74 63 6c 45 78 65 63 75 74 65 2e 63 09 ic/tclExecute.c.
0ee0: 53 61 74 20 4e 6f 76 20 20 34 20 31 36 3a 31 32 Sat Nov 4 16:12
0ef0: 3a 32 35 20 32 30 30 36 0a 40 40 20 2d 31 38 33 :25 2006.@@ -183
0f00: 2c 31 34 20 2b 31 38 33 2c 31 39 20 40 40 0a 20 ,14 +183,19 @@.
0f10: 20 2a 20 70 61 69 72 20 6d 75 73 74 20 73 75 72 * pair must sur
0f20: 72 6f 75 6e 64 20 61 6e 79 20 63 61 6c 6c 20 69 round any call i
0f30: 6e 73 69 64 65 20 54 63 6c 45 78 65 63 75 74 65 nside TclExecute
0f40: 42 79 74 65 43 6f 64 65 20 28 61 6e 64 20 61 20 ByteCode (and a
0f50: 66 65 77 20 6f 74 68 65 72 0a 20 20 2a 20 70 72 few other. * pr
0f60: 6f 63 65 64 75 72 65 73 20 74 68 61 74 20 75 73 ocedures that us
0f70: 65 20 74 68 69 73 20 73 63 68 65 6d 65 29 20 74 e this scheme) t
0f80: 68 61 74 20 63 6f 75 6c 64 20 72 65 73 75 6c 74 hat could result
0f90: 20 69 6e 20 61 20 72 65 63 75 72 73 69 76 65 20 in a recursive
0fa0: 63 61 6c 6c 0a 20 20 2a 20 74 6f 20 54 63 6c 45 call. * to TclE
0fb0: 78 65 63 75 74 65 42 79 74 65 43 6f 64 65 2e 0a xecuteByteCode..
0fc0: 2b 20 2a 20 0a 2b 20 2a 20 54 49 50 20 32 39 30 + * .+ * TIP 290
0fd0: 3a 20 6b 65 65 70 20 74 68 65 20 63 61 74 63 68 : keep the catch
0fe0: 20 6c 65 76 65 6c 20 69 66 20 6e 65 63 65 73 73 level if necess
0ff0: 61 72 79 0a 20 20 2a 2f 0a 20 0a 20 23 64 65 66 ary. */. . #def
1000: 69 6e 65 20 43 41 43 48 45 5f 53 54 41 43 4b 5f ine CACHE_STACK_
1010: 49 4e 46 4f 28 29 20 5c 0a 2d 20 20 20 20 74 6f INFO() \.- to
1020: 73 50 74 72 20 3d 20 65 65 50 74 72 2d 3e 74 6f sPtr = eePtr->to
1030: 73 50 74 72 0a 2b 20 20 20 20 74 6f 73 50 74 72 sPtr.+ tosPtr
1040: 20 3d 20 65 65 50 74 72 2d 3e 74 6f 73 50 74 72 = eePtr->tosPtr
1050: 3b 5c 0a 2b 20 20 20 20 69 66 20 28 63 61 74 63 ;\.+ if (catc
1060: 68 54 6f 70 20 21 3d 20 69 6e 69 74 43 61 74 63 hTop != initCatc
1070: 68 54 6f 70 29 20 69 50 74 72 2d 3e 63 61 74 63 hTop) iPtr->catc
1080: 68 4c 65 76 65 6c 2d 2d 0a 20 0a 20 23 64 65 66 hLevel--. . #def
1090: 69 6e 65 20 44 45 43 41 43 48 45 5f 53 54 41 43 ine DECACHE_STAC
10a0: 4b 5f 49 4e 46 4f 28 29 20 5c 0a 20 20 20 20 20 K_INFO() \.
10b0: 65 65 50 74 72 2d 3e 74 6f 73 50 74 72 20 3d 20 eePtr->tosPtr =
10c0: 74 6f 73 50 74 72 3b 5c 0a 2d 20 20 20 20 63 68 tosPtr;\.- ch
10d0: 65 63 6b 49 6e 74 65 72 70 20 3d 20 31 0a 2b 20 eckInterp = 1.+
10e0: 20 20 20 63 68 65 63 6b 49 6e 74 65 72 70 20 3d checkInterp =
10f0: 20 31 3b 5c 0a 2b 20 20 20 20 69 66 20 28 63 61 1;\.+ if (ca
1100: 74 63 68 54 6f 70 20 21 3d 20 69 6e 69 74 43 61 tchTop != initCa
1110: 74 63 68 54 6f 70 29 20 69 50 74 72 2d 3e 63 61 tchTop) iPtr->ca
1120: 74 63 68 4c 65 76 65 6c 2b 2b 0a 2b 20 20 20 20 tchLevel++.+
1130: 0a 20 0a 20 0a 20 2f 2a 0a 40 40 20 2d 31 37 39 . . . /*.@@ -179
1140: 34 2c 36 20 2b 31 37 39 39 2c 31 33 20 40 40 0a 4,6 +1799,13 @@.
1150: 20 09 20 20 20 20 2f 2a 54 63 6c 5f 52 65 73 65 . /*Tcl_Rese
1160: 74 52 65 73 75 6c 74 28 69 6e 74 65 72 70 29 3b tResult(interp);
1170: 2a 2f 0a 20 09 20 20 20 20 72 65 73 75 6c 74 20 */. . result
1180: 3d 20 54 63 6c 45 76 61 6c 4f 62 6a 76 49 6e 74 = TclEvalObjvInt
1190: 65 72 6e 61 6c 28 69 6e 74 65 72 70 2c 20 6f 62 ernal(interp, ob
11a0: 6a 63 2c 20 6f 62 6a 76 2c 20 62 79 74 65 73 2c jc, objv, bytes,
11b0: 20 6c 65 6e 67 74 68 2c 20 30 29 3b 0a 20 09 20 length, 0);. .
11c0: 20 20 20 43 41 43 48 45 5f 53 54 41 43 4b 5f 49 CACHE_STACK_I
11d0: 4e 46 4f 28 29 3b 0a 2b 0a 2b 09 20 20 20 20 2f NFO();.+.+. /
11e0: 2a 0a 2b 20 20 20 20 20 20 20 20 20 2a 20 54 49 *.+ * TI
11f0: 50 20 32 39 30 3a 20 72 65 73 65 74 20 74 68 65 P 290: reset the
1200: 20 45 58 43 45 50 54 43 4d 44 5f 46 49 4e 49 53 EXCEPTCMD_FINIS
1210: 48 45 44 20 66 6c 61 67 20 74 68 65 20 74 6f 70 HED flag the top
1220: 20 6f 66 20 63 61 74 63 68 20 73 74 61 63 6b 0a of catch stack.
1230: 2b 20 20 20 20 20 20 20 20 20 2a 2f 0a 2b 20 20 + */.+
1240: 20 20 20 20 20 20 69 66 20 28 63 61 74 63 68 54 if (catchT
1250: 6f 70 20 3c 20 30 29 20 7b 0a 2b 20 20 20 20 20 op < 0) {.+
1260: 20 20 20 20 20 20 20 69 50 74 72 2d 3e 65 78 63 iPtr->exc
1270: 65 70 74 69 6f 6e 43 6f 6d 6d 61 6e 64 46 6c 61 eptionCommandFla
1280: 67 73 20 26 3d 20 7e 45 58 43 45 50 54 43 4d 44 gs &= ~EXCEPTCMD
1290: 5f 46 49 4e 49 53 48 45 44 3b 0a 2b 20 20 20 20 _FINISHED;.+
12a0: 20 20 20 20 7d 0a 20 0a 20 09 20 20 20 20 2f 2a }. . . /*
12b0: 0a 20 09 20 20 20 20 20 2a 20 49 66 20 74 68 65 . . * If the
12c0: 20 6f 6c 64 20 73 74 61 63 6b 20 69 73 20 67 6f old stack is go
12d0: 69 6e 67 20 74 6f 20 62 65 20 72 65 6c 65 61 73 ing to be releas
12e0: 65 64 2c 20 69 74 20 69 73 20 73 61 66 65 20 74 ed, it is safe t
12f0: 6f 20 64 6f 20 73 6f 0a 64 69 66 66 20 2d 75 62 o do so.diff -ub
1300: 72 20 74 63 6c 2e 6f 72 69 67 2f 67 65 6e 65 72 r tcl.orig/gener
1310: 69 63 2f 74 63 6c 49 6e 74 2e 68 20 74 63 6c 2e ic/tclInt.h tcl.
1320: 32 39 30 2f 67 65 6e 65 72 69 63 2f 74 63 6c 49 290/generic/tclI
1330: 6e 74 2e 68 0a 2d 2d 2d 20 74 63 6c 2e 6f 72 69 nt.h.--- tcl.ori
1340: 67 2f 67 65 6e 65 72 69 63 2f 74 63 6c 49 6e 74 g/generic/tclInt
1350: 2e 68 09 54 68 75 20 4e 6f 76 20 20 32 20 31 36 .h.Thu Nov 2 16
1360: 3a 35 37 3a 35 34 20 32 30 30 36 0a 2b 2b 2b 20 :57:54 2006.+++
1370: 74 63 6c 2e 32 39 30 2f 67 65 6e 65 72 69 63 2f tcl.290/generic/
1380: 74 63 6c 49 6e 74 2e 68 09 53 61 74 20 4e 6f 76 tclInt.h.Sat Nov
1390: 20 20 34 20 31 36 3a 30 39 3a 34 33 20 32 30 30 4 16:09:43 200
13a0: 36 0a 40 40 20 2d 31 32 38 35 2c 36 20 2b 31 32 6.@@ -1285,6 +12
13b0: 38 35 2c 31 34 20 40 40 0a 20 7d 3b 0a 20 0a 20 85,14 @@. };. .
13c0: 2f 2a 0a 2b 20 2a 20 54 49 50 20 32 39 30 20 46 /*.+ * TIP 290 F
13d0: 6c 61 67 73 20 66 6f 72 20 72 75 6e 6e 69 6e 67 lags for running
13e0: 20 61 6e 20 65 78 63 65 70 74 69 6f 6e 20 63 6f an exception co
13f0: 6d 6d 61 6e 64 0a 2b 20 2a 2f 20 0a 2b 23 64 65 mmand.+ */ .+#de
1400: 66 69 6e 65 20 45 58 43 45 50 54 43 4d 44 5f 4f fine EXCEPTCMD_O
1410: 4e 43 41 55 47 48 54 20 20 20 20 20 20 31 20 2f NCAUGHT 1 /
1420: 2a 20 52 75 6e 20 74 68 65 20 63 6f 6d 6d 61 6e * Run the comman
1430: 64 20 6f 6e 20 63 61 75 67 68 74 20 65 78 63 65 d on caught exce
1440: 70 74 69 6f 6e 73 20 2a 2f 0a 2b 23 64 65 66 69 ptions */.+#defi
1450: 6e 65 20 45 58 43 45 50 54 43 4d 44 5f 4f 4e 55 ne EXCEPTCMD_ONU
1460: 4e 43 41 55 47 48 54 20 20 20 20 32 20 2f 2a 20 NCAUGHT 2 /*
1470: 52 75 6e 20 74 68 65 20 63 6f 6d 6d 61 6e 64 20 Run the command
1480: 6f 6e 20 75 6e 63 61 75 67 68 74 20 65 78 63 65 on uncaught exce
1490: 70 74 69 6f 6e 73 20 2a 2f 0a 2b 23 64 65 66 69 ptions */.+#defi
14a0: 6e 65 20 45 58 43 45 50 54 43 4d 44 5f 46 49 4e ne EXCEPTCMD_FIN
14b0: 49 53 48 45 44 20 20 20 20 34 20 2f 2a 20 69 6e ISHED 4 /* in
14c0: 64 69 63 61 74 65 73 20 74 68 61 74 20 74 68 65 dicates that the
14d0: 20 63 6f 6d 6d 61 6e 64 20 68 61 73 20 62 65 65 command has bee
14e0: 6e 20 72 75 6e 20 66 6f 72 20 61 20 70 61 72 74 n run for a part
14f0: 69 63 75 6c 61 72 20 65 78 63 65 70 74 69 6f 6e icular exception
1500: 20 2a 2f 0a 2b 23 64 65 66 69 6e 65 20 45 58 43 */.+#define EXC
1510: 45 50 54 43 4d 44 5f 52 55 4e 4e 49 4e 47 20 20 EPTCMD_RUNNING
1520: 20 20 20 38 20 2f 2a 20 69 6e 64 69 63 61 74 65 8 /* indicate
1530: 73 20 74 68 61 74 20 74 68 65 20 65 78 63 65 70 s that the excep
1540: 74 69 6f 6e 20 63 6f 6d 6d 61 6e 64 20 69 73 20 tion command is
1550: 63 75 72 72 65 6e 74 6c 79 20 72 75 6e 6e 69 6e currently runnin
1560: 67 20 2a 2f 0a 2b 0a 2b 2f 2a 0a 20 20 2a 2d 2d g */.+.+/*. *--
1570: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
1580: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
1590: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
15a0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0a 20 --------------.
15b0: 20 2a 20 54 68 69 73 20 73 74 72 75 63 74 75 72 * This structur
15c0: 65 20 64 65 66 69 6e 65 73 20 61 6e 20 69 6e 74 e defines an int
15d0: 65 72 70 72 65 74 65 72 2c 20 77 68 69 63 68 20 erpreter, which
15e0: 69 73 20 61 20 63 6f 6c 6c 65 63 74 69 6f 6e 20 is a collection
15f0: 6f 66 20 63 6f 6d 6d 61 6e 64 73 0a 20 20 2a 20 of commands. *
1600: 70 6c 75 73 20 6f 74 68 65 72 20 73 74 61 74 65 plus other state
1610: 20 69 6e 66 6f 72 6d 61 74 69 6f 6e 20 72 65 6c information rel
1620: 61 74 65 64 20 74 6f 20 69 6e 74 65 72 70 72 65 ated to interpre
1630: 74 69 6e 67 20 63 6f 6d 6d 61 6e 64 73 2c 20 73 ting commands, s
1640: 75 63 68 20 61 73 0a 40 40 20 2d 31 32 39 32 2c uch as.@@ -1292,
1650: 37 20 2b 31 33 30 30 2c 36 20 40 40 0a 20 20 2a 7 +1300,6 @@. *
1660: 20 74 63 6c 42 61 73 69 63 2e 63 2c 20 62 75 74 tclBasic.c, but
1670: 20 61 6c 6d 6f 73 74 20 65 76 65 72 79 20 54 63 almost every Tc
1680: 6c 20 73 6f 75 72 63 65 20 66 69 6c 65 20 75 73 l source file us
1690: 65 73 20 73 6f 6d 65 74 68 69 6e 67 20 69 6e 20 es something in
16a0: 68 65 72 65 2e 0a 20 20 2a 2d 2d 2d 2d 2d 2d 2d here.. *-------
16b0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
16c0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
16d0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
16e0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 0a 20 20 2a 2f 0a 2d ---------. */.-
16f0: 0a 20 74 79 70 65 64 65 66 20 73 74 72 75 63 74 . typedef struct
1700: 20 49 6e 74 65 72 70 20 7b 0a 20 20 20 20 20 2f Interp {. /
1710: 2a 0a 20 20 20 20 20 20 2a 20 4e 6f 74 65 3a 20 *. * Note:
1720: 74 68 65 20 66 69 72 73 74 20 74 68 72 65 65 20 the first three
1730: 66 69 65 6c 64 73 20 6d 75 73 74 20 6d 61 74 63 fields must matc
1740: 68 20 65 78 61 63 74 6c 79 20 74 68 65 20 66 69 h exactly the fi
1750: 65 6c 64 73 20 69 6e 20 61 0a 40 40 20 2d 31 35 elds in a.@@ -15
1760: 35 35 2c 36 20 2b 31 35 36 32 2c 31 35 20 40 40 55,6 +1562,15 @@
1770: 0a 20 20 20 20 20 42 79 74 65 43 6f 64 65 53 74 . ByteCodeSt
1780: 61 74 73 20 73 74 61 74 73 3b 09 2f 2a 20 48 6f ats stats;./* Ho
1790: 6c 64 73 20 63 6f 6d 70 69 6c 61 74 69 6f 6e 20 lds compilation
17a0: 61 6e 64 20 65 78 65 63 75 74 69 6f 6e 20 73 74 and execution st
17b0: 61 74 69 73 74 69 63 73 0a 20 09 09 09 09 20 2a atistics. .... *
17c0: 20 66 6f 72 20 74 68 69 73 20 69 6e 74 65 72 70 for this interp
17d0: 72 65 74 65 72 2e 20 2a 2f 0a 20 23 65 6e 64 69 reter. */. #endi
17e0: 66 20 2f 2a 20 54 43 4c 5f 43 4f 4d 50 49 4c 45 f /* TCL_COMPILE
17f0: 5f 53 54 41 54 53 20 2a 2f 0a 2b 0a 2b 09 54 63 _STATS */.+.+.Tc
1800: 6c 5f 4f 62 6a 2a 20 65 78 63 65 70 74 69 6f 6e l_Obj* exception
1810: 43 6f 6d 6d 61 6e 64 3b 20 2f 2a 20 41 20 73 63 Command; /* A sc
1820: 72 69 70 74 20 74 68 61 74 20 69 73 20 65 78 65 ript that is exe
1830: 63 75 74 65 64 20 6f 6e 20 65 72 72 6f 72 73 20 cuted on errors
1840: 2a 2f 0a 2b 09 69 6e 74 20 65 78 63 65 70 74 69 */.+.int excepti
1850: 6f 6e 43 6f 6d 6d 61 6e 64 46 6c 61 67 73 3b 20 onCommandFlags;
1860: 2f 2a 20 46 6c 61 67 73 20 66 6f 72 20 65 78 65 /* Flags for exe
1870: 63 75 74 69 6e 67 20 74 68 65 20 45 72 72 6f 72 cuting the Error
1880: 20 53 63 72 69 70 74 2e 20 2a 2f 0a 2b 20 20 20 Script. */.+
1890: 20 69 6e 74 20 63 61 74 63 68 4c 65 76 65 6c 3b int catchLevel;
18a0: 20 2f 2a 20 4c 65 76 65 6c 20 6f 66 20 5b 63 61 /* Level of [ca
18b0: 74 63 68 5d 20 63 6f 6d 6d 61 6e 64 73 20 2e 20 tch] commands .
18c0: 49 73 20 69 6e 63 72 65 6d 65 6e 74 65 64 20 0a Is incremented .
18d0: 2b 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 +
18e0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2a 20 *
18f0: 6f 6e 20 65 61 63 68 20 65 6e 63 6f 75 6e 74 65 on each encounte
1900: 72 65 64 20 5b 63 61 74 63 68 5d 2e 20 49 66 20 red [catch]. If
1910: 69 74 20 69 73 20 67 72 65 61 74 65 72 0a 2b 20 it is greater.+
1920: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
1930: 20 20 20 20 20 20 20 20 20 20 20 20 2a 20 74 68 * th
1940: 61 6e 20 30 20 64 75 72 69 6e 67 20 61 6e 20 65 an 0 during an e
1950: 72 72 6f 72 20 69 73 20 74 68 72 6f 77 6e 20 74 rror is thrown t
1960: 68 69 73 20 6d 65 61 6e 73 20 74 68 61 74 0a 2b his means that.+
1970: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
1980: 20 20 20 20 20 20 20 20 20 20 20 20 20 2a 20 74 * t
1990: 68 65 20 65 72 72 6f 72 20 77 61 73 20 63 61 74 he error was cat
19a0: 63 68 65 64 20 65 6c 73 65 77 68 65 72 65 2e 20 ched elsewhere.
19b0: 57 65 20 63 61 6e 20 72 65 61 63 74 0a 2b 20 20 We can react.+
19c0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
19d0: 20 20 20 20 20 20 20 20 20 20 20 2a 20 61 63 63 * acc
19e0: 6f 72 64 69 6e 67 6c 79 0a 2b 20 20 20 20 20 20 ordingly.+
19f0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
1a00: 20 20 20 20 20 20 20 2a 2f 0a 20 7d 20 49 6e 74 */. } Int
1a10: 65 72 70 3b 0a 20 0a 20 2f 2a 0a 64 69 66 66 20 erp;. . /*.diff
1a20: 2d 75 62 72 20 74 63 6c 2e 6f 72 69 67 2f 67 65 -ubr tcl.orig/ge
1a30: 6e 65 72 69 63 2f 74 63 6c 54 72 61 63 65 2e 63 neric/tclTrace.c
1a40: 20 74 63 6c 2e 32 39 30 2f 67 65 6e 65 72 69 63 tcl.290/generic
1a50: 2f 74 63 6c 54 72 61 63 65 2e 63 0a 2d 2d 2d 20 /tclTrace.c.---
1a60: 74 63 6c 2e 6f 72 69 67 2f 67 65 6e 65 72 69 63 tcl.orig/generic
1a70: 2f 74 63 6c 54 72 61 63 65 2e 63 09 4d 6f 6e 20 /tclTrace.c.Mon
1a80: 4f 63 74 20 32 33 20 32 31 3a 33 36 3a 35 35 20 Oct 23 21:36:55
1a90: 32 30 30 36 0a 2b 2b 2b 20 74 63 6c 2e 32 39 30 2006.+++ tcl.290
1aa0: 2f 67 65 6e 65 72 69 63 2f 74 63 6c 54 72 61 63 /generic/tclTrac
1ab0: 65 2e 63 09 4d 6f 6e 20 4e 6f 76 20 20 36 20 31 e.c.Mon Nov 6 1
1ac0: 39 3a 32 33 3a 30 30 20 32 30 30 36 0a 40 40 20 9:23:00 2006.@@
1ad0: 2d 31 30 31 2c 36 20 2b 31 30 31 2c 37 20 40 40 -101,6 +101,7 @@
1ae0: 0a 20 73 74 61 74 69 63 20 54 63 6c 5f 54 72 61 . static Tcl_Tra
1af0: 63 65 54 79 70 65 4f 62 6a 43 6d 64 20 54 72 61 ceTypeObjCmd Tra
1b00: 63 65 56 61 72 69 61 62 6c 65 4f 62 6a 43 6d 64 ceVariableObjCmd
1b10: 3b 0a 20 73 74 61 74 69 63 20 54 63 6c 5f 54 72 ;. static Tcl_Tr
1b20: 61 63 65 54 79 70 65 4f 62 6a 43 6d 64 20 54 72 aceTypeObjCmd Tr
1b30: 61 63 65 43 6f 6d 6d 61 6e 64 4f 62 6a 43 6d 64 aceCommandObjCmd
1b40: 3b 0a 20 73 74 61 74 69 63 20 54 63 6c 5f 54 72 ;. static Tcl_Tr
1b50: 61 63 65 54 79 70 65 4f 62 6a 43 6d 64 20 54 72 aceTypeObjCmd Tr
1b60: 61 63 65 45 78 65 63 75 74 69 6f 6e 4f 62 6a 43 aceExecutionObjC
1b70: 6d 64 3b 0a 2b 73 74 61 74 69 63 20 54 63 6c 5f md;.+static Tcl_
1b80: 54 72 61 63 65 54 79 70 65 4f 62 6a 43 6d 64 20 TraceTypeObjCmd
1b90: 54 72 61 63 65 45 78 63 65 70 74 69 6f 6e 4f 62 TraceExceptionOb
1ba0: 6a 43 6d 64 3b 0a 20 0a 20 2f 2a 0a 20 20 2a 20 jCmd;. . /*. *
1bb0: 45 61 63 68 20 73 75 62 63 6f 6d 6d 61 6e 64 20 Each subcommand
1bc0: 68 61 73 20 61 20 6e 75 6d 62 65 72 20 6f 66 20 has a number of
1bd0: 27 74 79 70 65 73 27 20 74 6f 20 77 68 69 63 68 'types' to which
1be0: 20 69 74 20 63 61 6e 20 61 70 70 6c 79 2e 20 43 it can apply. C
1bf0: 75 72 72 65 6e 74 6c 79 0a 40 40 20 2d 31 31 30 urrently.@@ -110
1c00: 2c 31 32 20 2b 31 31 31 2c 31 33 20 40 40 0a 20 ,12 +111,13 @@.
1c10: 20 2a 2f 0a 20 0a 20 73 74 61 74 69 63 20 43 4f */. . static CO
1c20: 4e 53 54 20 63 68 61 72 20 2a 74 72 61 63 65 54 NST char *traceT
1c30: 79 70 65 4f 70 74 69 6f 6e 73 5b 5d 20 3d 20 7b ypeOptions[] = {
1c40: 0a 2d 20 20 20 20 22 65 78 65 63 75 74 69 6f 6e .- "execution
1c50: 22 2c 20 22 63 6f 6d 6d 61 6e 64 22 2c 20 22 76 ", "command", "v
1c60: 61 72 69 61 62 6c 65 22 2c 20 4e 55 4c 4c 0a 2b ariable", NULL.+
1c70: 20 20 20 20 22 65 78 65 63 75 74 69 6f 6e 22 2c "execution",
1c80: 20 22 63 6f 6d 6d 61 6e 64 22 2c 20 22 76 61 72 "command", "var
1c90: 69 61 62 6c 65 22 2c 20 22 65 78 63 65 70 74 69 iable", "excepti
1ca0: 6f 6e 22 2c 20 4e 55 4c 4c 0a 20 7d 3b 0a 20 73 on", NULL. };. s
1cb0: 74 61 74 69 63 20 54 63 6c 5f 54 72 61 63 65 54 tatic Tcl_TraceT
1cc0: 79 70 65 4f 62 6a 43 6d 64 20 2a 74 72 61 63 65 ypeObjCmd *trace
1cd0: 53 75 62 43 6d 64 73 5b 5d 20 3d 20 7b 0a 20 20 SubCmds[] = {.
1ce0: 20 20 20 54 72 61 63 65 45 78 65 63 75 74 69 6f TraceExecutio
1cf0: 6e 4f 62 6a 43 6d 64 2c 0a 20 20 20 20 20 54 72 nObjCmd,. Tr
1d00: 61 63 65 43 6f 6d 6d 61 6e 64 4f 62 6a 43 6d 64 aceCommandObjCmd
1d10: 2c 0a 20 20 20 20 20 54 72 61 63 65 56 61 72 69 ,. TraceVari
1d20: 61 62 6c 65 4f 62 6a 43 6d 64 2c 0a 2b 20 20 20 ableObjCmd,.+
1d30: 20 54 72 61 63 65 45 78 63 65 70 74 69 6f 6e 4f TraceExceptionO
1d40: 62 6a 43 6d 64 0a 20 7d 3b 0a 20 0a 20 2f 2a 0a bjCmd. };. . /*.
1d50: 40 40 20 2d 31 38 31 2c 37 20 2b 31 38 33 2c 37 @@ -181,7 +183,7
1d60: 20 40 40 0a 20 20 20 20 20 63 68 61 72 20 2a 6e @@. char *n
1d70: 61 6d 65 2c 20 2a 66 6c 61 67 4f 70 73 2c 20 2a ame, *flagOps, *
1d80: 70 3b 0a 20 20 20 20 20 2f 2a 20 4d 61 69 6e 20 p;. /* Main
1d90: 73 75 62 20 63 6f 6d 6d 61 6e 64 73 20 74 6f 20 sub commands to
1da0: 27 74 72 61 63 65 27 20 2a 2f 0a 20 20 20 20 20 'trace' */.
1db0: 73 74 61 74 69 63 20 43 4f 4e 53 54 20 63 68 61 static CONST cha
1dc0: 72 20 2a 74 72 61 63 65 4f 70 74 69 6f 6e 73 5b r *traceOptions[
1dd0: 5d 20 3d 20 7b 0a 2d 09 22 61 64 64 22 2c 20 22 ] = {.-."add", "
1de0: 69 6e 66 6f 22 2c 20 22 72 65 6d 6f 76 65 22 2c info", "remove",
1df0: 0a 2b 09 22 61 64 64 22 2c 20 22 69 6e 66 6f 22 .+."add", "info"
1e00: 2c 20 22 72 65 6d 6f 76 65 22 2c 20 22 73 65 74 , "remove", "set
1e10: 22 2c 20 22 75 6e 73 65 74 22 2c 0a 20 23 69 66 ", "unset",. #if
1e20: 6e 64 65 66 20 54 43 4c 5f 52 45 4d 4f 56 45 5f ndef TCL_REMOVE_
1e30: 4f 42 53 4f 4c 45 54 45 5f 54 52 41 43 45 53 0a OBSOLETE_TRACES.
1e40: 20 09 22 76 61 72 69 61 62 6c 65 22 2c 20 22 76 ."variable", "v
1e50: 64 65 6c 65 74 65 22 2c 20 22 76 69 6e 66 6f 22 delete", "vinfo"
1e60: 2c 0a 20 23 65 6e 64 69 66 0a 40 40 20 2d 31 38 ,. #endif.@@ -18
1e70: 39 2c 37 20 2b 31 39 31 2c 37 20 40 40 0a 20 20 9,7 +191,7 @@.
1e80: 20 20 20 7d 3b 0a 20 20 20 20 20 2f 2a 20 27 4f };. /* 'O
1e90: 4c 44 27 20 6f 70 74 69 6f 6e 73 20 61 72 65 20 LD' options are
1ea0: 70 72 65 2d 54 63 6c 2d 38 2e 34 20 73 74 79 6c pre-Tcl-8.4 styl
1eb0: 65 20 2a 2f 0a 20 20 20 20 20 65 6e 75 6d 20 74 e */. enum t
1ec0: 72 61 63 65 4f 70 74 69 6f 6e 73 20 7b 0a 2d 09 raceOptions {.-.
1ed0: 54 52 41 43 45 5f 41 44 44 2c 20 54 52 41 43 45 TRACE_ADD, TRACE
1ee0: 5f 49 4e 46 4f 2c 20 54 52 41 43 45 5f 52 45 4d _INFO, TRACE_REM
1ef0: 4f 56 45 2c 0a 2b 09 54 52 41 43 45 5f 41 44 44 OVE,.+.TRACE_ADD
1f00: 2c 20 54 52 41 43 45 5f 49 4e 46 4f 2c 20 54 52 , TRACE_INFO, TR
1f10: 41 43 45 5f 52 45 4d 4f 56 45 2c 20 54 52 41 43 ACE_REMOVE, TRAC
1f20: 45 5f 53 45 54 2c 20 54 52 41 43 45 5f 55 4e 53 E_SET, TRACE_UNS
1f30: 45 54 2c 0a 20 23 69 66 6e 64 65 66 20 54 43 4c ET,. #ifndef TCL
1f40: 5f 52 45 4d 4f 56 45 5f 4f 42 53 4f 4c 45 54 45 _REMOVE_OBSOLETE
1f50: 5f 54 52 41 43 45 53 0a 20 09 54 52 41 43 45 5f _TRACES. .TRACE_
1f60: 4f 4c 44 5f 56 41 52 49 41 42 4c 45 2c 20 54 52 OLD_VARIABLE, TR
1f70: 41 43 45 5f 4f 4c 44 5f 56 44 45 4c 45 54 45 2c ACE_OLD_VDELETE,
1f80: 20 54 52 41 43 45 5f 4f 4c 44 5f 56 49 4e 46 4f TRACE_OLD_VINFO
1f90: 0a 20 23 65 6e 64 69 66 0a 40 40 20 2d 32 34 39 . #endif.@@ -249
1fa0: 2c 36 20 2b 32 35 31 2c 32 33 20 40 40 0a 20 09 ,6 +251,23 @@. .
1fb0: 72 65 74 75 72 6e 20 28 74 72 61 63 65 53 75 62 return (traceSub
1fc0: 43 6d 64 73 5b 74 79 70 65 49 6e 64 65 78 5d 29 Cmds[typeIndex])
1fd0: 28 69 6e 74 65 72 70 2c 20 6f 70 74 69 6f 6e 49 (interp, optionI
1fe0: 6e 64 65 78 2c 20 6f 62 6a 63 2c 20 6f 62 6a 76 ndex, objc, objv
1ff0: 29 3b 0a 20 09 62 72 65 61 6b 3b 0a 20 20 20 20 );. .break;.
2000: 20 7d 0a 2b 20 20 20 20 63 61 73 65 20 54 52 41 }.+ case TRA
2010: 43 45 5f 53 45 54 3a 0a 2b 20 20 20 20 63 61 73 CE_SET:.+ cas
2020: 65 20 54 52 41 43 45 5f 55 4e 53 45 54 3a 20 7b e TRACE_UNSET: {
2030: 0a 2b 20 20 20 20 69 6e 74 20 74 79 70 65 49 6e .+ int typeIn
2040: 64 65 78 3b 0a 2b 20 20 20 20 69 66 20 28 6f 62 dex;.+ if (ob
2050: 6a 63 20 3c 20 33 29 20 7b 0a 2b 20 20 20 20 20 jc < 3) {.+
2060: 20 20 20 54 63 6c 5f 57 72 6f 6e 67 4e 75 6d 41 Tcl_WrongNumA
2070: 72 67 73 28 69 6e 74 65 72 70 2c 20 32 2c 20 6f rgs(interp, 2, o
2080: 62 6a 76 2c 20 22 65 78 63 65 70 74 69 6f 6e 20 bjv, "exception
2090: 3f 61 72 67 20 2e 2e 2e 3f 22 29 3b 0a 2b 20 20 ?arg ...?");.+
20a0: 20 20 20 20 20 20 72 65 74 75 72 6e 20 54 43 4c return TCL
20b0: 5f 45 52 52 4f 52 3b 0a 2b 20 20 20 20 7d 0a 2b _ERROR;.+ }.+
20c0: 20 20 20 20 69 66 20 28 54 63 6c 5f 47 65 74 49 if (Tcl_GetI
20d0: 6e 64 65 78 46 72 6f 6d 4f 62 6a 28 69 6e 74 65 ndexFromObj(inte
20e0: 72 70 2c 20 6f 62 6a 76 5b 32 5d 2c 20 74 72 61 rp, objv[2], tra
20f0: 63 65 54 79 70 65 4f 70 74 69 6f 6e 73 2c 20 22 ceTypeOptions, "
2100: 6f 70 74 69 6f 6e 22 2c 0a 2b 20 20 20 20 20 20 option",.+
2110: 20 20 30 2c 20 26 74 79 70 65 49 6e 64 65 78 29 0, &typeIndex)
2120: 20 21 3d 20 54 43 4c 5f 4f 4b 29 20 7b 0a 2b 20 != TCL_OK) {.+
2130: 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 54 43 return TC
2140: 4c 5f 45 52 52 4f 52 3b 0a 2b 20 20 20 20 7d 0a L_ERROR;.+ }.
2150: 2b 20 20 20 20 69 66 20 28 74 79 70 65 49 6e 64 + if (typeInd
2160: 65 78 20 3c 20 33 29 20 7b 0a 2b 20 20 20 20 20 ex < 3) {.+
2170: 20 20 20 72 65 74 75 72 6e 20 54 43 4c 5f 45 52 return TCL_ER
2180: 52 4f 52 3b 0a 2b 20 20 20 20 7d 0a 2b 20 20 20 ROR;.+ }.+
2190: 20 72 65 74 75 72 6e 20 54 72 61 63 65 45 78 63 return TraceExc
21a0: 65 70 74 69 6f 6e 4f 62 6a 43 6d 64 28 69 6e 74 eptionObjCmd(int
21b0: 65 72 70 2c 20 6f 70 74 69 6f 6e 49 6e 64 65 78 erp, optionIndex
21c0: 2c 20 6f 62 6a 63 2c 20 6f 62 6a 76 29 3b 0a 2b , objc, objv);.+
21d0: 20 20 20 20 62 72 65 61 6b 3b 0a 2b 20 20 20 20 break;.+
21e0: 7d 0a 20 0a 20 23 69 66 6e 64 65 66 20 54 43 4c }. . #ifndef TCL
21f0: 5f 52 45 4d 4f 56 45 5f 4f 42 53 4f 4c 45 54 45 _REMOVE_OBSOLETE
2200: 5f 54 52 41 43 45 53 0a 20 20 20 20 20 63 61 73 _TRACES. cas
2210: 65 20 54 52 41 43 45 5f 4f 4c 44 5f 56 41 52 49 e TRACE_OLD_VARI
2220: 41 42 4c 45 3a 0a 40 40 20 2d 36 31 34 2c 36 20 ABLE:.@@ -614,6
2230: 2b 36 33 33 2c 31 30 39 20 40 40 0a 20 20 20 20 +633,109 @@.
2240: 20 7d 0a 20 20 20 20 20 7d 0a 20 20 20 20 20 72 }. }. r
2250: 65 74 75 72 6e 20 54 43 4c 5f 4f 4b 3b 0a 2b 7d eturn TCL_OK;.+}
2260: 0a 2b 0a 2b 73 74 61 74 69 63 20 69 6e 74 0a 2b .+.+static int.+
2270: 54 72 61 63 65 45 78 63 65 70 74 69 6f 6e 4f 62 TraceExceptionOb
2280: 6a 43 6d 64 28 0a 2b 20 20 20 20 54 63 6c 5f 49 jCmd(.+ Tcl_I
2290: 6e 74 65 72 70 20 2a 69 6e 74 65 72 70 2c 20 20 nterp *interp,
22a0: 20 20 20 2f 2a 20 43 75 72 72 65 6e 74 20 69 6e /* Current in
22b0: 74 65 72 70 72 65 74 65 72 2e 20 2a 2f 0a 2b 20 terpreter. */.+
22c0: 20 20 20 69 6e 74 20 6f 70 74 69 6f 6e 49 6e 64 int optionInd
22d0: 65 78 2c 20 20 20 20 20 20 20 20 2f 2a 20 41 64 ex, /* Ad
22e0: 64 2c 20 69 6e 66 6f 20 6f 72 20 72 65 6d 6f 76 d, info or remov
22f0: 65 20 2a 2f 0a 2b 20 20 20 20 69 6e 74 20 6f 62 e */.+ int ob
2300: 6a 63 2c 20 20 20 20 20 20 20 20 20 20 20 2f 2a jc, /*
2310: 20 4e 75 6d 62 65 72 20 6f 66 20 61 72 67 75 6d Number of argum
2320: 65 6e 74 73 2e 20 2a 2f 0a 2b 20 20 20 20 54 63 ents. */.+ Tc
2330: 6c 5f 4f 62 6a 20 2a 43 4f 4e 53 54 20 6f 62 6a l_Obj *CONST obj
2340: 76 5b 5d 29 20 20 2f 2a 20 41 72 67 75 6d 65 6e v[]) /* Argumen
2350: 74 20 6f 62 6a 65 63 74 73 2e 20 2a 2f 0a 2b 7b t objects. */.+{
2360: 0a 2b 20 20 20 20 49 6e 74 65 72 70 20 2a 69 50 .+ Interp *iP
2370: 74 72 20 3d 20 28 49 6e 74 65 72 70 2a 29 69 6e tr = (Interp*)in
2380: 74 65 72 70 3b 0a 2b 20 20 20 20 65 6e 75 6d 20 terp;.+ enum
2390: 74 72 61 63 65 4f 70 74 69 6f 6e 73 20 7b 0a 2b traceOptions {.+
23a0: 20 20 20 20 54 52 41 43 45 5f 41 44 44 2c 20 54 TRACE_ADD, T
23b0: 52 41 43 45 5f 49 4e 46 4f 2c 20 54 52 41 43 45 RACE_INFO, TRACE
23c0: 5f 52 45 4d 4f 56 45 2c 20 54 52 41 43 45 5f 53 _REMOVE, TRACE_S
23d0: 45 54 2c 20 54 52 41 43 45 5f 55 4e 53 45 54 0a ET, TRACE_UNSET.
23e0: 2b 20 20 20 20 7d 3b 0a 2b 20 20 20 20 0a 2b 20 + };.+ .+
23f0: 20 20 20 73 77 69 74 63 68 20 28 28 65 6e 75 6d switch ((enum
2400: 20 74 72 61 63 65 4f 70 74 69 6f 6e 73 29 20 6f traceOptions) o
2410: 70 74 69 6f 6e 49 6e 64 65 78 29 20 7b 0a 2b 20 ptionIndex) {.+
2420: 20 20 20 20 20 20 20 63 61 73 65 20 54 52 41 43 case TRAC
2430: 45 5f 49 4e 46 4f 3a 20 7b 0a 2b 20 20 20 20 20 E_INFO: {.+
2440: 20 20 20 2f 2a 0a 2b 20 20 20 20 20 20 20 20 20 /*.+
2450: 2a 20 52 65 74 75 72 6e 20 74 68 65 20 63 75 72 * Return the cur
2460: 72 65 6e 74 6c 79 20 73 65 74 20 65 72 72 6f 72 rently set error
2470: 20 73 63 72 69 70 74 20 70 6c 75 73 20 61 20 74 script plus a t
2480: 75 70 6c 65 20 66 6f 72 20 2d 63 61 75 67 68 74 uple for -caught
2490: 20 61 6e 64 20 0a 2b 20 20 20 20 20 20 20 20 20 and .+
24a0: 2a 20 2d 75 6e 63 61 75 67 68 74 20 74 68 61 74 * -uncaught that
24b0: 20 69 6e 64 69 63 61 74 65 73 20 77 68 65 6e 20 indicates when
24c0: 74 68 65 20 73 63 72 69 70 74 20 69 73 20 65 78 the script is ex
24d0: 65 63 75 74 65 64 0a 2b 20 20 20 20 20 20 20 20 ecuted.+
24e0: 20 2a 2f 0a 2b 20 20 20 20 20 20 20 20 54 63 6c */.+ Tcl
24f0: 5f 4f 62 6a 20 2a 72 65 73 75 6c 74 20 3d 20 54 _Obj *result = T
2500: 63 6c 5f 4e 65 77 4f 62 6a 28 29 3b 0a 2b 20 20 cl_NewObj();.+
2510: 20 20 20 20 20 20 54 63 6c 5f 4c 69 73 74 4f 62 Tcl_ListOb
2520: 6a 41 70 70 65 6e 64 45 6c 65 6d 65 6e 74 28 69 jAppendElement(i
2530: 6e 74 65 72 70 2c 20 72 65 73 75 6c 74 2c 20 54 nterp, result, T
2540: 63 6c 5f 4e 65 77 53 74 72 69 6e 67 4f 62 6a 28 cl_NewStringObj(
2550: 22 2d 63 61 75 67 68 74 22 2c 20 2d 31 29 29 3b "-caught", -1));
2560: 0a 2b 20 20 20 20 20 20 20 20 54 63 6c 5f 4c 69 .+ Tcl_Li
2570: 73 74 4f 62 6a 41 70 70 65 6e 64 45 6c 65 6d 65 stObjAppendEleme
2580: 6e 74 28 69 6e 74 65 72 70 2c 20 72 65 73 75 6c nt(interp, resul
2590: 74 2c 20 0a 2b 20 20 20 20 20 20 20 20 20 20 20 t, .+
25a0: 20 54 63 6c 5f 4e 65 77 42 6f 6f 6c 65 61 6e 4f Tcl_NewBooleanO
25b0: 62 6a 28 69 50 74 72 2d 3e 65 78 63 65 70 74 69 bj(iPtr->excepti
25c0: 6f 6e 43 6f 6d 6d 61 6e 64 46 6c 61 67 73 20 26 onCommandFlags &
25d0: 20 45 58 43 45 50 54 43 4d 44 5f 4f 4e 43 41 55 EXCEPTCMD_ONCAU
25e0: 47 48 54 29 29 3b 0a 2b 20 20 20 20 20 20 20 20 GHT));.+
25f0: 54 63 6c 5f 4c 69 73 74 4f 62 6a 41 70 70 65 6e Tcl_ListObjAppen
2600: 64 45 6c 65 6d 65 6e 74 28 69 6e 74 65 72 70 2c dElement(interp,
2610: 20 72 65 73 75 6c 74 2c 20 54 63 6c 5f 4e 65 77 result, Tcl_New
2620: 53 74 72 69 6e 67 4f 62 6a 28 22 2d 75 6e 63 61 StringObj("-unca
2630: 75 67 68 74 22 2c 20 2d 31 29 29 3b 0a 2b 20 20 ught", -1));.+
2640: 20 20 20 20 20 20 54 63 6c 5f 4c 69 73 74 4f 62 Tcl_ListOb
2650: 6a 41 70 70 65 6e 64 45 6c 65 6d 65 6e 74 28 69 jAppendElement(i
2660: 6e 74 65 72 70 2c 20 72 65 73 75 6c 74 2c 20 0a nterp, result, .
2670: 2b 20 20 20 20 20 20 20 20 20 20 20 20 54 63 6c + Tcl
2680: 5f 4e 65 77 42 6f 6f 6c 65 61 6e 4f 62 6a 28 69 _NewBooleanObj(i
2690: 50 74 72 2d 3e 65 78 63 65 70 74 69 6f 6e 43 6f Ptr->exceptionCo
26a0: 6d 6d 61 6e 64 46 6c 61 67 73 20 26 20 45 58 43 mmandFlags & EXC
26b0: 45 50 54 43 4d 44 5f 4f 4e 55 4e 43 41 55 47 48 EPTCMD_ONUNCAUGH
26c0: 54 29 29 3b 0a 2b 20 20 20 20 20 20 20 20 69 66 T));.+ if
26d0: 20 28 69 50 74 72 2d 3e 65 78 63 65 70 74 69 6f (iPtr->exceptio
26e0: 6e 43 6f 6d 6d 61 6e 64 20 3d 3d 20 4e 55 4c 4c nCommand == NULL
26f0: 29 20 7b 0a 2b 20 20 20 20 20 20 20 20 20 20 20 ) {.+
2700: 20 54 63 6c 5f 4c 69 73 74 4f 62 6a 41 70 70 65 Tcl_ListObjAppe
2710: 6e 64 45 6c 65 6d 65 6e 74 28 69 6e 74 65 72 70 ndElement(interp
2720: 2c 20 72 65 73 75 6c 74 2c 20 54 63 6c 5f 4e 65 , result, Tcl_Ne
2730: 77 53 74 72 69 6e 67 4f 62 6a 28 22 22 2c 20 2d wStringObj("", -
2740: 31 29 29 3b 0a 2b 20 20 20 20 20 20 20 20 7d 20 1));.+ }
2750: 65 6c 73 65 20 7b 0a 2b 20 20 20 20 20 20 20 20 else {.+
2760: 20 20 20 20 54 63 6c 5f 4c 69 73 74 4f 62 6a 41 Tcl_ListObjA
2770: 70 70 65 6e 64 45 6c 65 6d 65 6e 74 28 69 6e 74 ppendElement(int
2780: 65 72 70 2c 20 72 65 73 75 6c 74 2c 20 69 50 74 erp, result, iPt
2790: 72 2d 3e 65 78 63 65 70 74 69 6f 6e 43 6f 6d 6d r->exceptionComm
27a0: 61 6e 64 29 3b 0a 2b 20 20 20 20 20 20 20 20 7d and);.+ }
27b0: 0a 2b 20 20 20 20 20 20 20 20 0a 2b 20 20 20 20 .+ .+
27c0: 20 20 20 20 54 63 6c 5f 53 65 74 4f 62 6a 52 65 Tcl_SetObjRe
27d0: 73 75 6c 74 28 69 6e 74 65 72 70 2c 20 72 65 73 sult(interp, res
27e0: 75 6c 74 29 3b 0a 2b 20 20 20 20 20 20 20 20 72 ult);.+ r
27f0: 65 74 75 72 6e 20 54 43 4c 5f 4f 4b 3b 0a 2b 20 eturn TCL_OK;.+
2800: 20 20 20 20 20 20 20 7d 0a 2b 20 20 20 20 20 20 }.+
2810: 20 20 63 61 73 65 20 54 52 41 43 45 5f 53 45 54 case TRACE_SET
2820: 3a 20 7b 0a 2b 20 20 20 20 20 20 20 20 62 72 65 : {.+ bre
2830: 61 6b 3b 0a 2b 20 20 20 20 20 20 20 20 7d 0a 2b ak;.+ }.+
2840: 20 20 20 20 20 20 20 20 63 61 73 65 20 54 52 41 case TRA
2850: 43 45 5f 55 4e 53 45 54 3a 20 7b 0a 2b 20 20 20 CE_UNSET: {.+
2860: 20 20 20 20 20 54 63 6c 5f 44 65 63 72 52 65 66 Tcl_DecrRef
2870: 43 6f 75 6e 74 28 69 50 74 72 2d 3e 65 78 63 65 Count(iPtr->exce
2880: 70 74 69 6f 6e 43 6f 6d 6d 61 6e 64 29 3b 0a 2b ptionCommand);.+
2890: 20 20 20 20 20 20 20 20 69 50 74 72 2d 3e 65 78 iPtr->ex
28a0: 63 65 70 74 69 6f 6e 43 6f 6d 6d 61 6e 64 20 3d ceptionCommand =
28b0: 20 4e 55 4c 4c 3b 0a 2b 20 20 20 20 20 20 20 20 NULL;.+
28c0: 72 65 74 75 72 6e 20 54 43 4c 5f 4f 4b 3b 0a 2b return TCL_OK;.+
28d0: 20 20 20 20 20 20 20 20 7d 0a 2b 20 20 20 20 20 }.+
28e0: 20 20 20 64 65 66 61 75 6c 74 3a 20 7b 0a 2b 20 default: {.+
28f0: 20 20 20 20 20 20 20 54 63 6c 5f 53 65 74 4f 62 Tcl_SetOb
2900: 6a 52 65 73 75 6c 74 28 69 6e 74 65 72 70 2c 20 jResult(interp,
2910: 54 63 6c 5f 4e 65 77 53 74 72 69 6e 67 4f 62 6a Tcl_NewStringObj
2920: 28 0a 2b 20 20 20 20 20 20 20 20 20 20 20 20 22 (.+ "
2930: 62 61 64 20 6f 70 74 69 6f 6e 2c 20 73 68 6f 75 bad option, shou
2940: 6c 64 20 62 65 20 74 72 61 63 65 20 73 65 74 7c ld be trace set|
2950: 67 65 74 7c 69 6e 66 6f 20 65 78 63 65 70 74 69 get|info excepti
2960: 6f 6e 22 2c 20 2d 31 29 29 3b 0a 2b 20 20 20 20 on", -1));.+
2970: 20 20 20 20 72 65 74 75 72 6e 20 54 43 4c 5f 45 return TCL_E
2980: 52 52 4f 52 3b 0a 2b 20 20 20 20 20 20 20 20 7d RROR;.+ }
2990: 0a 2b 20 20 20 20 7d 0a 2b 20 20 20 20 0a 2b 20 .+ }.+ .+
29a0: 20 20 20 69 66 20 28 6f 62 6a 63 20 3d 3d 20 34 if (objc == 4
29b0: 29 20 7b 0a 2b 20 20 20 20 20 20 20 20 69 50 74 ) {.+ iPt
29c0: 72 2d 3e 65 78 63 65 70 74 69 6f 6e 43 6f 6d 6d r->exceptionComm
29d0: 61 6e 64 20 3d 20 6f 62 6a 76 5b 33 5d 3b 0a 2b and = objv[3];.+
29e0: 20 20 20 20 20 20 20 20 54 63 6c 5f 49 6e 63 72 Tcl_Incr
29f0: 52 65 66 43 6f 75 6e 74 20 28 69 50 74 72 2d 3e RefCount (iPtr->
2a00: 65 78 63 65 70 74 69 6f 6e 43 6f 6d 6d 61 6e 64 exceptionCommand
2a10: 29 3b 0a 2b 20 20 20 20 20 20 20 20 0a 2b 20 20 );.+ .+
2a20: 20 20 20 20 20 20 72 65 74 75 72 6e 20 54 43 4c return TCL
2a30: 5f 4f 4b 3b 0a 2b 20 20 20 20 7d 0a 2b 20 20 20 _OK;.+ }.+
2a40: 20 0a 2b 20 20 20 20 69 66 20 28 6f 62 6a 63 20 .+ if (objc
2a50: 3d 3d 20 35 29 20 7b 0a 2b 20 20 20 20 20 20 20 == 5) {.+
2a60: 20 63 68 61 72 20 2a 66 6c 61 67 20 3d 20 54 63 char *flag = Tc
2a70: 6c 5f 47 65 74 53 74 72 69 6e 67 28 6f 62 6a 76 l_GetString(objv
2a80: 5b 33 5d 29 3b 0a 2b 20 20 20 20 20 20 20 20 0a [3]);.+ .
2a90: 2b 20 20 20 20 20 20 20 20 69 66 20 28 2a 66 6c + if (*fl
2aa0: 61 67 20 21 3d 20 27 2d 27 29 20 7b 0a 2b 20 20 ag != '-') {.+
2ab0: 20 20 20 20 20 20 20 20 20 20 67 6f 74 6f 20 65 goto e
2ac0: 72 72 6f 72 52 65 74 75 72 6e 3b 0a 2b 20 20 20 rrorReturn;.+
2ad0: 20 20 20 20 20 7d 0a 2b 20 20 20 20 20 20 20 20 }.+
2ae0: 69 66 20 28 73 74 72 63 6d 70 28 66 6c 61 67 2c if (strcmp(flag,
2af0: 20 22 2d 63 61 75 67 68 74 22 29 20 3d 3d 20 30 "-caught") == 0
2b00: 29 20 7b 0a 2b 20 20 20 20 20 20 20 20 20 20 20 ) {.+
2b10: 20 69 50 74 72 2d 3e 65 78 63 65 70 74 69 6f 6e iPtr->exception
2b20: 43 6f 6d 6d 61 6e 64 46 6c 61 67 73 20 3d 20 45 CommandFlags = E
2b30: 58 43 45 50 54 43 4d 44 5f 4f 4e 43 41 55 47 48 XCEPTCMD_ONCAUGH
2b40: 54 3b 0a 2b 20 20 20 20 20 20 20 20 7d 20 65 6c T;.+ } el
2b50: 73 65 20 69 66 20 28 73 74 72 63 6d 70 28 66 6c se if (strcmp(fl
2b60: 61 67 2c 20 22 2d 75 6e 63 61 75 67 68 74 22 29 ag, "-uncaught")
2b70: 20 3d 3d 20 30 29 20 7b 0a 2b 20 20 20 20 20 20 == 0) {.+
2b80: 20 20 20 20 20 20 69 50 74 72 2d 3e 65 78 63 65 iPtr->exce
2b90: 70 74 69 6f 6e 43 6f 6d 6d 61 6e 64 46 6c 61 67 ptionCommandFlag
2ba0: 73 20 3d 20 45 58 43 45 50 54 43 4d 44 5f 4f 4e s = EXCEPTCMD_ON
2bb0: 55 4e 43 41 55 47 48 54 3b 0a 2b 20 20 20 20 20 UNCAUGHT;.+
2bc0: 20 20 20 7d 20 65 6c 73 65 20 7b 0a 2b 20 20 20 } else {.+
2bd0: 20 20 20 20 20 20 20 20 20 67 6f 74 6f 20 65 72 goto er
2be0: 72 6f 72 52 65 74 75 72 6e 3b 0a 2b 20 20 20 20 rorReturn;.+
2bf0: 20 20 20 20 7d 0a 2b 20 20 20 20 20 20 20 20 0a }.+ .
2c00: 2b 20 20 20 20 20 20 20 20 69 50 74 72 2d 3e 65 + iPtr->e
2c10: 78 63 65 70 74 69 6f 6e 43 6f 6d 6d 61 6e 64 20 xceptionCommand
2c20: 3d 20 6f 62 6a 76 5b 34 5d 3b 0a 2b 20 20 20 20 = objv[4];.+
2c30: 20 20 20 20 54 63 6c 5f 49 6e 63 72 52 65 66 43 Tcl_IncrRefC
2c40: 6f 75 6e 74 28 69 50 74 72 2d 3e 65 78 63 65 70 ount(iPtr->excep
2c50: 74 69 6f 6e 43 6f 6d 6d 61 6e 64 29 3b 0a 2b 20 tionCommand);.+
2c60: 20 20 20 20 20 20 20 0a 2b 20 20 20 20 20 20 20 .+
2c70: 20 72 65 74 75 72 6e 20 54 43 4c 5f 4f 4b 3b 0a return TCL_OK;.
2c80: 2b 20 20 20 20 7d 0a 2b 20 20 20 20 0a 2b 20 20 + }.+ .+
2c90: 20 20 69 66 20 28 6f 62 6a 63 20 3d 3d 20 36 29 if (objc == 6)
2ca0: 20 7b 0a 2b 20 20 20 20 20 20 20 20 63 68 61 72 {.+ char
2cb0: 20 2a 66 6c 61 67 31 20 3d 20 54 63 6c 5f 47 65 *flag1 = Tcl_Ge
2cc0: 74 53 74 72 69 6e 67 28 6f 62 6a 76 5b 33 5d 29 tString(objv[3])
2cd0: 2c 20 2a 66 6c 61 67 32 20 3d 20 54 63 6c 5f 47 , *flag2 = Tcl_G
2ce0: 65 74 53 74 72 69 6e 67 28 6f 62 6a 76 5b 34 5d etString(objv[4]
2cf0: 29 3b 0a 2b 20 20 20 20 20 20 20 20 69 6e 74 20 );.+ int
2d00: 76 61 6c 69 64 20 3d 20 30 3b 0a 2b 20 20 20 20 valid = 0;.+
2d10: 20 20 20 20 69 66 20 28 2a 66 6c 61 67 31 20 21 if (*flag1 !
2d20: 3d 20 27 2d 27 20 7c 7c 20 2a 66 6c 61 67 32 20 = '-' || *flag2
2d30: 21 3d 20 27 2d 27 29 20 7b 0a 2b 20 20 20 20 20 != '-') {.+
2d40: 20 20 20 20 20 20 20 67 6f 74 6f 20 65 72 72 6f goto erro
2d50: 72 52 65 74 75 72 6e 3b 0a 2b 20 20 20 20 20 20 rReturn;.+
2d60: 20 20 7d 0a 2b 20 20 20 20 20 20 20 20 0a 2b 20 }.+ .+
2d70: 20 20 20 20 20 20 20 76 61 6c 69 64 20 3d 20 28 valid = (
2d80: 73 74 72 63 6d 70 28 66 6c 61 67 31 2c 20 22 2d strcmp(flag1, "-
2d90: 63 61 75 67 68 74 22 29 20 3d 3d 20 30 20 26 26 caught") == 0 &&
2da0: 20 73 74 72 63 6d 70 28 66 6c 61 67 32 2c 20 22 strcmp(flag2, "
2db0: 2d 75 6e 63 61 75 67 68 74 22 29 20 3d 3d 20 30 -uncaught") == 0
2dc0: 29 0a 2b 20 20 20 20 20 20 20 20 20 20 20 20 7c ).+ |
2dd0: 7c 20 28 73 74 72 63 6d 70 28 66 6c 61 67 31 2c | (strcmp(flag1,
2de0: 20 22 2d 75 6e 63 61 75 67 68 74 22 29 20 3d 3d "-uncaught") ==
2df0: 20 30 20 26 26 20 73 74 72 63 6d 70 28 66 6c 61 0 && strcmp(fla
2e00: 67 32 2c 20 22 2d 63 61 75 67 68 74 22 29 20 3d g2, "-caught") =
2e10: 3d 20 30 29 3b 0a 2b 20 20 20 20 20 20 20 20 69 = 0);.+ i
2e20: 66 20 28 21 76 61 6c 69 64 29 20 7b 0a 2b 20 20 f (!valid) {.+
2e30: 20 20 20 20 20 20 20 20 20 20 67 6f 74 6f 20 65 goto e
2e40: 72 72 6f 72 52 65 74 75 72 6e 3b 0a 2b 20 20 20 rrorReturn;.+
2e50: 20 20 20 20 20 7d 0a 2b 20 20 20 20 20 20 20 20 }.+
2e60: 0a 2b 20 20 20 20 20 20 20 20 69 50 74 72 2d 3e .+ iPtr->
2e70: 65 78 63 65 70 74 69 6f 6e 43 6f 6d 6d 61 6e 64 exceptionCommand
2e80: 46 6c 61 67 73 20 3d 20 45 58 43 45 50 54 43 4d Flags = EXCEPTCM
2e90: 44 5f 4f 4e 43 41 55 47 48 54 7c 45 58 43 45 50 D_ONCAUGHT|EXCEP
2ea0: 54 43 4d 44 5f 4f 4e 55 4e 43 41 55 47 48 54 3b TCMD_ONUNCAUGHT;
2eb0: 0a 2b 20 20 20 20 20 20 20 20 69 50 74 72 2d 3e .+ iPtr->
2ec0: 65 78 63 65 70 74 69 6f 6e 43 6f 6d 6d 61 6e 64 exceptionCommand
2ed0: 20 3d 20 6f 62 6a 76 5b 35 5d 3b 0a 2b 20 20 20 = objv[5];.+
2ee0: 20 20 20 20 20 54 63 6c 5f 49 6e 63 72 52 65 66 Tcl_IncrRef
2ef0: 43 6f 75 6e 74 28 69 50 74 72 2d 3e 65 78 63 65 Count(iPtr->exce
2f00: 70 74 69 6f 6e 43 6f 6d 6d 61 6e 64 29 3b 0a 2b ptionCommand);.+
2f10: 20 20 20 20 20 20 20 20 0a 2b 20 20 20 20 20 20 .+
2f20: 20 20 72 65 74 75 72 6e 20 54 43 4c 5f 4f 4b 3b return TCL_OK;
2f30: 0a 2b 20 20 20 20 7d 0a 2b 20 20 20 20 0a 2b 65 .+ }.+ .+e
2f40: 72 72 6f 72 52 65 74 75 72 6e 3a 0a 2b 20 20 20 rrorReturn:.+
2f50: 20 69 50 74 72 2d 3e 65 78 63 65 70 74 69 6f 6e iPtr->exception
2f60: 43 6f 6d 6d 61 6e 64 20 3d 20 4e 55 4c 4c 3b 0a Command = NULL;.
2f70: 2b 20 20 20 20 69 50 74 72 2d 3e 65 78 63 65 70 + iPtr->excep
2f80: 74 69 6f 6e 43 6f 6d 6d 61 6e 64 46 6c 61 67 73 tionCommandFlags
2f90: 20 3d 20 30 3b 0a 2b 20 20 20 20 54 63 6c 5f 57 = 0;.+ Tcl_W
2fa0: 72 6f 6e 67 4e 75 6d 41 72 67 73 28 69 6e 74 65 rongNumArgs(inte
2fb0: 72 70 2c 20 33 2c 20 6f 62 6a 76 2c 20 22 3f 2d rp, 3, objv, "?-
2fc0: 63 61 75 67 68 74 3f 20 3f 2d 75 6e 63 61 75 67 caught? ?-uncaug
2fd0: 68 74 3f 20 3f 73 63 72 69 70 74 3f 22 29 3b 0a ht? ?script?");.
2fe0: 2b 20 20 20 20 72 65 74 75 72 6e 20 54 43 4c 5f + return TCL_
2ff0: 45 52 52 4f 52 3b 0a 20 7d 0a 20 0c 0a 20 2f 2a ERROR;. }. .. /*
3000: 0a 64 69 66 66 20 2d 75 62 72 20 74 63 6c 2e 6f .diff -ubr tcl.o
3010: 72 69 67 2f 74 65 73 74 73 2f 74 72 61 63 65 2e rig/tests/trace.
3020: 74 65 73 74 20 74 63 6c 2e 32 39 30 2f 74 65 73 test tcl.290/tes
3030: 74 73 2f 74 72 61 63 65 2e 74 65 73 74 0a 2d 2d ts/trace.test.--
3040: 2d 20 74 63 6c 2e 6f 72 69 67 2f 74 65 73 74 73 - tcl.orig/tests
3050: 2f 74 72 61 63 65 2e 74 65 73 74 09 46 72 69 20 /trace.test.Fri
3060: 4e 6f 76 20 20 33 20 32 33 3a 32 34 3a 34 33 20 Nov 3 23:24:43
3070: 32 30 30 36 0a 2b 2b 2b 20 74 63 6c 2e 32 39 30 2006.+++ tcl.290
3080: 2f 74 65 73 74 73 2f 74 72 61 63 65 2e 74 65 73 /tests/trace.tes
3090: 74 09 4d 6f 6e 20 4e 6f 76 20 20 36 20 31 39 3a t.Mon Nov 6 19:
30a0: 33 34 3a 34 36 20 32 30 30 36 0a 40 40 20 2d 38 34:46 2006.@@ -8
30b0: 34 32 2c 37 20 2b 38 34 32 2c 37 20 40 40 0a 20 42,7 +842,7 @@.
30c0: 0a 20 74 65 73 74 20 74 72 61 63 65 2d 31 34 2e . test trace-14.
30d0: 35 20 7b 74 72 61 63 65 20 63 6f 6d 6d 61 6e 64 5 {trace command
30e0: 2c 20 69 6e 76 61 6c 69 64 20 6f 70 74 69 6f 6e , invalid option
30f0: 7d 20 7b 0a 20 20 20 20 20 6c 69 73 74 20 5b 63 } {. list [c
3100: 61 74 63 68 20 7b 74 72 61 63 65 20 67 6f 72 70 atch {trace gorp
3110: 7d 20 6d 73 67 5d 20 24 6d 73 67 0a 2d 7d 20 5b } msg] $msg.-} [
3120: 6c 69 73 74 20 31 20 22 62 61 64 20 6f 70 74 69 list 1 "bad opti
3130: 6f 6e 20 5c 22 67 6f 72 70 5c 22 3a 20 6d 75 73 on \"gorp\": mus
3140: 74 20 62 65 20 61 64 64 2c 20 69 6e 66 6f 2c 20 t be add, info,
3150: 72 65 6d 6f 76 65 2c 20 76 61 72 69 61 62 6c 65 remove, variable
3160: 2c 20 76 64 65 6c 65 74 65 2c 20 6f 72 20 76 69 , vdelete, or vi
3170: 6e 66 6f 22 5d 0a 2b 7d 20 5b 6c 69 73 74 20 31 nfo"].+} [list 1
3180: 20 22 62 61 64 20 6f 70 74 69 6f 6e 20 5c 22 67 "bad option \"g
3190: 6f 72 70 5c 22 3a 20 6d 75 73 74 20 62 65 20 61 orp\": must be a
31a0: 64 64 2c 20 69 6e 66 6f 2c 20 72 65 6d 6f 76 65 dd, info, remove
31b0: 2c 20 73 65 74 2c 20 75 6e 73 65 74 2c 20 76 61 , set, unset, va
31c0: 72 69 61 62 6c 65 2c 20 76 64 65 6c 65 74 65 2c riable, vdelete,
31d0: 20 6f 72 20 76 69 6e 66 6f 22 5d 0a 20 0a 20 23 or vinfo"]. . #
31e0: 20 41 67 61 69 6e 2c 20 5b 74 72 61 63 65 20 2e Again, [trace .
31f0: 2e 2e 20 63 6f 6d 6d 61 6e 64 5d 20 61 6e 64 20 .. command] and
3200: 5b 74 72 61 63 65 20 2e 2e 2e 20 76 61 72 69 61 [trace ... varia
3210: 62 6c 65 5d 20 73 68 61 72 65 20 73 79 6e 74 61 ble] share synta
3220: 78 20 61 6e 64 0a 20 23 20 65 72 72 6f 72 20 6d x and. # error m
3230: 65 73 73 61 67 65 20 73 74 79 6c 65 73 20 66 6f essage styles fo
3240: 72 20 74 68 65 69 72 20 6f 70 4c 69 73 74 20 6f r their opList o
3250: 70 74 69 6f 6e 73 3b 20 74 68 65 73 65 20 6c 6f ptions; these lo
3260: 6f 70 73 20 74 65 73 74 20 74 68 6f 73 65 20 0a ops test those .
3270: 4f 6e 6c 79 20 69 6e 20 74 63 6c 2e 32 39 30 2f Only in tcl.290/
3280: 77 69 6e 3a 20 32 38 30 2d 6c 61 74 65 73 74 2d win: 280-latest-
3290: 32 30 30 36 31 31 30 34 2e 64 69 66 66 0a 20061104.diff.