summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2006-09-21 21:11:50 (GMT)
committerdgp <dgp@users.sourceforge.net>2006-09-21 21:11:50 (GMT)
commit2ee60d27da9fef65d3ffb28c901bd174911d991d (patch)
treedd005f47187069391364a7733099aee0b6bb98ba
parente9758671ba3c3d87b274149801fe3f2485776550 (diff)
downloadtcl-2ee60d27da9fef65d3ffb28c901bd174911d991d.zip
tcl-2ee60d27da9fef65d3ffb28c901bd174911d991d.tar.gz
tcl-2ee60d27da9fef65d3ffb28c901bd174911d991d.tar.bz2
* generic/tclUtil.c: Dropped ParseInteger() routine.
TclParseNumber covers the task just fine.
-rw-r--r--ChangeLog5
-rw-r--r--generic/tclUtil.c95
2 files changed, 20 insertions, 80 deletions
diff --git a/ChangeLog b/ChangeLog
index 699add2..da861af 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2006-09-21 Don Porter <dgp@users.sourceforge.net>
+
+ * generic/tclUtil.c: Dropped ParseInteger() routine.
+ TclParseNumber covers the task just fine.
+
2006-09-19 Donal K. Fellows <dkf@users.sf.net>
* generic/tclEvent.c (Tcl_VwaitObjCmd): Rewrite so that an exceeded
diff --git a/generic/tclUtil.c b/generic/tclUtil.c
index 3ab3a14..2a1c1dc 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.69 2006/08/10 12:15:31 dkf Exp $
+ * RCS: @(#) $Id: tclUtil.c,v 1.70 2006/09/21 21:11:50 dgp Exp $
*/
#include "tclInt.h"
@@ -69,7 +69,6 @@ static void ClearHash(Tcl_HashTable *tablePtr);
static void FreeProcessGlobalValue(ClientData clientData);
static void FreeThreadHash(ClientData clientData);
static Tcl_HashTable * GetThreadHash(Tcl_ThreadDataKey *keyPtr);
-static int ParseInteger(CONST char *bytes, int numBytes);
static int SetEndOffsetFromAny(Tcl_Interp* interp,
Tcl_Obj* objPtr);
static void UpdateStringOfEndOffset(Tcl_Obj* objPtr);
@@ -2159,66 +2158,6 @@ TclNeedSpace(
/*
*----------------------------------------------------------------------
*
- * ParseInteger --
- *
- * Scans up to numBytes bytes starting at bytes, and checks whether the
- * leading bytes look like an integer's string representation.
- *
- * Results:
- * Returns 0 if the leading bytes do not look like an integer.
- * Otherwise, returns the number of bytes examined that look like an
- * integer. This may be less than numBytes if the integer is only the
- * leading part of the string.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-ParseInteger(
- CONST char *bytes, /* The string to examine. */
- int numBytes) /* Max number of bytes to scan. */
-{
- register CONST char *p = bytes;
-
- /*
- * Take care of introductory "0x".
- */
-
- if ((numBytes > 1) && (p[0] == '0') && ((p[1] == 'x') || (p[1] == 'X'))) {
- int scanned;
- Tcl_UniChar ch;
-
- p += 2;
- numBytes -= 2;
- scanned = TclParseHex(p, numBytes, &ch);
- if (scanned) {
- return scanned+2;
- }
-
- /*
- * Recognize the 0 as valid integer, but x is left behind.
- */
-
- return 1;
- }
- while (numBytes && isdigit(UCHAR(*p))) { /* INTL: digit */
- numBytes--; p++;
- }
- if (numBytes == 0) {
- return (p - bytes);
- }
- if ((*p != '.') && (*p != 'e') && (*p != 'E')) {
- return (p - bytes);
- }
- return 0;
-}
-
-/*
- *----------------------------------------------------------------------
- *
* TclGetIntForIndex --
*
* This function returns an integer corresponding to the list index held
@@ -2265,36 +2204,32 @@ TclGetIntForIndex(
*indexPtr = endValue + objPtr->internalRep.longValue;
} else {
- int opIdx, length;
- char *bytes = Tcl_GetStringFromObj(objPtr, &length);
- char *p = bytes;
+ int length;
+ char *opPtr, *bytes = Tcl_GetStringFromObj(objPtr, &length);
- while (length && isspace(UCHAR(*p))) { /* INTL: ISO space. */
- length--; p++;
+ /* Leading whitespace is acceptable in an index */
+ while (length && isspace(UCHAR(*bytes))) { /* INTL: ISO space. */
+ bytes++; length--;
}
- if (length == 0) {
- goto parseError;
- }
- if ((*p == '+') || (*p == '-')) {
- p++; length--;
- }
- opIdx = ParseInteger(p, length) + (int) (p-bytes);
- if (opIdx) {
+
+ if (TCL_OK == TclParseNumber(NULL, NULL, NULL,
+ bytes, length, (CONST char **)&opPtr,
+ TCL_PARSE_INTEGER_ONLY | TCL_PARSE_NO_WHITESPACE)) {
int code, first, second;
- char savedOp = bytes[opIdx];
+ char savedOp = *opPtr;
if ((savedOp != '+') && (savedOp != '-')) {
goto parseError;
}
- if (isspace(UCHAR(bytes[opIdx+1]))) {
+ if (isspace(UCHAR(opPtr[1]))) {
goto parseError;
}
- bytes[opIdx] = '\0';
+ *opPtr = '\0';
code = Tcl_GetInt(interp, bytes, &first);
- bytes[opIdx] = savedOp;
+ *opPtr = savedOp;
if (code == TCL_ERROR) {
goto parseError;
}
- if (TCL_ERROR == Tcl_GetInt(interp, bytes+opIdx+1, &second)) {
+ if (TCL_ERROR == Tcl_GetInt(interp, opPtr+1, &second)) {
goto parseError;
}
if (savedOp == '+') {