summaryrefslogtreecommitdiffstats
path: root/generic/tclMain.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2007-08-21 20:41:31 (GMT)
committerdgp <dgp@users.sourceforge.net>2007-08-21 20:41:31 (GMT)
commit5a6f909bc973a094f28f7cadc81faf84a9128748 (patch)
treee30018135f4e85fac7c5b364a7f210449f2cd160 /generic/tclMain.c
parent2d087cd971d85e6e4bb484878b61f0ce4d845b6b (diff)
downloadtcl-5a6f909bc973a094f28f7cadc81faf84a9128748.zip
tcl-5a6f909bc973a094f28f7cadc81faf84a9128748.tar.gz
tcl-5a6f909bc973a094f28f7cadc81faf84a9128748.tar.bz2
* generic/tclMain.c: Corrected the logic of dropping the last
* tests/main.test: newline from an interactively typed command. [Bug 1775878].
Diffstat (limited to 'generic/tclMain.c')
-rw-r--r--generic/tclMain.c44
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;