summaryrefslogtreecommitdiffstats
path: root/generic/tclGet.c
diff options
context:
space:
mode:
authorhobbs <hobbs@noemail.net>2002-11-19 02:34:48 (GMT)
committerhobbs <hobbs@noemail.net>2002-11-19 02:34:48 (GMT)
commit37a7c7abde6c9f7aac56e9a325dc525869b3a0ca (patch)
tree504abe4bc769d428863271620704ff919b9629b9 /generic/tclGet.c
parent1f46bc5c72b2183d19993e99562b8ec32b90dc6f (diff)
downloadtcl-37a7c7abde6c9f7aac56e9a325dc525869b3a0ca.zip
tcl-37a7c7abde6c9f7aac56e9a325dc525869b3a0ca.tar.gz
tcl-37a7c7abde6c9f7aac56e9a325dc525869b3a0ca.tar.bz2
* generic/tclUtil.c (SetEndOffsetFromAny): handle integer offset
after the "end-" prefix. * generic/get.test: * generic/string.test: * generic/tclObj.c (SetIntFromAny, SetWideIntFromAny): * generic/tclGet.c (TclGetLong, Tcl_GetInt): simplify sign handling before calling strtoul(l). [Bug #634856] FossilOrigin-Name: 9ed60484106be0df1d59f7a63c433c7e7e957725
Diffstat (limited to 'generic/tclGet.c')
-rw-r--r--generic/tclGet.c28
1 files changed, 19 insertions, 9 deletions
diff --git a/generic/tclGet.c b/generic/tclGet.c
index a42a3f1..6819322 100644
--- a/generic/tclGet.c
+++ b/generic/tclGet.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: tclGet.c,v 1.7 2001/09/25 16:23:56 dgp Exp $
+ * RCS: @(#) $Id: tclGet.c,v 1.8 2002/11/19 02:34:49 hobbs Exp $
*/
#include "tclInt.h"
@@ -46,7 +46,7 @@ Tcl_GetInt(interp, string, intPtr)
int *intPtr; /* Place to store converted result. */
{
char *end;
- CONST char *p;
+ CONST char *p = string;
long i;
/*
@@ -56,7 +56,14 @@ Tcl_GetInt(interp, string, intPtr)
*/
errno = 0;
- for (p = string; isspace(UCHAR(*p)); p++) { /* INTL: ISO space. */
+#ifdef TCL_STRTOUL_SIGN_CHECK
+ /*
+ * This special sign check actually causes bad numbers to be allowed
+ * when strtoul. I can't find a strtoul that doesn't validly handle
+ * signed characters, and the C standard implies that this is all
+ * unnecessary. [Bug #634856]
+ */
+ for ( ; isspace(UCHAR(*p)); p++) { /* INTL: ISO space. */
/* Empty loop body. */
}
if (*p == '-') {
@@ -65,9 +72,10 @@ Tcl_GetInt(interp, string, intPtr)
} else if (*p == '+') {
p++;
i = strtoul(p, &end, 0); /* INTL: Tcl source. */
- } else {
+ } else
+#else
i = strtoul(p, &end, 0); /* INTL: Tcl source. */
- }
+#endif
if (end == p) {
badInteger:
if (interp != (Tcl_Interp *) NULL) {
@@ -135,7 +143,7 @@ TclGetLong(interp, string, longPtr)
long *longPtr; /* Place to store converted long result. */
{
char *end;
- CONST char *p;
+ CONST char *p = string;
long i;
/*
@@ -144,7 +152,8 @@ TclGetLong(interp, string, longPtr)
*/
errno = 0;
- for (p = string; isspace(UCHAR(*p)); p++) { /* INTL: ISO space. */
+#ifdef TCL_STRTOUL_SIGN_CHECK
+ for ( ; isspace(UCHAR(*p)); p++) { /* INTL: ISO space. */
/* Empty loop body. */
}
if (*p == '-') {
@@ -153,9 +162,10 @@ TclGetLong(interp, string, longPtr)
} else if (*p == '+') {
p++;
i = strtoul(p, &end, 0); /* INTL: Tcl source. */
- } else {
+ } else
+#else
i = strtoul(p, &end, 0); /* INTL: Tcl source. */
- }
+#endif
if (end == p) {
badInteger:
if (interp != (Tcl_Interp *) NULL) {