summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2019-08-02 12:15:23 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2019-08-02 12:15:23 (GMT)
commit474d95712ea623f7cccf704be60d713aa2ebe309 (patch)
treebd8e84a71e7799de0d39a19caa754821d7da2926 /generic
parent2a3d586a796e62f522303b3ab71c84743a73bf89 (diff)
parentadbd7d18869a4d99a25188fad9c3bbf55d072980 (diff)
downloadtcl-474d95712ea623f7cccf704be60d713aa2ebe309.zip
tcl-474d95712ea623f7cccf704be60d713aa2ebe309.tar.gz
tcl-474d95712ea623f7cccf704be60d713aa2ebe309.tar.bz2
Merge 8.7. Continue implementation for win32
Diffstat (limited to 'generic')
-rw-r--r--generic/regcustom.h4
-rw-r--r--generic/regguts.h2
-rw-r--r--generic/tcl.h2
-rw-r--r--generic/tclBasic.c50
-rw-r--r--generic/tclCmdMZ.c21
-rw-r--r--generic/tclCompCmds.c4
-rw-r--r--generic/tclCompCmdsGR.c2
-rw-r--r--generic/tclCompCmdsSZ.c2
-rw-r--r--generic/tclCompile.h4
-rw-r--r--generic/tclDTrace.d57
-rw-r--r--generic/tclEnsemble.c6
-rw-r--r--generic/tclEnv.c6
-rw-r--r--generic/tclExecute.c20
-rw-r--r--generic/tclIOUtil.c12
-rw-r--r--generic/tclInt.h21
-rw-r--r--generic/tclLiteral.c2
-rw-r--r--generic/tclMain.c2
-rw-r--r--generic/tclObj.c2
-rw-r--r--generic/tclPanic.c2
-rw-r--r--generic/tclPathObj.c2
-rw-r--r--generic/tclProc.c44
-rw-r--r--generic/tclResult.c8
-rw-r--r--generic/tclStringObj.c56
-rw-r--r--generic/tclTest.c12
-rw-r--r--generic/tclThreadJoin.c2
-rw-r--r--generic/tclZipfs.c2
26 files changed, 184 insertions, 163 deletions
diff --git a/generic/regcustom.h b/generic/regcustom.h
index 095385d..4396399 100644
--- a/generic/regcustom.h
+++ b/generic/regcustom.h
@@ -131,7 +131,7 @@ typedef int celt; /* Type to hold chr, or NOCELT */
#if 1
#define AllocVars(vPtr) \
static Tcl_ThreadDataKey varsKey; \
- register struct vars *vPtr = (struct vars *) \
+ struct vars *vPtr = (struct vars *) \
Tcl_GetThreadData(&varsKey, sizeof(struct vars))
#else
/*
@@ -140,7 +140,7 @@ typedef int celt; /* Type to hold chr, or NOCELT */
* faster in practice (measured!)
*/
#define AllocVars(vPtr) \
- register struct vars *vPtr = (struct vars *) MALLOC(sizeof(struct vars))
+ struct vars *vPtr = (struct vars *) MALLOC(sizeof(struct vars))
#define FreeVars(vPtr) \
FREE(vPtr)
#endif
diff --git a/generic/regguts.h b/generic/regguts.h
index b3dbaa4..da38ef2 100644
--- a/generic/regguts.h
+++ b/generic/regguts.h
@@ -411,7 +411,7 @@ struct guts {
#ifndef AllocVars
#define AllocVars(vPtr) \
struct vars var; \
- register struct vars *vPtr = &var
+ struct vars *vPtr = &var
#endif
#ifndef FreeVars
#define FreeVars(vPtr) ((void) 0)
diff --git a/generic/tcl.h b/generic/tcl.h
index cd194d1..f3253db 100644
--- a/generic/tcl.h
+++ b/generic/tcl.h
@@ -406,7 +406,7 @@ typedef unsigned TCL_WIDE_INT_TYPE Tcl_WideUInt;
#if defined(_WIN32)
# ifdef __BORLANDC__
typedef struct stati64 Tcl_StatBuf;
-# elif defined(_WIN64)
+# elif defined(_WIN64) || defined(__MINGW_USE_VC2005_COMPAT) || defined(_USE_64BIT_TIME_T)
typedef struct __stat64 Tcl_StatBuf;
# elif (defined(_MSC_VER) && (_MSC_VER < 1400)) || defined(_USE_32BIT_TIME_T)
typedef struct _stati64 Tcl_StatBuf;
diff --git a/generic/tclBasic.c b/generic/tclBasic.c
index e2025f6..732e625 100644
--- a/generic/tclBasic.c
+++ b/generic/tclBasic.c
@@ -453,24 +453,24 @@ typedef struct {
const char *name; /* Name of the function. The full name is
* "::tcl::mathfunc::<name>". */
Tcl_ObjCmdProc *objCmdProc; /* Function that evaluates the function */
- void *clientData; /* Client data for the function */
+ double (*fn)(double x); /* Real function pointer */
} BuiltinFuncDef;
static const BuiltinFuncDef BuiltinFuncTable[] = {
{ "abs", ExprAbsFunc, NULL },
- { "acos", ExprUnaryFunc, (void *) acos },
- { "asin", ExprUnaryFunc, (void *) asin },
- { "atan", ExprUnaryFunc, (void *) atan },
- { "atan2", ExprBinaryFunc, (void *) atan2 },
+ { "acos", ExprUnaryFunc, acos },
+ { "asin", ExprUnaryFunc, asin },
+ { "atan", ExprUnaryFunc, atan },
+ { "atan2", ExprBinaryFunc, (double (*)(double)) (double (*)(double, double)) atan2},
{ "bool", ExprBoolFunc, NULL },
{ "ceil", ExprCeilFunc, NULL },
- { "cos", ExprUnaryFunc, (void *) cos },
- { "cosh", ExprUnaryFunc, (void *) cosh },
+ { "cos", ExprUnaryFunc, cos },
+ { "cosh", ExprUnaryFunc, cosh },
{ "double", ExprDoubleFunc, NULL },
{ "entier", ExprIntFunc, NULL },
- { "exp", ExprUnaryFunc, (void *) exp },
+ { "exp", ExprUnaryFunc, exp },
{ "floor", ExprFloorFunc, NULL },
- { "fmod", ExprBinaryFunc, (void *) fmod },
- { "hypot", ExprBinaryFunc, (void *) hypot },
+ { "fmod", ExprBinaryFunc, (double (*)(double)) (double (*)(double, double)) fmod},
+ { "hypot", ExprBinaryFunc, (double (*)(double)) (double (*)(double, double)) hypot},
{ "int", ExprIntFunc, NULL },
{ "isfinite", ExprIsFiniteFunc, NULL },
{ "isinf", ExprIsInfinityFunc, NULL },
@@ -479,19 +479,19 @@ static const BuiltinFuncDef BuiltinFuncTable[] = {
{ "isqrt", ExprIsqrtFunc, NULL },
{ "issubnormal", ExprIsSubnormalFunc, NULL, },
{ "isunordered", ExprIsUnorderedFunc, NULL, },
- { "log", ExprUnaryFunc, (void *) log },
- { "log10", ExprUnaryFunc, (void *) log10 },
+ { "log", ExprUnaryFunc, log },
+ { "log10", ExprUnaryFunc, log10 },
{ "max", ExprMaxFunc, NULL },
{ "min", ExprMinFunc, NULL },
- { "pow", ExprBinaryFunc, (void *) pow },
+ { "pow", ExprBinaryFunc, (double (*)(double)) (double (*)(double, double)) pow},
{ "rand", ExprRandFunc, NULL },
{ "round", ExprRoundFunc, NULL },
- { "sin", ExprUnaryFunc, (void *) sin },
- { "sinh", ExprUnaryFunc, (void *) sinh },
+ { "sin", ExprUnaryFunc, sin },
+ { "sinh", ExprUnaryFunc, sinh },
{ "sqrt", ExprSqrtFunc, NULL },
{ "srand", ExprSrandFunc, NULL },
- { "tan", ExprUnaryFunc, (void *) tan },
- { "tanh", ExprUnaryFunc, (void *) tanh },
+ { "tan", ExprUnaryFunc, tan },
+ { "tanh", ExprUnaryFunc, tanh },
{ "wide", ExprWideFunc, NULL },
{ NULL, NULL, NULL }
};
@@ -657,7 +657,15 @@ Tcl_CreateInterp(void)
Tcl_Panic("Tcl_CallFrame must not be smaller than CallFrame");
}
-#if defined(_WIN32) && !defined(_WIN64)
+#if defined(_WIN32) && !defined(_WIN64) && !defined(_USE_64BIT_TIME_T) \
+ && !defined(__MINGW_USE_VC2005_COMPAT)
+ /* If Tcl is compiled on Win32 using -D_USE_64BIT_TIME_T or
+ * -D__MINGW_USE_VC2005_COMPAT, the result is a binary incompatible
+ * with the 'standard' build of Tcl: All extensions using Tcl_StatBuf
+ * or interal functions like TclpGetDate() need to be recompiled in
+ * the same way. Therefore, this is not officially supported.
+ * In stead, it is recommended to use Win64 or Tcl 9.0 (not released yet)
+ */
if (sizeof(time_t) != 4) {
/*NOTREACHED*/
Tcl_Panic("<time.h> is not compatible with MSVC");
@@ -1078,7 +1086,7 @@ Tcl_CreateInterp(void)
builtinFuncPtr++) {
strcpy(mathFuncName+MATH_FUNC_PREFIX_LEN, builtinFuncPtr->name);
Tcl_CreateObjCommand(interp, mathFuncName,
- builtinFuncPtr->objCmdProc, builtinFuncPtr->clientData, NULL);
+ builtinFuncPtr->objCmdProc, (void *)builtinFuncPtr->fn, NULL);
Tcl_Export(interp, nsPtr, builtinFuncPtr->name, 0);
}
@@ -2635,7 +2643,7 @@ TclCreateObjCommandInNs(
Tcl_Interp *interp,
const char *cmdName, /* Name of command, without any namespace
* components. */
- Tcl_Namespace *ns, /* The namespace to create the command in */
+ Tcl_Namespace *namesp, /* The namespace to create the command in */
Tcl_ObjCmdProc *proc, /* Object-based function to associate with
* name. */
ClientData clientData, /* Arbitrary value to pass to object
@@ -2649,7 +2657,7 @@ TclCreateObjCommandInNs(
ImportRef *oldRefPtr = NULL;
ImportedCmdData *dataPtr;
Tcl_HashEntry *hPtr;
- Namespace *nsPtr = (Namespace *) ns;
+ Namespace *nsPtr = (Namespace *) namesp;
/*
* If the command name we seek to create already exists, we need to delete
diff --git a/generic/tclCmdMZ.c b/generic/tclCmdMZ.c
index 0a5b745..3b4dfc8 100644
--- a/generic/tclCmdMZ.c
+++ b/generic/tclCmdMZ.c
@@ -4188,7 +4188,6 @@ Tcl_TimeRateObjCmd(
};
NRE_callback *rootPtr;
ByteCode *codePtr = NULL;
- int codeOptimized = 0;
for (i = 1; i < objc - 1; i++) {
int index;
@@ -4373,15 +4372,6 @@ Tcl_TimeRateObjCmd(
}
codePtr = TclCompileObj(interp, objPtr, NULL, 0);
TclPreserveByteCode(codePtr);
- /*
- * Replace last compiled done instruction with continue: it's a part of
- * iteration, this way evaluation will be more similar to a cycle (also
- * avoids extra overhead to set result to interp, etc.)
- */
- if (codePtr->codeStart[codePtr->numCodeBytes-1] == INST_DONE) {
- codePtr->codeStart[codePtr->numCodeBytes-1] = INST_CONTINUE;
- codeOptimized = 1;
- }
}
/*
@@ -4423,6 +4413,12 @@ Tcl_TimeRateObjCmd(
count++;
if (!direct) { /* precompiled */
rootPtr = TOP_CB(interp);
+ /*
+ * Use loop optimized TEBC call (TCL_EVAL_DISCARD_RESULT): it's a part of
+ * iteration, this way evaluation will be more similar to a cycle (also
+ * avoids extra overhead to set result to interp, etc.)
+ */
+ ((Interp *)interp)->evalFlags |= TCL_EVAL_DISCARD_RESULT;
result = TclNRExecuteByteCode(interp, codePtr);
result = TclNRRunCallbacks(interp, result, rootPtr);
} else { /* eval */
@@ -4675,11 +4671,6 @@ Tcl_TimeRateObjCmd(
done:
if (codePtr != NULL) {
- if ( codeOptimized
- && codePtr->codeStart[codePtr->numCodeBytes-1] == INST_CONTINUE
- ) {
- codePtr->codeStart[codePtr->numCodeBytes-1] = INST_DONE;
- }
TclReleaseByteCode(codePtr);
}
return result;
diff --git a/generic/tclCompCmds.c b/generic/tclCompCmds.c
index 6aa9705..56a98aa 100644
--- a/generic/tclCompCmds.c
+++ b/generic/tclCompCmds.c
@@ -3174,7 +3174,7 @@ TclCompileFormatCmd(
DefineLineInformation; /* TIP #280 */
Tcl_Token *tokenPtr = parsePtr->tokenPtr;
Tcl_Obj **objv, *formatObj, *tmpObj;
- char *bytes, *start;
+ const char *bytes, *start;
int i, j, len;
/*
@@ -3301,7 +3301,7 @@ TclCompileFormatCmd(
if (*++bytes == '%') {
Tcl_AppendToObj(tmpObj, "%", 1);
} else {
- char *b = TclGetStringFromObj(tmpObj, &len);
+ const char *b = TclGetStringFromObj(tmpObj, &len);
/*
* If there is a non-empty literal from the format string,
diff --git a/generic/tclCompCmdsGR.c b/generic/tclCompCmdsGR.c
index 43c4299..c282849 100644
--- a/generic/tclCompCmdsGR.c
+++ b/generic/tclCompCmdsGR.c
@@ -589,7 +589,7 @@ TclCompileInfoCommandsCmd(
DefineLineInformation; /* TIP #280 */
Tcl_Token *tokenPtr;
Tcl_Obj *objPtr;
- char *bytes;
+ const char *bytes;
/*
* We require one compile-time known argument for the case we can compile.
diff --git a/generic/tclCompCmdsSZ.c b/generic/tclCompCmdsSZ.c
index ea7ee09..ad47f66 100644
--- a/generic/tclCompCmdsSZ.c
+++ b/generic/tclCompCmdsSZ.c
@@ -925,7 +925,7 @@ TclCompileStringMapCmd(
DefineLineInformation; /* TIP #280 */
Tcl_Token *mapTokenPtr, *stringTokenPtr;
Tcl_Obj *mapObj, **objv;
- char *bytes;
+ const char *bytes;
int len;
/*
diff --git a/generic/tclCompile.h b/generic/tclCompile.h
index 6b30f8b..5e39a21 100644
--- a/generic/tclCompile.h
+++ b/generic/tclCompile.h
@@ -1217,7 +1217,7 @@ MODULE_SCOPE Tcl_Obj *TclGetInnerContext(Tcl_Interp *interp,
const unsigned char *pc, Tcl_Obj **tosPtr);
MODULE_SCOPE Tcl_Obj *TclNewInstNameObj(unsigned char inst);
MODULE_SCOPE int TclPushProcCallFrame(ClientData clientData,
- register Tcl_Interp *interp, int objc,
+ Tcl_Interp *interp, int objc,
Tcl_Obj *const objv[], int isLambda);
@@ -1405,7 +1405,7 @@ MODULE_SCOPE int TclPushProcCallFrame(ClientData clientData,
#define TclEmitPush(objIndex, envPtr) \
do { \
- register int _objIndexCopy = (objIndex); \
+ int _objIndexCopy = (objIndex); \
if (_objIndexCopy <= 255) { \
TclEmitInstInt1(INST_PUSH1, _objIndexCopy, (envPtr)); \
} else { \
diff --git a/generic/tclDTrace.d b/generic/tclDTrace.d
index 360bdff..f5493b1 100644
--- a/generic/tclDTrace.d
+++ b/generic/tclDTrace.d
@@ -10,7 +10,6 @@
*/
typedef struct Tcl_Obj Tcl_Obj;
-typedef const char* TclDTraceStr;
/*
* Tcl DTrace probes
@@ -25,14 +24,14 @@ provider tcl {
* arg1: number of arguments (int)
* arg2: array of proc argument objects (Tcl_Obj**)
*/
- probe proc__entry(TclDTraceStr name, int objc, struct Tcl_Obj **objv);
+ probe proc__entry(const char *name, int objc, struct Tcl_Obj **objv);
/*
* tcl*:::proc-return probe
* triggered immediately after proc bytecode execution
* arg0: proc name (string)
* arg1: return code (int)
*/
- probe proc__return(TclDTraceStr name, int code);
+ probe proc__return(const char *name, int code);
/*
* tcl*:::proc-result probe
* triggered after proc-return probe and result processing
@@ -41,7 +40,7 @@ provider tcl {
* arg2: proc result (string)
* arg3: proc result object (Tcl_Obj*)
*/
- probe proc__result(TclDTraceStr name, int code, TclDTraceStr result,
+ probe proc__result(const char *name, int code, const char *result,
struct Tcl_Obj *resultobj);
/*
* tcl*:::proc-args probe
@@ -50,10 +49,10 @@ provider tcl {
* arg0: proc name (string)
* arg1-arg9: proc arguments or NULL (strings)
*/
- probe proc__args(TclDTraceStr name, TclDTraceStr arg1, TclDTraceStr arg2,
- TclDTraceStr arg3, TclDTraceStr arg4, TclDTraceStr arg5,
- TclDTraceStr arg6, TclDTraceStr arg7, TclDTraceStr arg8,
- TclDTraceStr arg9);
+ probe proc__args(const char *name, const char *arg1, const char *arg2,
+ const char *arg3, const char *arg4, const char *arg5,
+ const char *arg6, const char *arg7, const char *arg8,
+ const char *arg9);
/*
* tcl*:::proc-info probe
* triggered before proc-entry probe, gives access to TIP 280
@@ -67,9 +66,9 @@ provider tcl {
* arg6: TclOO method (string)
* arg7: TclOO class/object (string)
*/
- probe proc__info(TclDTraceStr cmd, TclDTraceStr type, TclDTraceStr proc,
- TclDTraceStr file, int line, int level, TclDTraceStr method,
- TclDTraceStr class);
+ probe proc__info(const char *cmd, const char *type, const char *proc,
+ const char *file, int line, int level, const char *method,
+ const char *class);
/***************************** cmd probes ******************************/
/*
@@ -79,14 +78,14 @@ provider tcl {
* arg1: number of arguments (int)
* arg2: array of command argument objects (Tcl_Obj**)
*/
- probe cmd__entry(TclDTraceStr name, int objc, struct Tcl_Obj **objv);
+ probe cmd__entry(const char *name, int objc, struct Tcl_Obj **objv);
/*
* tcl*:::cmd-return probe
* triggered immediately after commmand execution
* arg0: command name (string)
* arg1: return code (int)
*/
- probe cmd__return(TclDTraceStr name, int code);
+ probe cmd__return(const char *name, int code);
/*
* tcl*:::cmd-result probe
* triggered after cmd-return probe and result processing
@@ -95,7 +94,7 @@ provider tcl {
* arg2: command result (string)
* arg3: command result object (Tcl_Obj*)
*/
- probe cmd__result(TclDTraceStr name, int code, TclDTraceStr result,
+ probe cmd__result(const char *name, int code, const char *result,
struct Tcl_Obj *resultobj);
/*
* tcl*:::cmd-args probe
@@ -104,10 +103,10 @@ provider tcl {
* arg0: command name (string)
* arg1-arg9: command arguments or NULL (strings)
*/
- probe cmd__args(TclDTraceStr name, TclDTraceStr arg1, TclDTraceStr arg2,
- TclDTraceStr arg3, TclDTraceStr arg4, TclDTraceStr arg5,
- TclDTraceStr arg6, TclDTraceStr arg7, TclDTraceStr arg8,
- TclDTraceStr arg9);
+ probe cmd__args(const char *name, const char *arg1, const char *arg2,
+ const char *arg3, const char *arg4, const char *arg5,
+ const char *arg6, const char *arg7, const char *arg8,
+ const char *arg9);
/*
* tcl*:::cmd-info probe
* triggered before cmd-entry probe, gives access to TIP 280
@@ -121,9 +120,9 @@ provider tcl {
* arg6: TclOO method (string)
* arg7: TclOO class/object (string)
*/
- probe cmd__info(TclDTraceStr cmd, TclDTraceStr type, TclDTraceStr proc,
- TclDTraceStr file, int line, int level, TclDTraceStr method,
- TclDTraceStr class);
+ probe cmd__info(const char *cmd, const char *type, const char *proc,
+ const char *file, int line, int level, const char *method,
+ const char *class);
/***************************** inst probes *****************************/
/*
@@ -133,7 +132,7 @@ provider tcl {
* arg1: depth of stack (int)
* arg2: top of stack (Tcl_Obj**)
*/
- probe inst__start(TclDTraceStr name, int depth, struct Tcl_Obj **stack);
+ probe inst__start(const char *name, int depth, struct Tcl_Obj **stack);
/*
* tcl*:::inst-done probe
* triggered immediately after execution of a bytecode
@@ -141,7 +140,7 @@ provider tcl {
* arg1: depth of stack (int)
* arg2: top of stack (Tcl_Obj**)
*/
- probe inst__done(TclDTraceStr name, int depth, struct Tcl_Obj **stack);
+ probe inst__done(const char *name, int depth, struct Tcl_Obj **stack);
/***************************** obj probes ******************************/
/*
@@ -163,10 +162,10 @@ provider tcl {
* triggered when the ::tcl::dtrace command is called
* arg0-arg9: command arguments (strings)
*/
- probe tcl__probe(TclDTraceStr arg0, TclDTraceStr arg1, TclDTraceStr arg2,
- TclDTraceStr arg3, TclDTraceStr arg4, TclDTraceStr arg5,
- TclDTraceStr arg6, TclDTraceStr arg7, TclDTraceStr arg8,
- TclDTraceStr arg9);
+ probe tcl__probe(const char *arg0, const char *arg1, const char *arg2,
+ const char *arg3, const char *arg4, const char *arg5,
+ const char *arg6, const char *arg7, const char *arg8,
+ const char *arg9);
};
/*
@@ -174,7 +173,7 @@ provider tcl {
*/
typedef struct Tcl_ObjType {
- char *name;
+ const char *name;
void *freeIntRepProc;
void *dupIntRepProc;
void *updateStringProc;
@@ -185,7 +184,7 @@ struct Tcl_Obj {
int refCount;
char *bytes;
int length;
- Tcl_ObjType *typePtr;
+ const Tcl_ObjType *typePtr;
union {
long longValue;
double doubleValue;
diff --git a/generic/tclEnsemble.c b/generic/tclEnsemble.c
index 3e288c5..761d879 100644
--- a/generic/tclEnsemble.c
+++ b/generic/tclEnsemble.c
@@ -2580,7 +2580,7 @@ BuildEnsembleConfig(
if (subList) {
int subc;
Tcl_Obj **subv, *target, *cmdObj, *cmdPrefixObj;
- char *name;
+ const char *name;
/*
* There is a list of exactly what subcommands go in the table.
@@ -2665,7 +2665,7 @@ BuildEnsembleConfig(
Tcl_DictObjFirst(NULL, ensemblePtr->subcommandDict, &dictSearch,
&keyObj, &valueObj, &done);
while (!done) {
- char *name = TclGetString(keyObj);
+ const char *name = TclGetString(keyObj);
hPtr = Tcl_CreateHashEntry(hash, name, &isNew);
Tcl_SetHashValue(hPtr, valueObj);
@@ -3379,7 +3379,7 @@ CompileToInvokedCommand(
{
Tcl_Token *tokPtr;
Tcl_Obj *objPtr, **words;
- char *bytes;
+ const char *bytes;
int i, numWords, cmdLit, extraLiteralFlags = LITERAL_CMD_NAME;
DefineLineInformation;
diff --git a/generic/tclEnv.c b/generic/tclEnv.c
index 865a330..5e840e9 100644
--- a/generic/tclEnv.c
+++ b/generic/tclEnv.c
@@ -454,18 +454,18 @@ TclUnsetEnv(
*/
#if defined(_WIN32)
- string = ckalloc(length + 2);
+ string = (char *)ckalloc(length + 2);
memcpy(string, name, length);
string[length] = '=';
string[length+1] = '\0';
#else
- string = ckalloc(length + 1);
+ string = (char *)ckalloc(length + 1);
memcpy(string, name, length);
string[length] = '\0';
#endif /* _WIN32 */
Tcl_UtfToExternalDString(NULL, string, -1, &envString);
- string = ckrealloc(string, Tcl_DStringLength(&envString) + 1);
+ string = (char *)ckrealloc(string, Tcl_DStringLength(&envString) + 1);
memcpy(string, Tcl_DStringValue(&envString),
Tcl_DStringLength(&envString)+1);
Tcl_DStringFree(&envString);
diff --git a/generic/tclExecute.c b/generic/tclExecute.c
index f977ce8..f085c57 100644
--- a/generic/tclExecute.c
+++ b/generic/tclExecute.c
@@ -1981,7 +1981,14 @@ TclNRExecuteByteCode(
*/
TclNRAddCallback(interp, TEBCresume, TD, /* pc */ NULL,
- /* cleanup */ INT2PTR(0), NULL);
+ /* cleanup */ INT2PTR(0), INT2PTR(iPtr->evalFlags));
+
+ /*
+ * Reset discard result flag - because it is applicable for this call only,
+ * and should not affect all the nested invocations may return result.
+ */
+ iPtr->evalFlags &= ~TCL_EVAL_DISCARD_RESULT;
+
return TCL_OK;
}
@@ -2043,6 +2050,7 @@ TEBCresume(
#define auxObjList (TD->auxObjList)
#define catchTop (TD->catchTop)
#define codePtr (TD->codePtr)
+#define curEvalFlags PTR2INT(data[3]) /* calling iPtr->evalFlags */
/*
* Globals: variables that store state, must remain valid at all times.
@@ -2526,6 +2534,14 @@ TEBCresume(
case INST_DONE:
if (tosPtr > initTosPtr) {
+
+ if ((curEvalFlags & TCL_EVAL_DISCARD_RESULT) && (result == TCL_OK)) {
+ /* simulate pop & fast done (like it does continue in loop) */
+ TRACE_WITH_OBJ(("=> discarding "), OBJ_AT_TOS);
+ objPtr = POP_OBJECT();
+ TclDecrRefCount(objPtr);
+ goto abnormalReturn;
+ }
/*
* Set the interpreter's object result to point to the topmost
* object from the stack, and check for a possible [catch]. The
@@ -7695,7 +7711,7 @@ TEBCresume(
*/
/*
- * Abnormal return code. Restore the stack to state it had when
+ * Done or abnormal return code. Restore the stack to state it had when
* starting to execute the ByteCode. Panic if the stack is below the
* initial level.
*/
diff --git a/generic/tclIOUtil.c b/generic/tclIOUtil.c
index c0c1d24..e7efc8e 100644
--- a/generic/tclIOUtil.c
+++ b/generic/tclIOUtil.c
@@ -86,16 +86,6 @@ static void Disclaim(void);
static void * DivertFindSymbol(Tcl_Interp *interp,
Tcl_LoadHandle loadHandle, const char *symbol);
static void DivertUnloadFile(Tcl_LoadHandle loadHandle);
-
-/*
- * These form part of the native filesystem support. They are needed here
- * because we have a few native filesystem functions (which are the same for
- * win/unix) in this file. There is no need to place them in tclInt.h, because
- * they are not (and should not be) used anywhere else.
- */
-
-MODULE_SCOPE const char *const tclpFileAttrStrings[];
-MODULE_SCOPE const TclFileAttrProcs tclpFileAttrProcs[];
/*
* Declare the native filesystem support. These functions should be considered
@@ -1392,7 +1382,7 @@ TclFSNormalizeToUniquePath(
int i;
int isVfsPath = 0;
- char *path;
+ const char *path;
/*
* Paths starting with a UNC prefix whose final character is a colon
diff --git a/generic/tclInt.h b/generic/tclInt.h
index 057627b..0d1f137 100644
--- a/generic/tclInt.h
+++ b/generic/tclInt.h
@@ -2259,6 +2259,7 @@ typedef struct Interp {
#define TCL_EVAL_FILE 0x02
#define TCL_EVAL_SOURCE_IN_FRAME 0x10
#define TCL_EVAL_NORESOLVE 0x20
+#define TCL_EVAL_DISCARD_RESULT 0x40
/*
* Flag bits for Interp structures:
@@ -4234,7 +4235,6 @@ MODULE_SCOPE int TclIndexDecode(int encoded, int endValue);
#ifdef USE_DTRACE
#ifndef _TCLDTRACE_H
-typedef const char *TclDTraceStr;
#include "tclDTrace.h"
#endif
#define TCL_DTRACE_OBJ_CREATE(objPtr) TCL_OBJ_CREATE(objPtr)
@@ -4512,6 +4512,21 @@ MODULE_SCOPE void TclDbInitNewObj(Tcl_Obj *objPtr, const char *file,
}
/*
+ * These form part of the native filesystem support. They are needed here
+ * because we have a few native filesystem functions (which are the same for
+ * win/unix) in this file.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+MODULE_SCOPE const char *const tclpFileAttrStrings[];
+MODULE_SCOPE const TclFileAttrProcs tclpFileAttrProcs[];
+#ifdef __cplusplus
+}
+#endif
+
+/*
*----------------------------------------------------------------
* Macro used by the Tcl core to test whether an object has a
* string representation (or is a 'pure' internal value).
@@ -4535,8 +4550,8 @@ MODULE_SCOPE void TclDbInitNewObj(Tcl_Obj *objPtr, const char *file,
#define TclUnpackBignum(objPtr, bignum) \
do { \
- register Tcl_Obj *bignumObj = (objPtr); \
- register int bignumPayload = \
+ Tcl_Obj *bignumObj = (objPtr); \
+ int bignumPayload = \
PTR2INT(bignumObj->internalRep.twoPtrValue.ptr2); \
if (bignumPayload == -1) { \
(bignum) = *((mp_int *) bignumObj->internalRep.twoPtrValue.ptr1); \
diff --git a/generic/tclLiteral.c b/generic/tclLiteral.c
index 345574b..f86eab6 100644
--- a/generic/tclLiteral.c
+++ b/generic/tclLiteral.c
@@ -209,7 +209,7 @@ TclCreateLiteral(
*/
int objLength;
- char *objBytes = TclGetStringFromObj(objPtr, &objLength);
+ const char *objBytes = TclGetStringFromObj(objPtr, &objLength);
if ((objLength == length) && ((length == 0)
|| ((objBytes[0] == bytes[0])
diff --git a/generic/tclMain.c b/generic/tclMain.c
index 5fe4f43..e547738 100644
--- a/generic/tclMain.c
+++ b/generic/tclMain.c
@@ -60,7 +60,7 @@
*/
#if defined(UNICODE) && (TCL_UTF_MAX <= 4)
-# define NewNativeObj Tcl_NewUnicodeObj
+# define NewNativeObj(a,b) Tcl_NewUnicodeObj((const Tcl_UniChar *)a,b)
#else /* !UNICODE || (TCL_UTF_MAX > 4) */
static inline Tcl_Obj *
NewNativeObj(
diff --git a/generic/tclObj.c b/generic/tclObj.c
index 8e13e4f..7a31697 100644
--- a/generic/tclObj.c
+++ b/generic/tclObj.c
@@ -3018,6 +3018,7 @@ Tcl_GetLongFromObj(
* values in the unsigned long range will fit in a long.
*/
+ {
mp_int big;
unsigned long scratch, value = 0, numBytes = sizeof(unsigned long);
unsigned char *bytes = (unsigned char *) &scratch;
@@ -3039,6 +3040,7 @@ Tcl_GetLongFromObj(
}
}
}
+ }
#ifndef TCL_WIDE_INT_IS_LONG
tooLarge:
#endif
diff --git a/generic/tclPanic.c b/generic/tclPanic.c
index e8c1e7f..1096ead 100644
--- a/generic/tclPanic.c
+++ b/generic/tclPanic.c
@@ -51,7 +51,7 @@ Tcl_SetPanicProc(
{
#if defined(_WIN32)
/* tclWinDebugPanic only installs if there is no panicProc yet. */
- if ((proc != tclWinDebugPanic) || (panicProc == NULL))
+ if (((Tcl_PanicProc *)proc != tclWinDebugPanic) || (panicProc == NULL))
#elif defined(__CYGWIN__)
if (proc == NULL)
panicProc = tclWinDebugPanic;
diff --git a/generic/tclPathObj.c b/generic/tclPathObj.c
index 51659ee..34598d6 100644
--- a/generic/tclPathObj.c
+++ b/generic/tclPathObj.c
@@ -2242,7 +2242,7 @@ SetFsPathFromAny(
int len;
FsPath *fsPathPtr;
Tcl_Obj *transPtr;
- char *name;
+ const char *name;
if (TclHasIntRep(pathPtr, &fsPathType)) {
return TCL_OK;
diff --git a/generic/tclProc.c b/generic/tclProc.c
index 1b344de..f0974bf 100644
--- a/generic/tclProc.c
+++ b/generic/tclProc.c
@@ -157,7 +157,7 @@ Tcl_ProcObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register Interp *iPtr = (Interp *) interp;
+ Interp *iPtr = (Interp *) interp;
Proc *procPtr;
const char *procName;
const char *simpleName, *procArgs, *procBody;
@@ -761,7 +761,7 @@ TclObjGetFrame(
CallFrame **framePtrPtr) /* Store pointer to frame here (or NULL if
* global frame indicated). */
{
- register Interp *iPtr = (Interp *) interp;
+ Interp *iPtr = (Interp *) interp;
int curLevel, level, result;
const Tcl_ObjIntRep *irPtr;
const char *name = NULL;
@@ -898,7 +898,7 @@ TclNRUplevelObjCmd(
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register Interp *iPtr = (Interp *) interp;
+ Interp *iPtr = (Interp *) interp;
CmdFrame *invoker = NULL;
int word = 0;
int result;
@@ -1038,7 +1038,7 @@ ProcWrongNumArgs(
int skip)
{
CallFrame *framePtr = ((Interp *)interp)->varFramePtr;
- register Proc *procPtr = framePtr->procPtr;
+ Proc *procPtr = framePtr->procPtr;
int localCt = procPtr->numCompiledLocals, numArgs, i;
Tcl_Obj **desiredObjs;
const char *final = NULL;
@@ -1063,7 +1063,7 @@ ProcWrongNumArgs(
Tcl_IncrRefCount(desiredObjs[0]);
if (localCt > 0) {
- register Var *defPtr = (Var *) (&framePtr->localCachePtr->varName0 + localCt);
+ Var *defPtr = (Var *) (&framePtr->localCachePtr->varName0 + localCt);
for (i=1 ; i<=numArgs ; i++, defPtr++) {
Tcl_Obj *argObj;
@@ -1254,7 +1254,7 @@ InitResolvedLocals(
resVarInfo = localPtr->resolveInfo;
if (resVarInfo && resVarInfo->fetchProc) {
- register Var *resolvedVarPtr = (Var *)
+ Var *resolvedVarPtr = (Var *)
resVarInfo->fetchProc(interp, resVarInfo);
if (resolvedVarPtr) {
@@ -1277,7 +1277,7 @@ TclFreeLocalCache(
Tcl_Obj **namePtrPtr = &localCachePtr->varName0;
for (i = 0; i < localCachePtr->numVars; i++, namePtrPtr++) {
- register Tcl_Obj *objPtr = *namePtrPtr;
+ Tcl_Obj *objPtr = *namePtrPtr;
if (objPtr) {
/* TclReleaseLiteral calls Tcl_DecrRefCount for us */
@@ -1363,16 +1363,16 @@ InitLocalCache(
static int
InitArgsAndLocals(
- register Tcl_Interp *interp,/* Interpreter in which procedure was
+ Tcl_Interp *interp,/* Interpreter in which procedure was
* invoked. */
Tcl_Obj *procNameObj, /* Procedure name for error reporting. */
int skip) /* Number of initial arguments to be skipped,
* i.e., words in the "command name". */
{
CallFrame *framePtr = ((Interp *)interp)->varFramePtr;
- register Proc *procPtr = framePtr->procPtr;
+ Proc *procPtr = framePtr->procPtr;
ByteCode *codePtr;
- register Var *varPtr, *defPtr;
+ Var *varPtr, *defPtr;
int localCt = procPtr->numCompiledLocals, numArgs, argCt, i, imax;
Tcl_Obj *const *argObjs;
@@ -1530,7 +1530,7 @@ int
TclPushProcCallFrame(
ClientData clientData, /* Record describing procedure to be
* interpreted. */
- register Tcl_Interp *interp,/* Interpreter in which procedure was
+ Tcl_Interp *interp,/* Interpreter in which procedure was
* invoked. */
int objc, /* Count of number of arguments to this
* procedure. */
@@ -1622,7 +1622,7 @@ int
TclObjInterpProc(
ClientData clientData, /* Record describing procedure to be
* interpreted. */
- register Tcl_Interp *interp,/* Interpreter in which procedure was
+ Tcl_Interp *interp,/* Interpreter in which procedure was
* invoked. */
int objc, /* Count of number of arguments to this
* procedure. */
@@ -1639,7 +1639,7 @@ int
TclNRInterpProc(
ClientData clientData, /* Record describing procedure to be
* interpreted. */
- register Tcl_Interp *interp,/* Interpreter in which procedure was
+ Tcl_Interp *interp,/* Interpreter in which procedure was
* invoked. */
int objc, /* Count of number of arguments to this
* procedure. */
@@ -1674,7 +1674,7 @@ TclNRInterpProc(
int
TclNRInterpProcCore(
- register Tcl_Interp *interp,/* Interpreter in which procedure was
+ Tcl_Interp *interp,/* Interpreter in which procedure was
* invoked. */
Tcl_Obj *procNameObj, /* Procedure name for error reporting. */
int skip, /* Number of initial arguments to be skipped,
@@ -1683,7 +1683,7 @@ TclNRInterpProcCore(
* results of the overall procedure. */
{
Interp *iPtr = (Interp *) interp;
- register Proc *procPtr = iPtr->varFramePtr->procPtr;
+ Proc *procPtr = iPtr->varFramePtr->procPtr;
int result;
CallFrame *freePtr;
ByteCode *codePtr;
@@ -1700,8 +1700,8 @@ TclNRInterpProcCore(
#if defined(TCL_COMPILE_DEBUG)
if (tclTraceExec >= 1) {
- register CallFrame *framePtr = iPtr->varFramePtr;
- register int i;
+ CallFrame *framePtr = iPtr->varFramePtr;
+ int i;
if (framePtr->isProcCallFrame & FRAME_IS_LAMBDA) {
fprintf(stdout, "Calling lambda ");
@@ -2119,9 +2119,9 @@ TclProcDeleteProc(
void
TclProcCleanupProc(
- register Proc *procPtr) /* Procedure to be deleted. */
+ Proc *procPtr) /* Procedure to be deleted. */
{
- register CompiledLocal *localPtr;
+ CompiledLocal *localPtr;
Tcl_Obj *bodyPtr = procPtr->bodyPtr;
Tcl_Obj *defPtr;
Tcl_ResolvedVarInfo *resVarInfo;
@@ -2370,7 +2370,7 @@ ProcBodyFree(
static void
DupLambdaInternalRep(
Tcl_Obj *srcPtr, /* Object with internal rep to copy. */
- register Tcl_Obj *copyPtr) /* Object with internal rep to set. */
+ Tcl_Obj *copyPtr) /* Object with internal rep to set. */
{
Proc *procPtr;
Tcl_Obj *nsObjPtr;
@@ -2385,7 +2385,7 @@ DupLambdaInternalRep(
static void
FreeLambdaInternalRep(
- register Tcl_Obj *objPtr) /* CmdName object with internal representation
+ Tcl_Obj *objPtr) /* CmdName object with internal representation
* to free. */
{
Proc *procPtr;
@@ -2403,7 +2403,7 @@ FreeLambdaInternalRep(
static int
SetLambdaFromAny(
Tcl_Interp *interp, /* Used for error reporting if not NULL. */
- register Tcl_Obj *objPtr) /* The object to convert. */
+ Tcl_Obj *objPtr) /* The object to convert. */
{
Interp *iPtr = (Interp *) interp;
const char *name;
diff --git a/generic/tclResult.c b/generic/tclResult.c
index 1d758de..5e85e25 100644
--- a/generic/tclResult.c
+++ b/generic/tclResult.c
@@ -832,19 +832,19 @@ SetupAppendBuffer(
totalSpace = newSpace + iPtr->appendUsed;
if (totalSpace >= iPtr->appendAvl) {
- char *newStr;
+ char *newSpace;
if (totalSpace < 100) {
totalSpace = 200;
} else {
totalSpace *= 2;
}
- newStr = (char *)ckalloc(totalSpace);
- strcpy(newStr, iPtr->result);
+ newSpace = (char *)ckalloc(totalSpace);
+ strcpy(newSpace, iPtr->result);
if (iPtr->appendResult != NULL) {
ckfree(iPtr->appendResult);
}
- iPtr->appendResult = newStr;
+ iPtr->appendResult = newSpace;
iPtr->appendAvl = totalSpace;
} else if (iPtr->result != iPtr->appendResult) {
strcpy(iPtr->appendResult, iPtr->result);
diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c
index e677bd4..16a7a71 100644
--- a/generic/tclStringObj.c
+++ b/generic/tclStringObj.c
@@ -3563,7 +3563,7 @@ TclStringFirst(
}
if (TclIsPureByteArray(needle) && TclIsPureByteArray(haystack)) {
- unsigned char *end, *tryIt, *bh;
+ unsigned char *end, *check, *bh;
unsigned char *bn = Tcl_GetByteArrayFromObj(needle, &ln);
/* Find bytes in bytes */
@@ -3574,25 +3574,25 @@ TclStringFirst(
}
end = bh + lh;
- tryIt = bh + start;
- while (tryIt + ln <= end) {
+ check = bh + start;
+ while (check + ln <= end) {
/*
* Look for the leading byte of the needle in the haystack
- * starting at try and stopping when there's not enough room
+ * starting at check and stopping when there's not enough room
* for the needle left.
*/
- tryIt = (unsigned char *)memchr(tryIt, bn[0], (end + 1 - ln) - tryIt);
- if (tryIt == NULL) {
+ check = (unsigned char *)memchr(check, bn[0], (end + 1 - ln) - check);
+ if (check == NULL) {
/* Leading byte not found -> needle cannot be found. */
return -1;
}
/* Leading byte found, check rest of needle. */
- if (0 == memcmp(tryIt+1, bn+1, ln-1)) {
+ if (0 == memcmp(check+1, bn+1, ln-1)) {
/* Checks! Return the successful index. */
- return (tryIt - bh);
+ return (check - bh);
}
/* Rest of needle match failed; Iterate to continue search. */
- tryIt++;
+ check++;
}
return -1;
}
@@ -3610,7 +3610,7 @@ TclStringFirst(
*/
{
- Tcl_UniChar *tryIt, *end, *uh;
+ Tcl_UniChar *check, *end, *uh;
Tcl_UniChar *un = Tcl_GetUnicodeFromObj(needle, &ln);
uh = Tcl_GetUnicodeFromObj(haystack, &lh);
@@ -3620,10 +3620,10 @@ TclStringFirst(
}
end = uh + lh;
- for (tryIt = uh + start; tryIt + ln <= end; tryIt++) {
- if ((*tryIt == *un) && (0 ==
- memcmp(tryIt + 1, un + 1, (ln-1) * sizeof(Tcl_UniChar)))) {
- return (tryIt - uh);
+ for (check = uh + start; check + ln <= end; check++) {
+ if ((*check == *un) && (0 ==
+ memcmp(check + 1, un + 1, (ln-1) * sizeof(Tcl_UniChar)))) {
+ return (check - uh);
}
}
return -1;
@@ -3667,7 +3667,7 @@ TclStringLast(
}
if (TclIsPureByteArray(needle) && TclIsPureByteArray(haystack)) {
- unsigned char *tryIt, *bh = Tcl_GetByteArrayFromObj(haystack, &lh);
+ unsigned char *check, *bh = Tcl_GetByteArrayFromObj(haystack, &lh);
unsigned char *bn = Tcl_GetByteArrayFromObj(needle, &ln);
if (last >= lh) {
@@ -3677,20 +3677,20 @@ TclStringLast(
/* Don't start the loop if there cannot be a valid answer */
return -1;
}
- tryIt = bh + last + 1 - ln;
+ check = bh + last + 1 - ln;
- while (tryIt >= bh) {
- if ((*tryIt == bn[0])
- && (0 == memcmp(tryIt+1, bn+1, ln-1))) {
- return (tryIt - bh);
+ while (check >= bh) {
+ if ((*check == bn[0])
+ && (0 == memcmp(check+1, bn+1, ln-1))) {
+ return (check - bh);
}
- tryIt--;
+ check--;
}
return -1;
}
{
- Tcl_UniChar *tryIt, *uh = Tcl_GetUnicodeFromObj(haystack, &lh);
+ Tcl_UniChar *check, *uh = Tcl_GetUnicodeFromObj(haystack, &lh);
Tcl_UniChar *un = Tcl_GetUnicodeFromObj(needle, &ln);
if (last >= lh) {
@@ -3700,13 +3700,13 @@ TclStringLast(
/* Don't start the loop if there cannot be a valid answer */
return -1;
}
- tryIt = uh + last + 1 - ln;
- while (tryIt >= uh) {
- if ((*tryIt == un[0])
- && (0 == memcmp(tryIt+1, un+1, (ln-1)*sizeof(Tcl_UniChar)))) {
- return (tryIt - uh);
+ check = uh + last + 1 - ln;
+ while (check >= uh) {
+ if ((*check == un[0])
+ && (0 == memcmp(check+1, un+1, (ln-1)*sizeof(Tcl_UniChar)))) {
+ return (check - uh);
}
- tryIt--;
+ check--;
}
return -1;
}
diff --git a/generic/tclTest.c b/generic/tclTest.c
index 166334a..af68ad5 100644
--- a/generic/tclTest.c
+++ b/generic/tclTest.c
@@ -2403,11 +2403,11 @@ ExitProcOdd(
void *clientData) /* Integer value to print. */
{
char buf[16 + TCL_INTEGER_SPACE];
- size_t len;
+ int len;
- sprintf(buf, "odd %" TCL_Z_MODIFIER "d\n", (size_t)PTR2INT(clientData));
+ sprintf(buf, "odd %d\n", (int)PTR2INT(clientData));
len = strlen(buf);
- if (len != (size_t) write(1, buf, len)) {
+ if (len != (int) write(1, buf, len)) {
Tcl_Panic("ExitProcOdd: unable to write to stdout");
}
}
@@ -2417,11 +2417,11 @@ ExitProcEven(
void *clientData) /* Integer value to print. */
{
char buf[16 + TCL_INTEGER_SPACE];
- size_t len;
+ int len;
- sprintf(buf, "even %" TCL_Z_MODIFIER "d\n", (size_t)PTR2INT(clientData));
+ sprintf(buf, "even %d\n", (int)PTR2INT(clientData));
len = strlen(buf);
- if (len != (size_t) write(1, buf, len)) {
+ if (len != (int) write(1, buf, len)) {
Tcl_Panic("ExitProcEven: unable to write to stdout");
}
}
diff --git a/generic/tclThreadJoin.c b/generic/tclThreadJoin.c
index 5c70a62..0aff0a7 100644
--- a/generic/tclThreadJoin.c
+++ b/generic/tclThreadJoin.c
@@ -230,7 +230,7 @@ TclRememberJoinableThread(
{
JoinableThread *threadPtr;
- threadPtr = ckalloc(sizeof(JoinableThread));
+ threadPtr = (JoinableThread *)ckalloc(sizeof(JoinableThread));
threadPtr->id = id;
threadPtr->done = 0;
threadPtr->waitedUpon = 0;
diff --git a/generic/tclZipfs.c b/generic/tclZipfs.c
index 983d62f..598520c 100644
--- a/generic/tclZipfs.c
+++ b/generic/tclZipfs.c
@@ -1167,7 +1167,7 @@ ZipFSOpenArchive(
ZIPFS_POSIX_ERROR(interp, "file mapping failed");
goto error;
}
- zf->data = MapViewOfFile(zf->mountHandle, FILE_MAP_READ, 0, 0,
+ zf->data = (unsigned char *)MapViewOfFile(zf->mountHandle, FILE_MAP_READ, 0, 0,
zf->length);
if (!zf->data) {
ZIPFS_POSIX_ERROR(interp, "file mapping failed");