From 5f9e047cf5d7f3adca4154b75cf8f68325330af8 Mon Sep 17 00:00:00 2001 From: sebres Date: Tue, 26 Apr 2022 12:03:22 +0000 Subject: added test illustrating bug [27520c9b17] --- tests/error.test | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/error.test b/tests/error.test index af07ed7..08bd00c 100644 --- a/tests/error.test +++ b/tests/error.test @@ -351,6 +351,13 @@ test error-9.4 {try (ok, non-empty result) with on handler} { test error-9.5 {try (ok, non-empty result) with on ok handler} { try { list a b c } on ok {} { list d e f } } {d e f} +test error-9.6 {try (compilation of simple finaly token only, bug [27520c9b17])} -body { + set b {}; set l {} + try {lappend l error} finally [lappend l set b] + list $l $b +} -cleanup { + unset -nocomplain b l +} -result {{set b error} {}} # simple try tests - "on" handler matching -- cgit v0.12 From 2ce077e7c8a82332c62a598756f2de7dffb17376 Mon Sep 17 00:00:00 2001 From: sebres Date: Tue, 26 Apr 2022 12:03:41 +0000 Subject: fixes compilation of try-command [27520c9b17]: compile only if finaly token is simple --- generic/tclCompCmdsSZ.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/generic/tclCompCmdsSZ.c b/generic/tclCompCmdsSZ.c index 53bff6e..abaf7a7 100644 --- a/generic/tclCompCmdsSZ.c +++ b/generic/tclCompCmdsSZ.c @@ -2929,6 +2929,9 @@ TclCompileTryCmd( goto failedToCompile; } finallyToken = TokenAfter(tokenPtr); + if (finallyToken->type != TCL_TOKEN_SIMPLE_WORD) { + goto failedToCompile; + } } else { goto failedToCompile; } -- cgit v0.12 From fb6284e74892e0451649cff40291378b663dd448 Mon Sep 17 00:00:00 2001 From: sebres Date: Tue, 26 Apr 2022 13:25:01 +0000 Subject: fixes build using msys/mingw toolchain, missing build path as include caused: generic/tclEvent.c:17:10: fatal error: tclUuid.h: No such file or directory (cherry picked from unix/Makefile.in) --- win/Makefile.in | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/win/Makefile.in b/win/Makefile.in index 4a4979d..1464792 100644 --- a/win/Makefile.in +++ b/win/Makefile.in @@ -98,6 +98,7 @@ COMPILE_DEBUG_FLAGS = SRC_DIR = @srcdir@ ROOT_DIR = @srcdir@/.. TOP_DIR = $(shell cd @srcdir@/..; pwd -W 2>/dev/null || pwd -P) +BUILD_DIR = @builddir@ GENERIC_DIR = $(TOP_DIR)/generic WIN_DIR = $(TOP_DIR)/win COMPAT_DIR = $(TOP_DIR)/compat @@ -251,7 +252,7 @@ MINIZIP_OBJS = \ ZIP_INSTALL_OBJS = @ZIP_INSTALL_OBJS@ -CC_SWITCHES = -I"${GENERIC_DIR_NATIVE}" -I"${TOMMATH_DIR_NATIVE}" \ +CC_SWITCHES = -I"${BUILD_DIR}" -I"${GENERIC_DIR_NATIVE}" -I"${TOMMATH_DIR_NATIVE}" \ -I"${ZLIB_DIR_NATIVE}" -I"${WIN_DIR_NATIVE}" \ ${CFLAGS} ${CFLAGS_WARNING} ${SHLIB_CFLAGS} -DMP_PREC=4 \ ${AC_FLAGS} ${COMPILE_DEBUG_FLAGS} ${NO_DEPRECATED_FLAGS} -- cgit v0.12 From 9f54abf33a1289128b25b82e8a2d53013463801e Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 26 Apr 2022 15:07:32 +0000 Subject: Change value of TCL_INDEX_TEMP_TABLE from 2 to 64, and let it lead to a slightly more efficient implementation of Tcl_GetIndexFromObj*() (TIP #613) --- generic/tcl.h | 6 +++--- generic/tclDecls.h | 4 ++-- generic/tclIndexObj.c | 21 +++++++++++---------- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/generic/tcl.h b/generic/tcl.h index eff58b3..79e4174 100644 --- a/generic/tcl.h +++ b/generic/tcl.h @@ -977,15 +977,15 @@ typedef struct Tcl_DString { /* * Flags that may be passed to Tcl_GetIndexFromObj. * TCL_EXACT disallows abbreviated strings. - * TCL_INDEX_TEMP_TABLE disallows caching of lookups. A possible use case is - * a table that will not live long enough to make it worthwhile. * TCL_INDEX_NULL_OK allows the empty string or NULL to return TCL_OK. * The returned value will be -1; + * TCL_INDEX_TEMP_TABLE disallows caching of lookups. A possible use case is + * a table that will not live long enough to make it worthwhile. */ #define TCL_EXACT 1 -#define TCL_INDEX_TEMP_TABLE 2 #define TCL_INDEX_NULL_OK 32 +#define TCL_INDEX_TEMP_TABLE 64 /* *---------------------------------------------------------------------------- diff --git a/generic/tclDecls.h b/generic/tclDecls.h index 266c265..624903e 100644 --- a/generic/tclDecls.h +++ b/generic/tclDecls.h @@ -4252,7 +4252,7 @@ extern const TclStubs *tclStubsPtr; #define Tcl_GetBytesFromObj(interp, objPtr, sizePtr) \ (sizeof(*(sizePtr)) <= sizeof(int) ? tclStubsPtr->tclGetBytesFromObj(interp, objPtr, (int *)(sizePtr)) : tclStubsPtr->tcl_GetBytesFromObj(interp, objPtr, (size_t *)(sizePtr))) #define Tcl_GetIndexFromObjStruct(interp, objPtr, tablePtr, offset, msg, flags, indexPtr) \ - (tclStubsPtr->tcl_GetIndexFromObjStruct((interp), (objPtr), (tablePtr), (offset), (msg), (flags)|(int)(sizeof(*(indexPtr))<<8), (indexPtr))) + (tclStubsPtr->tcl_GetIndexFromObjStruct((interp), (objPtr), (tablePtr), (offset), (msg), (flags)|(int)(sizeof(*(indexPtr))<<1), (indexPtr))) #ifdef TCL_NO_DEPRECATED #define Tcl_GetStringFromObj(objPtr, sizePtr) \ (sizeof(*(sizePtr)) <= sizeof(int) ? tclStubsPtr->tcl_GetStringFromObj(objPtr, (int *)(sizePtr)) : tclStubsPtr->tclGetStringFromObj(objPtr, (size_t *)(sizePtr))) @@ -4265,7 +4265,7 @@ extern const TclStubs *tclStubsPtr; #define Tcl_GetBytesFromObj(interp, objPtr, sizePtr) \ (sizeof(*(sizePtr)) <= sizeof(int) ? (TclGetBytesFromObj)(interp, objPtr, (int *)(sizePtr)) : (Tcl_GetBytesFromObj)(interp, objPtr, (size_t *)(sizePtr))) #define Tcl_GetIndexFromObjStruct(interp, objPtr, tablePtr, offset, msg, flags, indexPtr) \ - ((Tcl_GetIndexFromObjStruct)((interp), (objPtr), (tablePtr), (offset), (msg), (flags)|(int)(sizeof(*(indexPtr))<<8), (indexPtr))) + ((Tcl_GetIndexFromObjStruct)((interp), (objPtr), (tablePtr), (offset), (msg), (flags)|(int)(sizeof(*(indexPtr))<<1), (indexPtr))) #ifdef TCL_NO_DEPRECATED #define Tcl_GetStringFromObj(objPtr, sizePtr) \ (sizeof(*(sizePtr)) <= sizeof(int) ? (Tcl_GetStringFromObj)(objPtr, (int *)(sizePtr)) : (TclGetStringFromObj)(objPtr, (size_t *)(sizePtr))) diff --git a/generic/tclIndexObj.c b/generic/tclIndexObj.c index 1f600c5..e1526ad 100644 --- a/generic/tclIndexObj.c +++ b/generic/tclIndexObj.c @@ -369,20 +369,21 @@ Tcl_GetIndexFromObjStruct( uncachedDone: if (indexPtr != NULL) { - if ((flags>>8) & (int)~sizeof(int)) { - if ((flags>>8) == sizeof(uint64_t)) { - *(uint64_t *)indexPtr = index; - return TCL_OK; - } else if ((flags>>8) == sizeof(uint32_t)) { - *(uint32_t *)indexPtr = index; - return TCL_OK; - } else if ((flags>>8) == sizeof(uint16_t)) { + flags &= (30-(int)(sizeof(int)<<1)); + if (flags) { + if (flags == sizeof(uint16_t)<<1) { *(uint16_t *)indexPtr = index; return TCL_OK; - } else if ((flags>>8) == sizeof(uint8_t)) { + } else if (flags == (int)(sizeof(uint8_t)<<1)) { *(uint8_t *)indexPtr = index; return TCL_OK; - } + } else if (flags == (int)(sizeof(int64_t)<<1)) { + *(int64_t *)indexPtr = index; + return TCL_OK; + } else if (flags == (int)(sizeof(int32_t)<<1)) { + *(int32_t *)indexPtr = index; + return TCL_OK; + } } *(int *)indexPtr = index; } -- cgit v0.12