diff options
author | dgp <dgp@users.sourceforge.net> | 2005-03-18 15:32:27 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2005-03-18 15:32:27 (GMT) |
commit | 5a484df86936621e5bf60c2a78ab5832ed886485 (patch) | |
tree | c1405b0df0e466b16aa02f6b7d6ed0240cd20efd /generic/tclCompCmds.c | |
parent | 06cfdf8d7716b24e5778cbeaef05d8756622d010 (diff) | |
download | tcl-5a484df86936621e5bf60c2a78ab5832ed886485.zip tcl-5a484df86936621e5bf60c2a78ab5832ed886485.tar.gz tcl-5a484df86936621e5bf60c2a78ab5832ed886485.tar.bz2 |
* generic/tclCompCmds.c (TclCompileIncrCmd): Corrected checks
for immediate operand usage to permit leading space and sign
characters. [Bug 1165671]
Diffstat (limited to 'generic/tclCompCmds.c')
-rw-r--r-- | generic/tclCompCmds.c | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/generic/tclCompCmds.c b/generic/tclCompCmds.c index 42b8448..300feb2 100644 --- a/generic/tclCompCmds.c +++ b/generic/tclCompCmds.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: tclCompCmds.c,v 1.39.2.2 2003/07/15 20:51:49 dgp Exp $ + * RCS: @(#) $Id: tclCompCmds.c,v 1.39.2.3 2005/03/18 15:32:29 dgp Exp $ */ #include "tclInt.h" @@ -1526,31 +1526,28 @@ TclCompileIncrCmd(interp, parsePtr, envPtr) */ 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) { @@ -1566,7 +1563,6 @@ TclCompileIncrCmd(interp, parsePtr, envPtr) } } else { /* no incr amount given so use 1 */ haveImmValue = 1; - immValue = 1; } /* |