summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--generic/regexec.c54
-rw-r--r--generic/tcl.decls4
-rw-r--r--generic/tcl.h16
-rw-r--r--generic/tclDecls.h8
-rw-r--r--generic/tclHash.c2
-rw-r--r--generic/tclObj.c11
-rw-r--r--generic/tclPanic.c8
-rw-r--r--generic/tclVar.c11
-rw-r--r--tools/genStubs.tcl2
-rw-r--r--win/tclWinError.c2
-rw-r--r--win/tclWinFile.c4
11 files changed, 62 insertions, 60 deletions
diff --git a/generic/regexec.c b/generic/regexec.c
index dfecf65..128d439 100644
--- a/generic/regexec.c
+++ b/generic/regexec.c
@@ -622,10 +622,10 @@ subset(
*/
static int /* regexec return code */
cdissect(
- struct vars *const v,
- struct subre *const t,
- chr *const begin, /* beginning of relevant substring */
- chr *const end) /* end of same */
+ struct vars *v,
+ struct subre *t,
+ chr *begin, /* beginning of relevant substring */
+ chr *end) /* end of same */
{
int er;
@@ -688,10 +688,10 @@ cdissect(
*/
static int /* regexec return code */
ccondissect(
- struct vars *const v,
- struct subre *const t,
- chr *const begin, /* beginning of relevant substring */
- chr *const end) /* end of same */
+ struct vars *v,
+ struct subre *t,
+ chr *begin, /* beginning of relevant substring */
+ chr *end) /* end of same */
{
struct dfa *d, *d2;
chr *mid;
@@ -778,10 +778,10 @@ ccondissect(
*/
static int /* regexec return code */
crevcondissect(
- struct vars *const v,
- struct subre *const t,
- chr *const begin, /* beginning of relevant substring */
- chr *const end) /* end of same */
+ struct vars *v,
+ struct subre *t,
+ chr *begin, /* beginning of relevant substring */
+ chr *end) /* end of same */
{
struct dfa *d, *d2;
chr *mid;
@@ -869,10 +869,10 @@ crevcondissect(
*/
static int /* regexec return code */
cbrdissect(
- struct vars *const v,
- struct subre *const t,
- chr *const begin, /* beginning of relevant substring */
- chr *const end) /* end of same */
+ struct vars *v,
+ struct subre *t,
+ chr *begin, /* beginning of relevant substring */
+ chr *end) /* end of same */
{
int n = t->subno, min = t->min, max = t->max;
size_t numreps;
@@ -926,7 +926,7 @@ cbrdissect(
if (tlen % brlen != 0)
return REG_NOMATCH;
numreps = tlen / brlen;
- if (numreps < min || (numreps > max && max != DUPINF))
+ if (numreps < (size_t)min || (numreps > (size_t)max && max != DUPINF))
return REG_NOMATCH;
/* okay, compare the actual string contents */
@@ -947,10 +947,10 @@ cbrdissect(
*/
static int /* regexec return code */
caltdissect(
- struct vars *const v,
+ struct vars *v,
struct subre *t,
- chr *const begin, /* beginning of relevant substring */
- chr *const end) /* end of same */
+ chr *begin, /* beginning of relevant substring */
+ chr *end) /* end of same */
{
struct dfa *d;
int er;
@@ -1025,9 +1025,9 @@ citerdissect(struct vars * v,
* sub-match endpoints in endpts[1..max_matches].
*/
max_matches = end - begin;
- if (max_matches > t->max && t->max != DUPINF)
+ if (max_matches > (size_t)t->max && t->max != DUPINF)
max_matches = t->max;
- if (max_matches < min_matches)
+ if (max_matches < (size_t)min_matches)
max_matches = min_matches;
endpts = (chr **) MALLOC((max_matches + 1) * sizeof(chr *));
if (endpts == NULL)
@@ -1074,7 +1074,7 @@ citerdissect(struct vars * v,
if (endpts[k] != end) {
/* haven't reached end yet, try another iteration if allowed */
- if (k >= max_matches) {
+ if ((size_t)k >= max_matches) {
/* must try to shorten some previous match */
k--;
goto backtrack;
@@ -1198,9 +1198,9 @@ creviterdissect(struct vars * v,
* sub-match endpoints in endpts[1..max_matches].
*/
max_matches = end - begin;
- if (max_matches > t->max && t->max != DUPINF)
+ if (max_matches > (size_t)t->max && t->max != DUPINF)
max_matches = t->max;
- if (max_matches < min_matches)
+ if (max_matches < (size_t)min_matches)
max_matches = min_matches;
endpts = (chr **) MALLOC((max_matches + 1) * sizeof(chr *));
if (endpts == NULL)
@@ -1238,7 +1238,7 @@ creviterdissect(struct vars * v,
limit++;
/* if this is the last allowed sub-match, it must reach to the end */
- if (k >= max_matches)
+ if ((size_t)k >= max_matches)
limit = end;
/* try to find an endpoint for the k'th sub-match */
@@ -1258,7 +1258,7 @@ creviterdissect(struct vars * v,
if (endpts[k] != end) {
/* haven't reached end yet, try another iteration if allowed */
- if (k >= max_matches) {
+ if ((size_t)k >= max_matches) {
/* must try to lengthen some previous match */
k--;
goto backtrack;
diff --git a/generic/tcl.decls b/generic/tcl.decls
index c1345cf..812a523 100644
--- a/generic/tcl.decls
+++ b/generic/tcl.decls
@@ -39,7 +39,7 @@ declare 1 {
void *clientDataPtr)
}
declare 2 {
- void Tcl_Panic(const char *format, ...)
+ TCL_NORETURN void Tcl_Panic(const char *format, ...)
}
declare 3 {
char *Tcl_Alloc(unsigned int size)
@@ -1009,7 +1009,7 @@ declare 277 {
Tcl_Pid Tcl_WaitPid(Tcl_Pid pid, int *statPtr, int options)
}
declare 278 {
- void Tcl_PanicVA(const char *format, va_list argList)
+ TCL_NORETURN void Tcl_PanicVA(const char *format, va_list argList)
}
declare 279 {
void Tcl_GetVersion(int *major, int *minor, int *patchLevel, int *type)
diff --git a/generic/tcl.h b/generic/tcl.h
index 49fb959..f022434 100644
--- a/generic/tcl.h
+++ b/generic/tcl.h
@@ -98,19 +98,21 @@ extern "C" {
/*
*----------------------------------------------------------------------------
* Support for functions with a variable number of arguments.
- *
- * The following TCL_VARARGS* macros are to support old extensions
- * written for older versions of Tcl where the macros permitted
- * support for the varargs.h system as well as stdarg.h .
- *
- * New code should just directly be written to use stdarg.h conventions.
*/
#include <stdarg.h>
#if defined(__GNUC__) && (__GNUC__ > 2)
# define TCL_FORMAT_PRINTF(a,b) __attribute__ ((__format__ (__printf__, a, b)))
+# define TCL_NORETURN __attribute__ ((noreturn))
+# define TCL_NORETURN1 __attribute__ ((noreturn))
#else
# define TCL_FORMAT_PRINTF(a,b)
+# if defined(_MSC_VER) && (_MSC_VER >= 1310)
+# define TCL_NORETURN _declspec(noreturn)
+# else
+# define TCL_NORETURN /* nothing */
+# endif
+# define TCL_NORETURN1 /* nothing */
#endif
/*
@@ -2190,7 +2192,7 @@ const char * TclTomMathInitializeStubs(Tcl_Interp *interp,
#define Tcl_Main(argc, argv, proc) Tcl_MainEx(argc, argv, proc, \
((Tcl_CreateInterp)()))
TCLAPI void Tcl_FindExecutable(const char *argv0);
-TCLAPI void Tcl_SetPanicProc(Tcl_PanicProc *panicProc);
+TCLAPI void Tcl_SetPanicProc(TCL_NORETURN1 Tcl_PanicProc *panicProc);
TCLAPI void Tcl_MainEx(int argc, char **argv,
Tcl_AppInitProc *appInitProc, Tcl_Interp *interp);
#if defined(_WIN32) && defined(UNICODE)
diff --git a/generic/tclDecls.h b/generic/tclDecls.h
index a57d5ce..d33ccb8 100644
--- a/generic/tclDecls.h
+++ b/generic/tclDecls.h
@@ -37,7 +37,7 @@ TCLAPI const char * Tcl_PkgRequireEx(Tcl_Interp *interp,
const char *name, const char *version,
int exact, void *clientDataPtr);
/* 2 */
-TCLAPI void Tcl_Panic(const char *format, ...) TCL_FORMAT_PRINTF(1, 2);
+TCLAPI TCL_NORETURN void Tcl_Panic(const char *format, ...) TCL_FORMAT_PRINTF(1, 2);
/* 3 */
TCLAPI char * Tcl_Alloc(unsigned int size);
/* 4 */
@@ -770,7 +770,7 @@ TCLAPI void Tcl_SetErrorCodeVA(Tcl_Interp *interp,
/* 277 */
TCLAPI Tcl_Pid Tcl_WaitPid(Tcl_Pid pid, int *statPtr, int options);
/* 278 */
-TCLAPI void Tcl_PanicVA(const char *format, va_list argList);
+TCLAPI TCL_NORETURN void Tcl_PanicVA(const char *format, va_list argList);
/* 279 */
TCLAPI void Tcl_GetVersion(int *major, int *minor,
int *patchLevel, int *type);
@@ -1745,7 +1745,7 @@ typedef struct TclStubs {
int (*tcl_PkgProvideEx) (Tcl_Interp *interp, const char *name, const char *version, const void *clientData); /* 0 */
const char * (*tcl_PkgRequireEx) (Tcl_Interp *interp, const char *name, const char *version, int exact, void *clientDataPtr); /* 1 */
- void (*tcl_Panic) (const char *format, ...) TCL_FORMAT_PRINTF(1, 2); /* 2 */
+ TCL_NORETURN1 void (*tcl_Panic) (const char *format, ...) TCL_FORMAT_PRINTF(1, 2); /* 2 */
char * (*tcl_Alloc) (unsigned int size); /* 3 */
void (*tcl_Free) (char *ptr); /* 4 */
char * (*tcl_Realloc) (char *ptr, unsigned int size); /* 5 */
@@ -2045,7 +2045,7 @@ typedef struct TclStubs {
void (*tcl_SetErrorCodeVA) (Tcl_Interp *interp, va_list argList); /* 275 */
void (*reserved276)(void);
Tcl_Pid (*tcl_WaitPid) (Tcl_Pid pid, int *statPtr, int options); /* 277 */
- void (*tcl_PanicVA) (const char *format, va_list argList); /* 278 */
+ TCL_NORETURN1 void (*tcl_PanicVA) (const char *format, va_list argList); /* 278 */
void (*tcl_GetVersion) (int *major, int *minor, int *patchLevel, int *type); /* 279 */
void (*tcl_InitMemory) (Tcl_Interp *interp); /* 280 */
Tcl_Channel (*tcl_StackChannel) (Tcl_Interp *interp, const Tcl_ChannelType *typePtr, ClientData instanceData, int mask, Tcl_Channel prevChan); /* 281 */
diff --git a/generic/tclHash.c b/generic/tclHash.c
index 282b165..3ea9dd9 100644
--- a/generic/tclHash.c
+++ b/generic/tclHash.c
@@ -324,7 +324,7 @@ CreateHashEntry(
if (hash != PTR2UINT(hPtr->hash)) {
continue;
}
- if (compareKeysProc((void *) key, hPtr)) {
+ if (((void *) key == hPtr) || compareKeysProc((void *) key, hPtr)) {
if (newPtr) {
*newPtr = 0;
}
diff --git a/generic/tclObj.c b/generic/tclObj.c
index 1ed4cb0..38800bf 100644
--- a/generic/tclObj.c
+++ b/generic/tclObj.c
@@ -3972,12 +3972,11 @@ TclCompareObjKeys(
/*
* If the object pointers are the same then they match.
- */
-
- if (objPtr1 == objPtr2) {
- return 1;
- }
-
+ * OPT: this comparison was moved to the caller
+
+ if (objPtr1 == objPtr2) return 1;
+ */
+
/*
* Don't use Tcl_GetStringFromObj as it would prevent l1 and l2 being
* in a register.
diff --git a/generic/tclPanic.c b/generic/tclPanic.c
index 851695f..b032449 100644
--- a/generic/tclPanic.c
+++ b/generic/tclPanic.c
@@ -15,7 +15,7 @@
#include "tclInt.h"
#if defined(_WIN32) || defined(__CYGWIN__)
- MODULE_SCOPE void tclWinDebugPanic(const char *format, ...);
+ MODULE_SCOPE TCL_NORETURN void tclWinDebugPanic(const char *format, ...);
#endif
/*
@@ -24,9 +24,9 @@
*/
#if defined(__CYGWIN__)
-static Tcl_PanicProc *panicProc = tclWinDebugPanic;
+static TCL_NORETURN Tcl_PanicProc *panicProc = tclWinDebugPanic;
#else
-static Tcl_PanicProc *panicProc = NULL;
+static TCL_NORETURN1 Tcl_PanicProc *panicProc = NULL;
#endif
/*
@@ -47,7 +47,7 @@ static Tcl_PanicProc *panicProc = NULL;
void
Tcl_SetPanicProc(
- Tcl_PanicProc *proc)
+ TCL_NORETURN1 Tcl_PanicProc *proc)
{
#if defined(_WIN32)
/* tclWinDebugPanic only installs if there is no panicProc yet. */
diff --git a/generic/tclVar.c b/generic/tclVar.c
index ab71b27..e18d472 100644
--- a/generic/tclVar.c
+++ b/generic/tclVar.c
@@ -6165,12 +6165,11 @@ CompareVarKeys(
/*
* If the object pointers are the same then they match.
- */
-
- if (objPtr1 == objPtr2) {
- return 1;
- }
-
+ * OPT: this comparison was moved to the caller
+
+ if (objPtr1 == objPtr2) return 1;
+ */
+
/*
* Don't use Tcl_GetStringFromObj as it would prevent l1 and l2 being in a
* register.
diff --git a/tools/genStubs.tcl b/tools/genStubs.tcl
index 00195af..aafa025 100644
--- a/tools/genStubs.tcl
+++ b/tools/genStubs.tcl
@@ -582,6 +582,8 @@ proc genStubs::makeSlot {name decl index} {
}
if {[string range $rtype end-8 end] eq "__stdcall"} {
append text [string trim [string range $rtype 0 end-9]] " (__stdcall *" $lfname ") "
+ } elseif {[string range $rtype 0 11] eq "TCL_NORETURN"} {
+ append text "TCL_NORETURN1 " [string trim [string range $rtype 12 end]] " (*" $lfname ") "
} else {
append text $rtype " (*" $lfname ") "
}
diff --git a/win/tclWinError.c b/win/tclWinError.c
index 4d3250d..30079b9 100644
--- a/win/tclWinError.c
+++ b/win/tclWinError.c
@@ -381,7 +381,7 @@ TclWinConvertError(
*----------------------------------------------------------------------
*/
-void
+TCL_NORETURN void
tclWinDebugPanic(
const char *format, ...)
{
diff --git a/win/tclWinFile.c b/win/tclWinFile.c
index 02927ad..f6e3a4b 100644
--- a/win/tclWinFile.c
+++ b/win/tclWinFile.c
@@ -172,7 +172,7 @@ static int WinLink(const TCHAR *LinkSource,
const TCHAR *LinkTarget, int linkAction);
static int WinSymLinkDirectory(const TCHAR *LinkDirectory,
const TCHAR *LinkTarget);
-MODULE_SCOPE void tclWinDebugPanic(const char *format, ...);
+MODULE_SCOPE TCL_NORETURN void tclWinDebugPanic(const char *format, ...);
/*
*--------------------------------------------------------------------
@@ -789,7 +789,7 @@ NativeWriteReparse(
*----------------------------------------------------------------------
*/
-void
+TCL_NORETURN void
tclWinDebugPanic(
const char *format, ...)
{