diff options
author | dgp <dgp@users.sourceforge.net> | 2005-04-05 16:39:58 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2005-04-05 16:39:58 (GMT) |
commit | 910070a52346c2fca44926623c23656a24cf6d24 (patch) | |
tree | e9e94c52165c0e0c330127a5b3fc57a234100eba /generic/tclUtil.c | |
parent | c8d4a92cc921570ed2efcc7a40f7360c38931023 (diff) | |
download | tcl-910070a52346c2fca44926623c23656a24cf6d24.zip tcl-910070a52346c2fca44926623c23656a24cf6d24.tar.gz tcl-910070a52346c2fca44926623c23656a24cf6d24.tar.bz2 |
* generic/tclExecute.c (ExprSrandFunc): Replaced incursions into the
* generic/tclUtil.c (TclGetIntForIndex): intreps of numeric types
with simpler calls of Tcl_GetIntFromObj and Tcl_GetLongFromObj,
now that those routines are better behaved wrt shimmering.
[Patch 1177219]
Diffstat (limited to 'generic/tclUtil.c')
-rw-r--r-- | generic/tclUtil.c | 46 |
1 files changed, 3 insertions, 43 deletions
diff --git a/generic/tclUtil.c b/generic/tclUtil.c index 59872ce..57fc6e0 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.36.2.5 2004/10/14 15:28:39 dkf Exp $ + * RCS: @(#) $Id: tclUtil.c,v 1.36.2.6 2005/04/05 16:40:16 dgp Exp $ */ #include "tclInt.h" @@ -2276,32 +2276,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 @@ -2310,31 +2288,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 |