summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2019-04-04 21:31:01 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2019-04-04 21:31:01 (GMT)
commit889e874282cb68715c4fa329df827d6fe0ebc84d (patch)
tree821a4ea16fdaf69e0027f11970bfa888248fe9af /generic
parent7d8a7adc9fda349a9676b23e95dc03fb6af56f93 (diff)
parent68d03f6af89984e9495654c0637685ab7708b3f6 (diff)
downloadtcl-889e874282cb68715c4fa329df827d6fe0ebc84d.zip
tcl-889e874282cb68715c4fa329df827d6fe0ebc84d.tar.gz
tcl-889e874282cb68715c4fa329df827d6fe0ebc84d.tar.bz2
Merge 8.7
Undo Tcl-specific changes in bn_mp_sqrt.c, and re-enable the two disabled test-cases: This proves the observed crash with DIBIT_BIT=60 is caused by those Tcl-specific changes!
Diffstat (limited to 'generic')
-rw-r--r--generic/tclCmdAH.c6
-rw-r--r--generic/tclCmdMZ.c12
-rw-r--r--generic/tclProcess.c4
-rw-r--r--generic/tclTest.c21
-rw-r--r--generic/tclTestObj.c26
-rw-r--r--generic/tclTestProcBodyObj.c2
-rw-r--r--generic/tclUtil.c6
-rw-r--r--generic/tclZlib.c6
8 files changed, 52 insertions, 31 deletions
diff --git a/generic/tclCmdAH.c b/generic/tclCmdAH.c
index 331f791..1811c5c 100644
--- a/generic/tclCmdAH.c
+++ b/generic/tclCmdAH.c
@@ -932,7 +932,7 @@ Tcl_ExitObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- int value;
+ Tcl_WideInt value;
if ((objc != 1) && (objc != 2)) {
Tcl_WrongNumArgs(interp, 1, objv, "?returnCode?");
@@ -941,10 +941,10 @@ Tcl_ExitObjCmd(
if (objc == 1) {
value = 0;
- } else if (Tcl_GetIntFromObj(interp, objv[1], &value) != TCL_OK) {
+ } else if (TclGetWideBitsFromObj(interp, objv[1], &value) != TCL_OK) {
return TCL_ERROR;
}
- Tcl_Exit(value);
+ Tcl_Exit((int)value);
/*NOTREACHED*/
return TCL_OK; /* Better not ever reach this! */
}
diff --git a/generic/tclCmdMZ.c b/generic/tclCmdMZ.c
index 8767ca6..2671d49 100644
--- a/generic/tclCmdMZ.c
+++ b/generic/tclCmdMZ.c
@@ -4373,6 +4373,11 @@ usage:
middle *= TclpWideClickInMicrosec();
#endif
+ if (!count) { /* no iterations - avoid divide by zero */
+ objs[0] = objs[2] = objs[4] = Tcl_NewWideIntObj(0);
+ goto retRes;
+ }
+
/* if not calibrate */
if (!calibrate) {
/* minimize influence of measurement overhead */
@@ -4425,9 +4430,14 @@ usage:
objs[4] = Tcl_NewWideIntObj((count / middle) * 1000000);
}
+ retRes:
/* estimated net execution time (in millisecs) */
if (!calibrate) {
- objs[6] = Tcl_ObjPrintf("%.3f", (double)middle / 1000);
+ if (middle >= 1) {
+ objs[6] = Tcl_ObjPrintf("%.3f", (double)middle / 1000);
+ } else {
+ objs[6] = Tcl_NewWideIntObj(0);
+ }
TclNewLiteralStringObj(objs[7], "nett-ms");
}
diff --git a/generic/tclProcess.c b/generic/tclProcess.c
index a781386..2f3f4ba 100644
--- a/generic/tclProcess.c
+++ b/generic/tclProcess.c
@@ -540,7 +540,7 @@ ProcessStatusObjCmd(
dict = Tcl_NewDictObj();
Tcl_MutexLock(&infoTablesMutex);
for (i = 0; i < numPids; i++) {
- result = Tcl_GetIntFromObj(interp, pidObjs[i], (int *) &pid);
+ result = Tcl_GetIntFromObj(interp, pidObjs[i], &pid);
if (result != TCL_OK) {
Tcl_MutexUnlock(&infoTablesMutex);
Tcl_DecrRefCount(dict);
@@ -654,7 +654,7 @@ ProcessPurgeObjCmd(
}
Tcl_MutexLock(&infoTablesMutex);
for (i = 0; i < numPids; i++) {
- result = Tcl_GetIntFromObj(interp, pidObjs[i], (int *) &pid);
+ result = Tcl_GetIntFromObj(interp, pidObjs[i], &pid);
if (result != TCL_OK) {
Tcl_MutexUnlock(&infoTablesMutex);
return result;
diff --git a/generic/tclTest.c b/generic/tclTest.c
index dde4496..26f2c37 100644
--- a/generic/tclTest.c
+++ b/generic/tclTest.c
@@ -53,6 +53,7 @@ DLLEXPORT int Tcltest_SafeInit(Tcl_Interp *interp);
static Tcl_DString delString;
static Tcl_Interp *delInterp;
+static const Tcl_ObjType *properByteArrayType;
/*
* One of the following structures exists for each asynchronous handler
@@ -553,8 +554,7 @@ int
Tcltest_Init(
Tcl_Interp *interp) /* Interpreter for application. */
{
- Tcl_Obj *listPtr;
- Tcl_Obj **objv;
+ Tcl_Obj **objv, *objPtr;
int objc, index;
static const char *const specialOptions[] = {
"-appinitprocerror", "-appinitprocdeleteinterp",
@@ -576,6 +576,11 @@ Tcltest_Init(
return TCL_ERROR;
}
+ objPtr = Tcl_NewStringObj("abc", 3);
+ (void)Tcl_GetByteArrayFromObj(objPtr, &index);
+ properByteArrayType = objPtr->typePtr;
+ Tcl_DecrRefCount(objPtr);
+
/*
* Create additional commands and math functions for testing Tcl.
*/
@@ -741,9 +746,9 @@ Tcltest_Init(
* Check for special options used in ../tests/main.test
*/
- listPtr = Tcl_GetVar2Ex(interp, "argv", NULL, TCL_GLOBAL_ONLY);
- if (listPtr != NULL) {
- if (Tcl_ListObjGetElements(interp, listPtr, &objc, &objv) != TCL_OK) {
+ objPtr = Tcl_GetVar2Ex(interp, "argv", NULL, TCL_GLOBAL_ONLY);
+ if (objPtr != NULL) {
+ if (Tcl_ListObjGetElements(interp, objPtr, &objc, &objv) != TCL_OK) {
return TCL_ERROR;
}
if (objc && (Tcl_GetIndexFromObj(NULL, objv[0], specialOptions, NULL,
@@ -5012,7 +5017,7 @@ TestbytestringObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* The argument objects. */
{
- int n;
+ int n = 0;
const char *p;
if (objc != 2) {
@@ -5020,6 +5025,10 @@ TestbytestringObjCmd(
return TCL_ERROR;
}
p = (const char *)Tcl_GetByteArrayFromObj(objv[1], &n);
+ if ((p == NULL) || !Tcl_FetchIntRep(objv[1], properByteArrayType)) {
+ Tcl_AppendResult(interp, "testbytestring expects bytes", NULL);
+ return TCL_ERROR;
+ }
Tcl_SetObjResult(interp, Tcl_NewStringObj(p, n));
return TCL_OK;
}
diff --git a/generic/tclTestObj.c b/generic/tclTestObj.c
index 8f12fd6..a289e32 100644
--- a/generic/tclTestObj.c
+++ b/generic/tclTestObj.c
@@ -385,9 +385,9 @@ TestbooleanobjCmd(
*/
if ((varPtr[varIndex] != NULL) && !Tcl_IsShared(varPtr[varIndex])) {
- Tcl_SetBooleanObj(varPtr[varIndex], boolValue);
+ Tcl_SetWideIntObj(varPtr[varIndex], boolValue != 0);
} else {
- SetVarToObj(varPtr, varIndex, Tcl_NewBooleanObj(boolValue));
+ SetVarToObj(varPtr, varIndex, Tcl_NewWideIntObj(boolValue != 0));
}
Tcl_SetObjResult(interp, varPtr[varIndex]);
} else if (strcmp(subCmd, "get") == 0) {
@@ -410,9 +410,9 @@ TestbooleanobjCmd(
return TCL_ERROR;
}
if (!Tcl_IsShared(varPtr[varIndex])) {
- Tcl_SetBooleanObj(varPtr[varIndex], !boolValue);
+ Tcl_SetWideIntObj(varPtr[varIndex], boolValue == 0);
} else {
- SetVarToObj(varPtr, varIndex, Tcl_NewBooleanObj(!boolValue));
+ SetVarToObj(varPtr, varIndex, Tcl_NewWideIntObj(boolValue == 0));
}
Tcl_SetObjResult(interp, varPtr[varIndex]);
} else {
@@ -658,7 +658,7 @@ TestintobjCmd(
Tcl_Obj *const objv[]) /* Argument objects. */
{
int intValue, varIndex, i;
- long longValue;
+ Tcl_WideInt wideValue;
const char *index, *subCmd, *string;
Tcl_Obj **varPtr;
@@ -713,7 +713,7 @@ TestintobjCmd(
} else {
SetVarToObj(varPtr, varIndex, Tcl_NewIntObj(intValue));
}
- } else if (strcmp(subCmd, "setlong") == 0) {
+ } else if (strcmp(subCmd, "setint") == 0) {
if (objc != 4) {
goto wrongNumArgs;
}
@@ -728,28 +728,28 @@ TestintobjCmd(
SetVarToObj(varPtr, varIndex, Tcl_NewWideIntObj(intValue));
}
Tcl_SetObjResult(interp, varPtr[varIndex]);
- } else if (strcmp(subCmd, "setmaxlong") == 0) {
- long maxLong = LONG_MAX;
+ } else if (strcmp(subCmd, "setmax") == 0) {
+ Tcl_WideInt maxWide = WIDE_MAX;
if (objc != 3) {
goto wrongNumArgs;
}
if ((varPtr[varIndex] != NULL) && !Tcl_IsShared(varPtr[varIndex])) {
- Tcl_SetWideIntObj(varPtr[varIndex], maxLong);
+ Tcl_SetWideIntObj(varPtr[varIndex], maxWide);
} else {
- SetVarToObj(varPtr, varIndex, Tcl_NewWideIntObj(maxLong));
+ SetVarToObj(varPtr, varIndex, Tcl_NewWideIntObj(maxWide));
}
- } else if (strcmp(subCmd, "ismaxlong") == 0) {
+ } else if (strcmp(subCmd, "ismax") == 0) {
if (objc != 3) {
goto wrongNumArgs;
}
if (CheckIfVarUnset(interp, varPtr,varIndex)) {
return TCL_ERROR;
}
- if (Tcl_GetLongFromObj(interp, varPtr[varIndex], &longValue) != TCL_OK) {
+ if (Tcl_GetWideIntFromObj(interp, varPtr[varIndex], &wideValue) != TCL_OK) {
return TCL_ERROR;
}
Tcl_AppendToObj(Tcl_GetObjResult(interp),
- ((longValue == LONG_MAX)? "1" : "0"), -1);
+ ((wideValue == WIDE_MAX)? "1" : "0"), -1);
} else if (strcmp(subCmd, "get") == 0) {
if (objc != 3) {
goto wrongNumArgs;
diff --git a/generic/tclTestProcBodyObj.c b/generic/tclTestProcBodyObj.c
index fba2844..913b253 100644
--- a/generic/tclTestProcBodyObj.c
+++ b/generic/tclTestProcBodyObj.c
@@ -340,7 +340,7 @@ ProcBodyTestCheckObjCmd(
}
version = Tcl_PkgPresent(interp, packageName, packageVersion, 1);
- Tcl_SetObjResult(interp, Tcl_NewBooleanObj(
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(
strcmp(version, packageVersion) == 0));
return TCL_OK;
}
diff --git a/generic/tclUtil.c b/generic/tclUtil.c
index 250a393..2889852 100644
--- a/generic/tclUtil.c
+++ b/generic/tclUtil.c
@@ -3448,7 +3448,7 @@ TclPrecTraceProc(
int flags) /* Information about what happened. */
{
Tcl_Obj *value;
- int prec;
+ Tcl_WideInt prec;
int *precisionPtr = Tcl_GetThreadData(&precisionKey, sizeof(int));
/*
@@ -3488,11 +3488,11 @@ TclPrecTraceProc(
}
value = Tcl_GetVar2Ex(interp, name1, name2, flags & TCL_GLOBAL_ONLY);
if (value == NULL
- || Tcl_GetIntFromObj(NULL, value, &prec) != TCL_OK
+ || Tcl_GetWideIntFromObj(NULL, value, &prec) != TCL_OK
|| prec < 0 || prec > TCL_MAX_PREC) {
return (char *) "improper value for precision";
}
- *precisionPtr = prec;
+ *precisionPtr = (int)prec;
return NULL;
}
#endif /* !TCL_NO_DEPRECATED)*/
diff --git a/generic/tclZlib.c b/generic/tclZlib.c
index 32268af..5a7abec 100644
--- a/generic/tclZlib.c
+++ b/generic/tclZlib.c
@@ -422,6 +422,7 @@ GenerateHeader(
{
Tcl_Obj *value;
int len, result = TCL_ERROR;
+ Tcl_WideInt wideValue;
const char *valueStr;
Tcl_Encoding latin1enc;
static const char *const types[] = {
@@ -485,10 +486,11 @@ GenerateHeader(
if (GetValue(interp, dictObj, "time", &value) != TCL_OK) {
goto error;
- } else if (value != NULL && Tcl_GetLongFromObj(interp, value,
- (long *) &headerPtr->header.time) != TCL_OK) {
+ } else if (value != NULL && Tcl_GetWideIntFromObj(interp, value,
+ &wideValue) != TCL_OK) {
goto error;
}
+ headerPtr->header.time = wideValue;
if (GetValue(interp, dictObj, "type", &value) != TCL_OK) {
goto error;