diff options
author | Miguel Sofer <miguel.sofer@gmail.com> | 2002-04-18 13:04:20 (GMT) |
---|---|---|
committer | Miguel Sofer <miguel.sofer@gmail.com> | 2002-04-18 13:04:20 (GMT) |
commit | 4da52701cd2676916c17d74b8c698025a9b3aebd (patch) | |
tree | 2e156e3c84fa1b82458e15f57f3027533a9eb34e /generic | |
parent | 342091a852b8bbb1cf9351963ac23d540938fc5e (diff) | |
download | tcl-4da52701cd2676916c17d74b8c698025a9b3aebd.zip tcl-4da52701cd2676916c17d74b8c698025a9b3aebd.tar.gz tcl-4da52701cd2676916c17d74b8c698025a9b3aebd.tar.bz2 |
fix for [Bug #542588], where "too large integers" were reported as
"floating-point value" in [expr] error messages.
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tclExecute.c | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/generic/tclExecute.c b/generic/tclExecute.c index fd369b2..f6d2ea2 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.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: tclExecute.c,v 1.52 2002/04/15 17:32:18 msofer Exp $ + * RCS: @(#) $Id: tclExecute.c,v 1.53 2002/04/18 13:04:20 msofer Exp $ */ #include "tclInt.h" @@ -4569,25 +4569,33 @@ IllegalExprOperandType(interp, pc, opndPtr) operatorStrings[opCode - INST_LOR], "\"", (char *) NULL); } else { char *msg = "non-numeric string"; - if (opndPtr->typePtr != &tclDoubleType) { + char *s; + int length; + + s = Tcl_GetStringFromObj(opndPtr, &length); + if (TclLooksLikeInt(s, length)) { + /* + * If something that looks like an integer appears here, then + * it *must* be a bad octal or too large to represent [Bug 542588]. + */ + + if (TclCheckBadOctal(NULL, Tcl_GetString(opndPtr))) { + msg = "invalid octal number"; + } else { + msg = "integer value too large to represent"; + Tcl_SetErrorCode(interp, "ARITH", "IOVERFLOW", + "integer value too large to represent", (char *) NULL); + } + } else { /* * See if the operand can be interpreted as a double in order to * improve the error message. */ - char *s = TclGetString(opndPtr); double d; if (Tcl_GetDouble((Tcl_Interp *) NULL, s, &d) == TCL_OK) { - /* - * Make sure that what appears to be a double - * (ie 08) isn't really a bad octal - */ - if (TclCheckBadOctal(NULL, TclGetString(opndPtr))) { - msg = "invalid octal number"; - } else { - msg = "floating-point value"; - } + msg = "floating-point value"; } } Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), "can't use ", |