summaryrefslogtreecommitdiffstats
path: root/generic/tclUtil.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2017-10-30 11:01:28 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2017-10-30 11:01:28 (GMT)
commitaad24c7ffcbdb7271ba73f1548b5be00185df1b2 (patch)
tree8fb59c30a74bbebcc26caf6a66fbb35460a7b9b1 /generic/tclUtil.c
parentfe508fa3b5c9dffaebbd68b86344a799a45075c4 (diff)
downloadtcl-aad24c7ffcbdb7271ba73f1548b5be00185df1b2.zip
tcl-aad24c7ffcbdb7271ba73f1548b5be00185df1b2.tar.gz
tcl-aad24c7ffcbdb7271ba73f1548b5be00185df1b2.tar.bz2
Change (internal) TclFormatInt() signature, so it can handle WideInt's directly. Ongoing simplifications ...
Diffstat (limited to 'generic/tclUtil.c')
-rw-r--r--generic/tclUtil.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/generic/tclUtil.c b/generic/tclUtil.c
index da4dc49..27e1877 100644
--- a/generic/tclUtil.c
+++ b/generic/tclUtil.c
@@ -3489,9 +3489,9 @@ int
TclFormatInt(
char *buffer, /* Points to the storage into which the
* formatted characters are written. */
- long n) /* The integer to format. */
+ Tcl_WideInt n) /* The integer to format. */
{
- long intVal;
+ Tcl_WideInt intVal;
int i;
int numFormatted, j;
const char *digits = "0123456789";
@@ -3514,7 +3514,7 @@ TclFormatInt(
intVal = -n; /* [Bug 3390638] Workaround for*/
if (n == -n || intVal == n) { /* broken compiler optimizers. */
- return sprintf(buffer, "%ld", n);
+ return sprintf(buffer, "%" TCL_LL_MODIFIER "d", n);
}
/*
@@ -3722,7 +3722,7 @@ SetEndOffsetFromAny(
Tcl_Interp *interp, /* Tcl interpreter or NULL */
Tcl_Obj *objPtr) /* Pointer to the object to parse */
{
- int offset; /* Offset in the "end-offset" expression */
+ Tcl_WideInt offset; /* Offset in the "end-offset" expression */
register const char *bytes; /* String rep of the object */
int length; /* Length of the object's string rep */
@@ -3758,15 +3758,24 @@ SetEndOffsetFromAny(
} else if ((length > 4) && ((bytes[3] == '-') || (bytes[3] == '+'))) {
/*
* This is our limited string expression evaluator. Pass everything
- * after "end-" to Tcl_GetInt, then reverse for offset.
+ * after "end-" to TclParseNumber.
*/
if (TclIsSpaceProc(bytes[4])) {
goto badIndexFormat;
}
- if (Tcl_GetInt(interp, bytes+4, &offset) != TCL_OK) {
+ if (TclParseNumber(NULL, objPtr, NULL, bytes+4, length-4, NULL,
+ TCL_PARSE_INTEGER_ONLY) != TCL_OK) {
return TCL_ERROR;
}
+ if ((objPtr->typePtr != &tclIntType)
+#ifndef TCL_WIDE_INT_IS_LONG
+ && (objPtr->typePtr != &tclWideIntType)
+#endif
+ ) {
+ goto badIndexFormat;
+ }
+ offset = objPtr->internalRep.wideValue;
if (bytes[3] == '-') {
offset = -offset;
}