summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
Diffstat (limited to 'generic')
-rw-r--r--generic/tclExecute.c8
-rw-r--r--generic/tclUtil.c46
2 files changed, 5 insertions, 49 deletions
diff --git a/generic/tclExecute.c b/generic/tclExecute.c
index 697ea08..7f90890 100644
--- a/generic/tclExecute.c
+++ b/generic/tclExecute.c
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclExecute.c,v 1.178 2005/04/04 10:12:51 msofer Exp $
+ * RCS: @(#) $Id: tclExecute.c,v 1.179 2005/04/05 16:56:26 dgp Exp $
*/
#include "tclInt.h"
@@ -6146,11 +6146,7 @@ ExprSrandFunc(interp, tosPtr, clientData)
return TCL_ERROR;
}
- if (valuePtr->typePtr == &tclIntType) {
- i = valuePtr->internalRep.longValue;
- } else if (valuePtr->typePtr == &tclWideIntType) {
- TclGetLongFromWide(i,valuePtr);
- } else {
+ if (Tcl_GetLongFromObj(NULL, valuePtr, &i) != TCL_OK) {
/*
* At this point, the only other possible type is double
*/
diff --git a/generic/tclUtil.c b/generic/tclUtil.c
index 6f032f6..9b7d0ec 100644
--- a/generic/tclUtil.c
+++ b/generic/tclUtil.c
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclUtil.c,v 1.53 2004/12/13 22:11:35 dgp Exp $
+ * RCS: @(#) $Id: tclUtil.c,v 1.54 2005/04/05 16:56:30 dgp Exp $
*/
#include "tclInt.h"
@@ -2300,32 +2300,10 @@ TclGetIntForIndex(interp, objPtr, endValue, indexPtr)
int *indexPtr; /* Location filled in with an integer
* representing an index. */
{
- char *bytes;
- int offset;
- Tcl_WideInt wideOffset;
-
- /*
- * If the object is already an integer, use it.
- */
-
- if (objPtr->typePtr == &tclIntType) {
- *indexPtr = (int)objPtr->internalRep.longValue;
+ if (Tcl_GetIntFromObj(NULL, objPtr, indexPtr) == TCL_OK) {
return TCL_OK;
}
- /*
- * If the object is already a wide-int, and it is not out of range
- * for an integer, use it. [Bug #526717]
- */
- if (objPtr->typePtr == &tclWideIntType) {
- TclGetWide(wideOffset,objPtr);
- if (wideOffset >= Tcl_LongAsWide(INT_MIN)
- && wideOffset <= Tcl_LongAsWide(INT_MAX)) {
- *indexPtr = (int) Tcl_WideAsLong(wideOffset);
- return TCL_OK;
- }
- }
-
if (SetEndOffsetFromAny(NULL, objPtr) == TCL_OK) {
/*
* If the object is already an offset from the end of the
@@ -2334,31 +2312,13 @@ TclGetIntForIndex(interp, objPtr, endValue, indexPtr)
*indexPtr = endValue + objPtr->internalRep.longValue;
- } else if (Tcl_GetWideIntFromObj(NULL, objPtr, &wideOffset) == TCL_OK) {
- /*
- * If the object can be converted to a wide integer, use
- * that. [Bug #526717]
- */
-
- offset = (int) Tcl_WideAsLong(wideOffset);
- if (Tcl_LongAsWide(offset) == wideOffset) {
- /*
- * But it is representable as a narrow integer, so we
- * prefer that (so preserving old behaviour in the
- * majority of cases.)
- */
- objPtr->typePtr = &tclIntType;
- objPtr->internalRep.longValue = offset;
- }
- *indexPtr = offset;
-
} else {
/*
* Report a parse error.
*/
if (interp != NULL) {
- bytes = Tcl_GetString(objPtr);
+ char *bytes = Tcl_GetString(objPtr);
/*
* The result might not be empty; this resets it which
* should be both a cheap operation, and of little problem