Tcl Source Code

Artifact [4749b08c26]
Login

Artifact 4749b08c265d9b4aa44b7753166e003a33f1066b:

Attachment "option1.patch" to ticket [1805896fff] added by dgp 2007-10-18 23:51:44.
Index: generic/tclStrToD.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclStrToD.c,v
retrieving revision 1.30
diff -u -r1.30 tclStrToD.c
--- generic/tclStrToD.c	23 Apr 2007 17:34:07 -0000	1.30
+++ generic/tclStrToD.c	18 Oct 2007 16:50:17 -0000
@@ -301,7 +301,8 @@
     char d = 0;			/* Last hexadecimal digit scanned; initialized
 				 * to avoid a compiler warning. */
     int shift = 0;		/* Amount to shift when accumulating binary */
-    int explicitOctal = 0;
+    int explicitOctal = (flags & TCL_PARSE_OCTAL_ONLY);
+    int decimalFallback = 0;
 
 #define ALL_BITS	(~(Tcl_WideUInt)0)
 #define MOST_BITS	(ALL_BITS >> 1)
@@ -488,11 +489,16 @@
 
 		goto endgame;
 	    }
+	    decimalFallback |= (c == '8' || c == '9');
 	    if (flags & TCL_PARSE_INTEGER_ONLY) {
 		/*
 		 * No seeking floating point when parsing only integer.
 		 */
 
+		if (decimalFallback) {
+		    state = DECIMAL;
+		    goto decimal;
+		}
 		goto endgame;
 	    }
 #ifndef KILL_OCTAL
@@ -530,6 +536,11 @@
 		break;
 	    } 
 #endif
+
+	    if (decimalFallback) {
+		state = DECIMAL;
+		goto decimal;
+	    }
 	    goto endgame;
 
 	    /*
@@ -633,9 +644,7 @@
 	     * digits.
 	     */
 
-#ifdef KILL_OCTAL
 	decimal:
-#endif
 	    acceptState = state;
 	    acceptPoint = p;
 	    acceptLen = len;