Tcl Source Code

Artifact [3c3648a77c]
Login

Artifact 3c3648a77c68b49a5328680734144351825e0150:

Attachment "immincr.patch" to ticket [1165671fff] added by dgp 2005-03-18 06:42:20.
Index: generic/tclCompCmds.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclCompCmds.c,v
retrieving revision 1.60
diff -u -r1.60 tclCompCmds.c
--- generic/tclCompCmds.c	10 Mar 2005 22:15:34 -0000	1.60
+++ generic/tclCompCmds.c	17 Mar 2005 23:16:01 -0000
@@ -1365,31 +1365,28 @@
      */
 
     haveImmValue = 0;
-    immValue = 0;
+    immValue = 1;
     if (parsePtr->numWords == 3) {
 	incrTokenPtr = varTokenPtr + (varTokenPtr->numComponents + 1);
 	if (incrTokenPtr->type == TCL_TOKEN_SIMPLE_WORD) {
 	    CONST char *word = incrTokenPtr[1].start;
 	    int numBytes = incrTokenPtr[1].size;
-	    int validLength = TclParseInteger(word, numBytes);
-	    long n;
 
 	    /*
 	     * Note there is a danger that modifying the string could have
-	     * undesirable side effects.  In this case, TclLooksLikeInt and
-	     * TclGetLong do not have any dependencies on shared strings so we
-	     * should be safe.
+	     * undesirable side effects.  In this case, TclLooksLikeInt has
+	     * no dependencies on shared strings so we should be safe.
 	     */
 
-	    if (validLength == numBytes) {
+	    if (TclLooksLikeInt(word, numBytes)) {
 		int code;
-		Tcl_Obj *longObj = Tcl_NewStringObj(word, numBytes);
-		Tcl_IncrRefCount(longObj);
-		code = Tcl_GetLongFromObj(NULL, longObj, &n);
-		Tcl_DecrRefCount(longObj);
-		if ((code == TCL_OK) && (-127 <= n) && (n <= 127)) {
+		Tcl_Obj *intObj = Tcl_NewStringObj(word, numBytes);
+		Tcl_IncrRefCount(intObj);
+		code = Tcl_GetIntFromObj(NULL, intObj, &immValue);
+		Tcl_DecrRefCount(intObj);
+		if ((code == TCL_OK)
+			&& (-127 <= immValue) && (immValue <= 127)) {
 		    haveImmValue = 1;
-		    immValue = n;
 		}
 	    }
 	    if (!haveImmValue) {
@@ -1402,7 +1399,6 @@
 	}
     } else {			/* no incr amount given so use 1 */
 	haveImmValue = 1;
-	immValue = 1;
     }
 
     /*