diff options
author | dgp <dgp@noemail.net> | 2007-08-21 20:41:30 (GMT) |
---|---|---|
committer | dgp <dgp@noemail.net> | 2007-08-21 20:41:30 (GMT) |
commit | 4f4f97aacfc7e2d871268c6fe8158b091adb025d (patch) | |
tree | e30018135f4e85fac7c5b364a7f210449f2cd160 /generic/tclMain.c | |
parent | a3a3d849676b741817eac09546a74d626beac4bf (diff) | |
download | tcl-4f4f97aacfc7e2d871268c6fe8158b091adb025d.zip tcl-4f4f97aacfc7e2d871268c6fe8158b091adb025d.tar.gz tcl-4f4f97aacfc7e2d871268c6fe8158b091adb025d.tar.bz2 |
* generic/tclMain.c: Corrected the logic of dropping the last
* tests/main.test: newline from an interactively typed command.
[Bug 1775878].
FossilOrigin-Name: 8b6639f41a0f78b4a71a9e406fbf456500e26119
Diffstat (limited to 'generic/tclMain.c')
-rw-r--r-- | generic/tclMain.c | 44 |
1 files changed, 27 insertions, 17 deletions
diff --git a/generic/tclMain.c b/generic/tclMain.c index 2ccb855..02cc5a9 100644 --- a/generic/tclMain.c +++ b/generic/tclMain.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclMain.c,v 1.42 2007/04/24 16:03:51 dgp Exp $ + * RCS: @(#) $Id: tclMain.c,v 1.43 2007/08/21 20:41:32 dgp Exp $ */ #include "tclInt.h" @@ -527,22 +527,30 @@ Tcl_Main( break; } - if (!TclObjCommandComplete(commandPtr)) { - /* - * Add the newline removed by Tcl_GetsObj back to the string. - */ + /* + * Add the newline removed by Tcl_GetsObj back to the string. + * Have to add it back before testing completeness, because + * it can make a difference. [Bug 1775878]. + */ - if (Tcl_IsShared(commandPtr)) { - Tcl_DecrRefCount(commandPtr); - commandPtr = Tcl_DuplicateObj(commandPtr); - Tcl_IncrRefCount(commandPtr); - } - Tcl_AppendToObj(commandPtr, "\n", 1); + if (Tcl_IsShared(commandPtr)) { + Tcl_DecrRefCount(commandPtr); + commandPtr = Tcl_DuplicateObj(commandPtr); + Tcl_IncrRefCount(commandPtr); + } + Tcl_AppendToObj(commandPtr, "\n", 1); + if (!TclObjCommandComplete(commandPtr)) { prompt = PROMPT_CONTINUE; continue; } prompt = PROMPT_START; + /* + * The final newline is syntactically redundant, and causes + * some error messages troubles deeper in, so lop it back off. + */ + Tcl_GetStringFromObj(commandPtr, &length); + Tcl_SetObjLength(commandPtr, --length); code = Tcl_RecordAndEvalObj(interp, commandPtr, TCL_EVAL_GLOBAL); inChannel = Tcl_GetStdChannel(TCL_STDIN); outChannel = Tcl_GetStdChannel(TCL_STDOUT); @@ -758,17 +766,19 @@ StdinProc( return; } + if (Tcl_IsShared(commandPtr)) { + Tcl_DecrRefCount(commandPtr); + commandPtr = Tcl_DuplicateObj(commandPtr); + Tcl_IncrRefCount(commandPtr); + } + Tcl_AppendToObj(commandPtr, "\n", 1); if (!TclObjCommandComplete(commandPtr)) { - if (Tcl_IsShared(commandPtr)) { - Tcl_DecrRefCount(commandPtr); - commandPtr = Tcl_DuplicateObj(commandPtr); - Tcl_IncrRefCount(commandPtr); - } - Tcl_AppendToObj(commandPtr, "\n", 1); isPtr->prompt = PROMPT_CONTINUE; goto prompt; } isPtr->prompt = PROMPT_START; + Tcl_GetStringFromObj(commandPtr, &length); + Tcl_SetObjLength(commandPtr, --length); /* * Disable the stdin channel handler while evaluating the command; |