summaryrefslogtreecommitdiffstats
path: root/generic/tclCompile.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2003-10-14 15:44:52 (GMT)
committerdgp <dgp@users.sourceforge.net>2003-10-14 15:44:52 (GMT)
commitb7c8b125de1f42a74d05bd5882afc2da0a88604a (patch)
treebdeafc412fed0f5ab5d71500254ea6d40c14174c /generic/tclCompile.c
parent53f461a314e8fda45504e3e1d7a51595d470604e (diff)
downloadtcl-b7c8b125de1f42a74d05bd5882afc2da0a88604a.zip
tcl-b7c8b125de1f42a74d05bd5882afc2da0a88604a.tar.gz
tcl-b7c8b125de1f42a74d05bd5882afc2da0a88604a.tar.bz2
* generic/tclBasic.c (TclAppendObjToErrorInfo): New internal routine
that appends a Tcl_Obj to the errorInfo, saving the caller the trouble of extracting the string rep. * generic/tclStringObj.c (TclAppendLimitedToObj): New internal routine that supports truncated appends with optional ellipsis marking. This single routine supports UTF-8-safe truncated appends needed in several places throughout the Tcl source code, mostly for error and stack messages. Clean fix for [Bug 760872]. * generic/tclInt.h: Declarations for new internal routines. * generic/tclCmdMZ.c: Updated callers to use the new routines. * generic/tclCompExpr.c: * generic/tclCompile.c: * generic/tclExecute.c: * generic/tclIOUtil.c: * generic/tclNamesp.c: * generic/tclObj.c: * generic/tclParseExpr.c: * generic/tclProc.c: * generic/tclStringObj.c: * mac/tclMacResource.c: * library/init.tcl: Updated ::errorInfo cleanup in [unknown] to reflect slight modifications to Tcl_LogCommandInfo(). Corrects failing init-4.* tests.
Diffstat (limited to 'generic/tclCompile.c')
-rw-r--r--generic/tclCompile.c26
1 files changed, 8 insertions, 18 deletions
diff --git a/generic/tclCompile.c b/generic/tclCompile.c
index 10845d3..66d4bea 100644
--- a/generic/tclCompile.c
+++ b/generic/tclCompile.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: tclCompile.c,v 1.50 2003/09/12 23:55:32 dkf Exp $
+ * RCS: @(#) $Id: tclCompile.c,v 1.51 2003/10/14 15:44:52 dgp Exp $
*/
#include "tclInt.h"
@@ -1613,10 +1613,9 @@ LogCompilationInfo(interp, script, command, length)
int length; /* Number of bytes in command (-1 means
* use all bytes up to first null byte). */
{
- char buffer[200];
register CONST char *p;
- char *ellipsis = "";
Interp *iPtr = (Interp *) interp;
+ Tcl_Obj *message;
if (iPtr->flags & ERR_ALREADY_LOGGED) {
/*
@@ -1638,21 +1637,12 @@ LogCompilationInfo(interp, script, command, length)
}
}
- /*
- * Create an error message to add to errorInfo, including up to a
- * maximum number of characters of the command.
- */
-
- if (length < 0) {
- length = strlen(command);
- }
- if (length > 150) {
- length = 150;
- ellipsis = "...";
- }
- sprintf(buffer, "\n while compiling\n\"%.*s%s\"",
- length, command, ellipsis);
- Tcl_AddObjErrorInfo(interp, buffer, -1);
+ message = Tcl_NewStringObj("\n while compiling\n\"", -1);
+ Tcl_IncrRefCount(message);
+ TclAppendLimitedToObj(message, command, length, 153, NULL);
+ Tcl_AppendToObj(message, "\"", -1);
+ TclAppendObjToErrorInfo(interp, message);
+ Tcl_DecrRefCount(message);
}
/*