diff options
author | dkf <dkf@noemail.net> | 2002-06-25 08:59:35 (GMT) |
---|---|---|
committer | dkf <dkf@noemail.net> | 2002-06-25 08:59:35 (GMT) |
commit | eb7dd2b9e38bc38aa77218da7dcba23e73799740 (patch) | |
tree | 93e9561c5d2d5d2788c9b6e588573abee06f4589 /generic/tclUtil.c | |
parent | 73d8b2955bb8d1e10cf332803deadeac7cceb243 (diff) | |
download | tcl-eb7dd2b9e38bc38aa77218da7dcba23e73799740.zip tcl-eb7dd2b9e38bc38aa77218da7dcba23e73799740.tar.gz tcl-eb7dd2b9e38bc38aa77218da7dcba23e73799740.tar.bz2 |
Surface fix for bug #533364; TclGetIntForIndex no longer assumes an unshared
empty result when generating an error message.
FossilOrigin-Name: 03029eff05753e3503eb60b83733117e55b1da5e
Diffstat (limited to 'generic/tclUtil.c')
-rw-r--r-- | generic/tclUtil.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/generic/tclUtil.c b/generic/tclUtil.c index b83c7c8..ff5e53a 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.31 2002/04/19 13:08:56 dkf Exp $ + * RCS: @(#) $Id: tclUtil.c,v 1.32 2002/06/25 08:59:36 dkf Exp $ */ #include "tclInt.h" @@ -2197,7 +2197,7 @@ TclGetIntForIndex(interp, objPtr, endValue, indexPtr) * representing an index. */ { char *bytes; - int length, offset; + int offset; #ifndef TCL_WIDE_INT_IS_LONG Tcl_WideInt wideOffset; #endif @@ -2267,8 +2267,14 @@ TclGetIntForIndex(interp, objPtr, endValue, indexPtr) * Report a parse error. */ - if ((Interp *)interp != NULL) { - bytes = Tcl_GetStringFromObj(objPtr, &length); + if (interp != NULL) { + bytes = Tcl_GetString(objPtr); + /* + * The result might not be empty; this resets it which + * should be both a cheap operation, and of little problem + * because this is an error-generation path anyway. + */ + Tcl_ResetResult(interp); Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), "bad index \"", bytes, "\": must be integer or end?-integer?", @@ -2365,6 +2371,7 @@ SetEndOffsetFromAny(interp, objPtr) if ((*bytes != 'e') || (strncmp(bytes, "end", (size_t)((length > 3) ? 3 : length)) != 0)) { if (interp != NULL) { + Tcl_ResetResult(interp); Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), "bad index \"", bytes, "\": must be end?-integer?", @@ -2390,6 +2397,7 @@ SetEndOffsetFromAny(interp, objPtr) * Conversion failed. Report the error. */ if (interp != NULL) { + Tcl_ResetResult(interp); Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), "bad index \"", bytes, "\": must be integer or end?-integer?", |