summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2022-11-20 20:18:08 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2022-11-20 20:18:08 (GMT)
commit2f3087ea8f42ed192da6b35b4cd230cb74f0fd6a (patch)
tree72ca5538c8c9e57c34108d97c25286e2e7ab4151 /generic
parentbfdd211de9210e8b9cf5af6cf3aa03a4698ef0ee (diff)
parentba25919a60b33720617b9f5c8fd1ef4a1a92d0c7 (diff)
downloadtcl-2f3087ea8f42ed192da6b35b4cd230cb74f0fd6a.zip
tcl-2f3087ea8f42ed192da6b35b4cd230cb74f0fd6a.tar.gz
tcl-2f3087ea8f42ed192da6b35b4cd230cb74f0fd6a.tar.bz2
Rebase to latest 8.7
Diffstat (limited to 'generic')
-rw-r--r--generic/tcl.decls14
-rw-r--r--generic/tclClock.c4
-rw-r--r--generic/tclCmdMZ.c4
-rw-r--r--generic/tclDecls.h25
-rw-r--r--generic/tclInt.decls2
-rw-r--r--generic/tclIntDecls.h6
-rw-r--r--generic/tclListObj.c13
-rw-r--r--generic/tclObj.c67
-rw-r--r--generic/tclScan.c2
-rw-r--r--generic/tclStubInit.c4
-rw-r--r--generic/tclTest.c4
11 files changed, 109 insertions, 36 deletions
diff --git a/generic/tcl.decls b/generic/tcl.decls
index 59d0ece..722ef75 100644
--- a/generic/tcl.decls
+++ b/generic/tcl.decls
@@ -2552,13 +2552,13 @@ declare 683 {
int Tcl_GetEncodingNulLength(Tcl_Encoding encoding)
}
-# TIP #648 (reserved)
-#declare 684 {
-# Tcl_Obj *Tcl_NewWideUIntObj(Tcl_WideUInt wideValue)
-#}
-#declare 685 {
-# void Tcl_SetWideUIntObj(Tcl_Obj *objPtr, Tcl_WideUInt uwideValue)
-#}
+# TIP #648
+declare 684 {
+ Tcl_Obj *Tcl_NewWideUIntObj(Tcl_WideUInt wideValue)
+}
+declare 685 {
+ void Tcl_SetWideUIntObj(Tcl_Obj *objPtr, Tcl_WideUInt uwideValue)
+}
# TIP #650 (reserved)
#declare 686 {
diff --git a/generic/tclClock.c b/generic/tclClock.c
index a9ba70c..d64348e 100644
--- a/generic/tclClock.c
+++ b/generic/tclClock.c
@@ -1810,7 +1810,7 @@ ClockMillisecondsObjCmd(
return TCL_ERROR;
}
Tcl_GetTime(&now);
- Tcl_SetObjResult(interp, Tcl_NewWideIntObj((Tcl_WideInt)
+ Tcl_SetObjResult(interp, Tcl_NewWideUIntObj((Tcl_WideUInt)
now.sec * 1000 + now.usec / 1000));
return TCL_OK;
}
@@ -1998,7 +1998,7 @@ ClockSecondsObjCmd(
return TCL_ERROR;
}
Tcl_GetTime(&now);
- Tcl_SetObjResult(interp, Tcl_NewWideIntObj((Tcl_WideInt) now.sec));
+ Tcl_SetObjResult(interp, Tcl_NewWideUIntObj(now.sec));
return TCL_OK;
}
diff --git a/generic/tclCmdMZ.c b/generic/tclCmdMZ.c
index b063689..ff466d9 100644
--- a/generic/tclCmdMZ.c
+++ b/generic/tclCmdMZ.c
@@ -3775,7 +3775,7 @@ TclNRSwitchObjCmd(
TclNewIndexObj(rangeObjAry[0], info.matches[j].start);
TclNewIndexObj(rangeObjAry[1], info.matches[j].end-1);
} else {
- TclNewIndexObj(rangeObjAry[1], TCL_INDEX_NONE);
+ TclNewIntObj(rangeObjAry[1], -1);
rangeObjAry[0] = rangeObjAry[1];
}
@@ -4099,7 +4099,7 @@ Tcl_TimeObjCmd(
* Use int obj since we know time is not fractional. [Bug 1202178]
*/
- objs[0] = Tcl_NewWideIntObj((count <= 0) ? 0 : (Tcl_WideInt)totalMicroSec);
+ objs[0] = Tcl_NewWideUIntObj((count <= 0) ? 0 : (Tcl_WideUInt)totalMicroSec);
} else {
objs[0] = Tcl_NewDoubleObj(totalMicroSec/count);
}
diff --git a/generic/tclDecls.h b/generic/tclDecls.h
index 3a57b2f..504f04f 100644
--- a/generic/tclDecls.h
+++ b/generic/tclDecls.h
@@ -2040,8 +2040,11 @@ EXTERN int Tcl_RemoveChannelMode(Tcl_Interp *interp,
Tcl_Channel chan, int mode);
/* 683 */
EXTERN int Tcl_GetEncodingNulLength(Tcl_Encoding encoding);
-/* Slot 684 is reserved */
-/* Slot 685 is reserved */
+/* 684 */
+EXTERN Tcl_Obj * Tcl_NewWideUIntObj(Tcl_WideUInt wideValue);
+/* 685 */
+EXTERN void Tcl_SetWideUIntObj(Tcl_Obj *objPtr,
+ Tcl_WideUInt uwideValue);
/* Slot 686 is reserved */
/* 687 */
EXTERN Tcl_Obj * Tcl_DStringToObj(Tcl_DString *dsPtr);
@@ -2764,8 +2767,8 @@ typedef struct TclStubs {
int (*tcl_GetNumber) (Tcl_Interp *interp, const char *bytes, size_t numBytes, void **clientDataPtr, int *typePtr); /* 681 */
int (*tcl_RemoveChannelMode) (Tcl_Interp *interp, Tcl_Channel chan, int mode); /* 682 */
int (*tcl_GetEncodingNulLength) (Tcl_Encoding encoding); /* 683 */
- void (*reserved684)(void);
- void (*reserved685)(void);
+ Tcl_Obj * (*tcl_NewWideUIntObj) (Tcl_WideUInt wideValue); /* 684 */
+ void (*tcl_SetWideUIntObj) (Tcl_Obj *objPtr, Tcl_WideUInt uwideValue); /* 685 */
void (*reserved686)(void);
Tcl_Obj * (*tcl_DStringToObj) (Tcl_DString *dsPtr); /* 687 */
} TclStubs;
@@ -4166,8 +4169,10 @@ extern const TclStubs *tclStubsPtr;
(tclStubsPtr->tcl_RemoveChannelMode) /* 682 */
#define Tcl_GetEncodingNulLength \
(tclStubsPtr->tcl_GetEncodingNulLength) /* 683 */
-/* Slot 684 is reserved */
-/* Slot 685 is reserved */
+#define Tcl_NewWideUIntObj \
+ (tclStubsPtr->tcl_NewWideUIntObj) /* 684 */
+#define Tcl_SetWideUIntObj \
+ (tclStubsPtr->tcl_SetWideUIntObj) /* 685 */
/* Slot 686 is reserved */
#define Tcl_DStringToObj \
(tclStubsPtr->tcl_DStringToObj) /* 687 */
@@ -4434,6 +4439,14 @@ extern const TclStubs *tclStubsPtr;
#undef Tcl_StringMatch
#define Tcl_StringMatch(str, pattern) Tcl_StringCaseMatch((str), (pattern), 0)
+#if TCL_MAJOR_VERSION > 8
+# define Tcl_NewIndexObj(value) (((value) >= TCL_INDEX_NONE) ? Tcl_NewWideIntObj(-1) : Tcl_NewWideUIntObj(value))
+# define Tcl_SetIndexObj(objPtr, value) (((value) >= TCL_INDEX_NONE) ? Tcl_SetWideIntObj(objPtr, -1) : Tcl_SetWideUIntObj(objPtr, value))
+#else
+# define Tcl_NewIndexObj Tcl_NewIntObj
+# define Tcl_SetIndexObj Tcl_SetIntObj
+#endif
+
#if TCL_UTF_MAX < 4
# undef Tcl_UniCharToUtfDString
# define Tcl_UniCharToUtfDString Tcl_Char16ToUtfDString
diff --git a/generic/tclInt.decls b/generic/tclInt.decls
index c0e0e06..b3e352a 100644
--- a/generic/tclInt.decls
+++ b/generic/tclInt.decls
@@ -701,7 +701,7 @@ declare 258 {
# TIP 625: for unit testing - create list objects with span
declare 260 {
- Tcl_Obj *TclListTestObj(int length, int leadingSpace, int endSpace)
+ Tcl_Obj *TclListTestObj(Tcl_Size length, Tcl_Size leadingSpace, Tcl_Size endSpace)
}
# TIP 625: for unit testing - check list invariants
diff --git a/generic/tclIntDecls.h b/generic/tclIntDecls.h
index 3da8567..4c8d897 100644
--- a/generic/tclIntDecls.h
+++ b/generic/tclIntDecls.h
@@ -660,8 +660,8 @@ EXTERN Tcl_Obj * TclpCreateTemporaryDirectory(Tcl_Obj *dirObj,
Tcl_Obj *basenameObj);
/* Slot 259 is reserved */
/* 260 */
-EXTERN Tcl_Obj * TclListTestObj(int length, int leadingSpace,
- int endSpace);
+EXTERN Tcl_Obj * TclListTestObj(Tcl_Size length,
+ Tcl_Size leadingSpace, Tcl_Size endSpace);
/* 261 */
EXTERN void TclListObjValidate(Tcl_Interp *interp,
Tcl_Obj *listObj);
@@ -930,7 +930,7 @@ typedef struct TclIntStubs {
void (*tclStaticLibrary) (Tcl_Interp *interp, const char *prefix, Tcl_LibraryInitProc *initProc, Tcl_LibraryInitProc *safeInitProc); /* 257 */
Tcl_Obj * (*tclpCreateTemporaryDirectory) (Tcl_Obj *dirObj, Tcl_Obj *basenameObj); /* 258 */
void (*reserved259)(void);
- Tcl_Obj * (*tclListTestObj) (int length, int leadingSpace, int endSpace); /* 260 */
+ Tcl_Obj * (*tclListTestObj) (Tcl_Size length, Tcl_Size leadingSpace, Tcl_Size endSpace); /* 260 */
void (*tclListObjValidate) (Tcl_Interp *interp, Tcl_Obj *listObj); /* 261 */
} TclIntStubs;
diff --git a/generic/tclListObj.c b/generic/tclListObj.c
index 8ee0f48..f016224 100644
--- a/generic/tclListObj.c
+++ b/generic/tclListObj.c
@@ -3514,15 +3514,8 @@ UpdateStringOfList(
*------------------------------------------------------------------------
*/
Tcl_Obj *
-TclListTestObj (int length, int leadingSpace, int endSpace)
+TclListTestObj (Tcl_Size length, Tcl_Size leadingSpace, Tcl_Size endSpace)
{
- if (length < 0)
- length = 0;
- if (leadingSpace < 0)
- leadingSpace = 0;
- if (endSpace < 0)
- endSpace = 0;
-
ListRep listRep;
Tcl_Size capacity;
Tcl_Obj *listObj;
@@ -3538,9 +3531,9 @@ TclListTestObj (int length, int leadingSpace, int endSpace)
ListRepInit(capacity, NULL, 0, &listRep);
ListStore *storePtr = listRep.storePtr;
- int i;
+ Tcl_Size i;
for (i = 0; i < length; ++i) {
- storePtr->slots[i + leadingSpace] = Tcl_NewIntObj(i);
+ storePtr->slots[i + leadingSpace] = Tcl_NewIndexObj(i);
Tcl_IncrRefCount(storePtr->slots[i + leadingSpace]);
}
storePtr->firstUsed = leadingSpace;
diff --git a/generic/tclObj.c b/generic/tclObj.c
index ce8e610..4639731 100644
--- a/generic/tclObj.c
+++ b/generic/tclObj.c
@@ -3219,6 +3219,33 @@ Tcl_NewWideIntObj(
/*
*----------------------------------------------------------------------
*
+ * Tcl_NewWideUIntObj --
+ *
+ * Results:
+ * The newly created object is returned. This object will have an invalid
+ * string representation. The returned object has ref count 0.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+Tcl_Obj *
+Tcl_NewWideUIntObj(
+ Tcl_WideUInt uwideValue)
+ /* Wide integer used to initialize the new
+ * object. */
+{
+ Tcl_Obj *objPtr;
+
+ TclNewUIntObj(objPtr, uwideValue);
+ return objPtr;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
* Tcl_DbNewWideIntObj --
*
* If a client is compiled with TCL_MEM_DEBUG defined, calls to
@@ -3312,6 +3339,46 @@ Tcl_SetWideIntObj(
TclSetIntObj(objPtr, wideValue);
}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * Tcl_SetWideUIntObj --
+ *
+ * Modify an object to be a wide integer object or a bignum object
+ * and to have the specified unsigned wide integer value.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * The object's old string rep, if any, is freed. Also, any old internal
+ * rep is freed.
+ *
+ *----------------------------------------------------------------------
+ */
+
+void
+Tcl_SetWideUIntObj(
+ Tcl_Obj *objPtr, /* Object w. internal rep to init. */
+ Tcl_WideUInt uwideValue)
+ /* Wide integer used to initialize the
+ * object's value. */
+{
+ if (Tcl_IsShared(objPtr)) {
+ Tcl_Panic("%s called with shared object", "Tcl_SetWideUIntObj");
+ }
+
+ if (uwideValue > WIDE_MAX) {
+ mp_int bignumValue;
+ if (mp_init_u64(&bignumValue, uwideValue) != MP_OKAY) {
+ Tcl_Panic("%s: memory overflow", "Tcl_SetWideUIntObj");
+ }
+ TclSetBignumInternalRep(objPtr, &bignumValue);
+ } {
+ TclSetIntObj(objPtr, (Tcl_WideInt)uwideValue);
+ }
+}
/*
*----------------------------------------------------------------------
diff --git a/generic/tclScan.c b/generic/tclScan.c
index 6bc914d..c0cf49f 100644
--- a/generic/tclScan.c
+++ b/generic/tclScan.c
@@ -1090,7 +1090,7 @@ Tcl_ScanObjCmd(
if (code == TCL_OK) {
if (underflow && (nconversions == 0)) {
if (numVars) {
- TclNewIndexObj(objPtr, TCL_INDEX_NONE);
+ TclNewIntObj(objPtr, -1);
} else {
if (objPtr) {
Tcl_SetListObj(objPtr, 0, NULL);
diff --git a/generic/tclStubInit.c b/generic/tclStubInit.c
index b3eb0de..a496c64 100644
--- a/generic/tclStubInit.c
+++ b/generic/tclStubInit.c
@@ -2055,8 +2055,8 @@ const TclStubs tclStubs = {
Tcl_GetNumber, /* 681 */
Tcl_RemoveChannelMode, /* 682 */
Tcl_GetEncodingNulLength, /* 683 */
- 0, /* 684 */
- 0, /* 685 */
+ Tcl_NewWideUIntObj, /* 684 */
+ Tcl_SetWideUIntObj, /* 685 */
0, /* 686 */
Tcl_DStringToObj, /* 687 */
};
diff --git a/generic/tclTest.c b/generic/tclTest.c
index bc3b553..021cb22 100644
--- a/generic/tclTest.c
+++ b/generic/tclTest.c
@@ -3121,12 +3121,12 @@ TestlinkCmd(
tmp = Tcl_NewWideIntObj(longVar);
Tcl_AppendElement(interp, Tcl_GetString(tmp));
Tcl_DecrRefCount(tmp);
- tmp = Tcl_NewWideIntObj((long)ulongVar);
+ tmp = Tcl_NewWideUIntObj(ulongVar);
Tcl_AppendElement(interp, Tcl_GetString(tmp));
Tcl_DecrRefCount(tmp);
Tcl_PrintDouble(NULL, (double)floatVar, buffer);
Tcl_AppendElement(interp, buffer);
- tmp = Tcl_NewWideIntObj((Tcl_WideInt)uwideVar);
+ tmp = Tcl_NewWideUIntObj(uwideVar);
Tcl_AppendElement(interp, Tcl_GetString(tmp));
Tcl_DecrRefCount(tmp);
} else if (strcmp(argv[1], "set") == 0) {