diff: fix readline command-line echoing problem

Fergus Henderson fjh at cs.mu.OZ.AU
Fri Apr 9 02:02:53 AEST 1999


On 08-Apr-1999, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> The debugging tests were failing, because they use `echo on',
> and readline already does echoing, so all the commands were
> getting echoed twice.
...
> trace/mercury_trace_internal.c:
> 	GNU readline always echos the inputs, so if readline support is
> 	enabled, then ignore the MR_echo_commands variable,
> 	and report an error if the user tries to use `echo off'.

It turns out that that change wasn't quite sufficient,
because it still doesn't echo the `echo on' command.
So I had to make a few more changes.  Here is a relative
diff for the log message and the changes to mercury_trace_internal.c,
followed by a full diff which includes some new changes to the test cases
inputs and outputs.

--- LogMsg.old	Fri Apr  9 01:46:53 1999
+++ LogMsg    	Fri Apr  9 01:59:35 1999
@@ -1,8 +1,24 @@
 
-Estimated hours taken: 0.75
+Estimated hours taken: 2
 
 trace/mercury_trace_internal.c:
 	GNU readline always echos the inputs, so if readline support is
 	enabled, then ignore the MR_echo_commands variable,
 	and report an error if the user tries to use `echo off'.
+	Also, if we're not using readline, then echo the `echo on' command,
+	so that the output will be the same as with readline.
+
+tests/debugger/*.inp:
+	Ensure that `echo on' is always the first command.
+
+tests/debugger/*.exp:
+tests/debugger/*.exp2:
+	Update to reflect the changes to *.inp,
+	and to include the echo of the `echo on' command.
+
+	(Also delete the mdb intro banners from *_lib.exp*,
+	because mdb is invoked with MERCURY_SUPPRESS_MDB_BANNER=yes.
+	The *_lib* files are in fact currently not used, so they should
+	probably be just deleted, I think.  But I'll do that as
+	a separate change.)
 
--- mercury_trace_internal.c.old	Fri Apr  9 00:19:10 1999
+++ mercury_trace_internal.c	Fri Apr  9 00:19:12 1999
@@ -1101,7 +1101,18 @@
 				
 #endif
 			} else if (streq(words[1], "on")) {
-				MR_echo_commands = TRUE;
+#ifdef MR_NO_USE_READLINE
+				if (!MR_echo_commands) {
+					/*
+					** echo the `echo on' command
+					** This is needed for testing, so that
+					** we get the same output both with
+					** and without readline.
+					*/
+					fprintf(MR_mdb_out, "echo on\n");
+					MR_echo_commands = TRUE;
+				}
+#endif
 				if (MR_trace_internal_interacting) {
 					fprintf(MR_mdb_out,
 						"Command echo enabled.\n");

Estimated hours taken: 1.5

trace/mercury_trace_internal.c:
	GNU readline always echos the inputs, so if readline support is
	enabled, then ignore the MR_echo_commands variable,
	and report an error if the user tries to use `echo off'.
	Also, if we're not using readline, then echo the `echo on' command,
	so that the output will be the same as with readline.

tests/debugger/*.inp:
	Ensure that `echo on' is always the first command.

tests/debugger/*.exp:
tests/debugger/*.exp2:
	Update to reflect the changes to *.inp,
	and to include the echo of the `echo on' command.

	(Also delete the mdb intro banners from *_lib.exp*,
	because mdb is invoked with MERCURY_SUPPRESS_MDB_BANNER=yes.
	The *_lib* files are in fact currently not used, so they should
	probably be just deleted, I think.  But I'll do that as
	a separate change.)

Index: tests/debugger/debugger_regs.exp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/debugger_regs.exp,v
retrieving revision 1.5
diff -u -r1.5 debugger_regs.exp
--- debugger_regs.exp	1998/11/15 16:47:42	1.5
+++ debugger_regs.exp	1999/04/08 14:19:32
@@ -1,5 +1,6 @@
        1:      1  1 CALL pred debugger_regs:main/2-0 (det) 
-mdb> Command echo enabled.
+mdb> echo on
+Command echo enabled.
 mdb> 
        2:      2  2 CALL pred debugger_regs:data/41-0 (det) 
 mdb> 
Index: tests/debugger/debugger_regs_lib.exp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/debugger_regs_lib.exp,v
retrieving revision 1.3
diff -u -r1.3 debugger_regs_lib.exp
--- debugger_regs_lib.exp	1998/10/16 06:19:34	1.3
+++ debugger_regs_lib.exp	1999/04/08 14:22:35
@@ -1,9 +1,6 @@
-Melbourne Mercury Debugger, mdb version 0.8.
-Copyright 1998 University of Melbourne, Australia.
-mdb is free software, covered by the GNU General Public License.
-There is absolutely no warranty for mdb.
        1:      1  1 CALL pred debugger_regs_lib:main/2-0 (det) 
-mdb> Command echo enabled
+mdb> echo on
+Command echo enabled
 mdb> 
        2:      2  2 CALL pred debugger_regs_lib:data/41-0 (det) 
 mdb> 
Index: tests/debugger/existential_type_classes.exp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/existential_type_classes.exp,v
retrieving revision 1.5
diff -u -r1.5 existential_type_classes.exp
--- existential_type_classes.exp	1999/02/04 14:58:29	1.5
+++ existential_type_classes.exp	1999/04/08 14:19:40
@@ -1,5 +1,6 @@
        1:      1  1 CALL pred existential_type_classes:main/2-0 (det) 
-mdb> Command echo enabled.
+mdb> echo on
+Command echo enabled.
 mdb> alias P print *
 P      =>    print *
 mdb> register --quiet
Index: tests/debugger/implied_instance.exp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/implied_instance.exp,v
retrieving revision 1.3
diff -u -r1.3 implied_instance.exp
--- implied_instance.exp	1999/02/04 14:58:30	1.3
+++ implied_instance.exp	1999/04/08 14:19:45
@@ -1,5 +1,6 @@
        1:      1  1 CALL pred implied_instance:main/2-0 (det) 
-mdb> Command echo enabled.
+mdb> echo on
+Command echo enabled.
 mdb> register --quiet
 mdb> alias P print *
 P      =>    print *
Index: tests/debugger/interpreter.exp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/interpreter.exp,v
retrieving revision 1.7
diff -u -r1.7 interpreter.exp
--- interpreter.exp	1998/12/04 01:11:03	1.7
+++ interpreter.exp	1999/04/08 14:27:41
@@ -1,5 +1,7 @@
        1:      1  1 CALL pred interpreter:main/2-0 (det) 
-mdb> mdb> Command echo enabled.
+mdb> echo on
+Command echo enabled.
+mdb> register --quiet
 mdb> 10 step
 Pure Prolog Interpreter.
 
Index: tests/debugger/interpreter_lib.exp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/interpreter_lib.exp,v
retrieving revision 1.3
diff -u -r1.3 interpreter_lib.exp
--- interpreter_lib.exp	1998/10/16 06:19:39	1.3
+++ interpreter_lib.exp	1999/04/08 14:23:08
@@ -1,9 +1,6 @@
-Melbourne Mercury Debugger, mdb version 0.8.
-Copyright 1998 University of Melbourne, Australia.
-mdb is free software, covered by the GNU General Public License.
-There is absolutely no warranty for mdb.
        1:      1  1 CALL pred interpreter_lib:main/2-0 (det) 
-mdb> Command echo enabled
+mdb> echo on
+Command echo enabled
 mdb> 45step
 Pure Prolog Interpreter.
 
Index: tests/debugger/multi_parameter.exp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/multi_parameter.exp,v
retrieving revision 1.4
diff -u -r1.4 multi_parameter.exp
--- multi_parameter.exp	1999/02/04 14:58:31	1.4
+++ multi_parameter.exp	1999/04/08 14:23:17
@@ -1,5 +1,6 @@
        1:      1  1 CALL pred multi_parameter:main/2-0 (det) 
-mdb> Command echo enabled.
+mdb> echo on
+Command echo enabled.
 mdb> 
        2:      2  2 CALL pred multi_parameter:foo/2-0 (det) 
 mdb> print *
Index: tests/debugger/queens.exp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/queens.exp,v
retrieving revision 1.8
diff -u -r1.8 queens.exp
--- queens.exp	1999/03/28 01:05:37	1.8
+++ queens.exp	1999/04/08 14:23:25
@@ -1,5 +1,6 @@
        1:      1  1 CALL pred queens:main/2-0 (cc_multi) 
-mdb> Command echo enabled.
+mdb> echo on
+Command echo enabled.
 mdb> print *
        HeadVar__1           		state('<<c_pointer>>')
 mdb> 
Index: tests/debugger/queens_lib.exp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/queens_lib.exp,v
retrieving revision 1.3
diff -u -r1.3 queens_lib.exp
--- queens_lib.exp	1998/10/16 06:19:47	1.3
+++ queens_lib.exp	1999/04/08 14:23:33
@@ -1,9 +1,6 @@
-Melbourne Mercury Debugger, mdb version 0.8.
-Copyright 1998 University of Melbourne, Australia.
-mdb is free software, covered by the GNU General Public License.
-There is absolutely no warranty for mdb.
        1:      1  1 CALL pred queens_lib:main/2-0 (cc_multi) 
-mdb> Command echo enabled
+mdb> echo on
+Command echo enabled
 mdb> print *
        HeadVar__1           		state('<<c_pointer>>')
 mdb> 
Index: tests/debugger/existential_type_classes.exp2
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/existential_type_classes.exp2,v
retrieving revision 1.3
diff -u -r1.3 existential_type_classes.exp2
--- existential_type_classes.exp2	1999/02/04 14:58:30	1.3
+++ existential_type_classes.exp2	1999/04/08 14:19:43
@@ -1,5 +1,6 @@
        1:      1  1 CALL pred existential_type_classes:main/2-0 (det) 
-mdb> Command echo enabled.
+mdb> echo on
+Command echo enabled.
 mdb> alias P print *
 P      =>    print *
 mdb> register --quiet
Index: tests/debugger/interpreter.exp2
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/interpreter.exp2,v
retrieving revision 1.4
diff -u -r1.4 interpreter.exp2
--- interpreter.exp2	1998/11/17 08:32:33	1.4
+++ interpreter.exp2	1999/04/08 15:34:24
@@ -1,5 +1,7 @@
        1:      1  1 CALL pred interpreter:main/2-0 (det) 
-mdb> mdb> Command echo enabled.
+mdb> echo on
+Command echo enabled.
+mdb> register --quiet
 mdb> 10 step
 Pure Prolog Interpreter.
 
Index: tests/debugger/multi_parameter.exp2
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/multi_parameter.exp2,v
retrieving revision 1.3
diff -u -r1.3 multi_parameter.exp2
--- multi_parameter.exp2	1999/02/04 14:58:32	1.3
+++ multi_parameter.exp2	1999/04/08 14:23:20
@@ -1,5 +1,6 @@
        1:      1  1 CALL pred multi_parameter:main/2-0 (det) 
-mdb> Command echo enabled.
+mdb> echo on
+Command echo enabled.
 mdb> 
        2:      2  2 CALL pred multi_parameter:foo/2-0 (det) 
 mdb> print *
Index: tests/debugger/interpreter.inp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/interpreter.inp,v
retrieving revision 1.3
diff -u -r1.3 interpreter.inp
--- interpreter.inp	1998/10/16 06:19:37	1.3
+++ interpreter.inp	1999/04/08 14:20:15
@@ -1,5 +1,5 @@
-register --quiet
 echo on
+register --quiet
 10 step
 vars
 print *
Index: tests/debugger/interpreter_lib.inp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/interpreter_lib.inp,v
retrieving revision 1.3
diff -u -r1.3 interpreter_lib.inp
--- interpreter_lib.inp	1998/10/16 06:19:40	1.3
+++ interpreter_lib.inp	1999/04/08 14:20:19
@@ -1,5 +1,5 @@
-register --quiet
 echo on
+register --quiet
 45step
 vars
 print *
Index: tests/debugger/queens.inp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/queens.inp,v
retrieving revision 1.6
diff -u -r1.6 queens.inp
--- queens.inp	1999/03/25 22:24:57	1.6
+++ queens.inp	1999/04/08 15:29:35
@@ -41,8 +41,8 @@
 #
 # Test interactive queries.
 #
-mmc_options --use-subdirs
 mmc_options
+mmc_options --use-subdirs
 query queens list
 append(X, Y, ['a', 'b', 'c']).
 qperm([1,2,3], List).
Index: tests/debugger/queens_lib.inp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/queens_lib.inp,v
retrieving revision 1.3
diff -u -r1.3 queens_lib.inp
--- queens_lib.inp	1998/10/16 06:19:51	1.3
+++ queens_lib.inp	1999/04/08 14:20:36
@@ -1,5 +1,5 @@
-register --quiet
 echo on
+register --quiet
 print *
 
 print *
Index: trace/mercury_trace_internal.c
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace_internal.c,v
retrieving revision 1.36
diff -u -r1.36 mercury_trace_internal.c
--- mercury_trace_internal.c	1999/03/30 05:45:52	1.36
+++ mercury_trace_internal.c	1999/04/08 14:19:12
@@ -96,7 +96,9 @@
 static	int			MR_scroll_next = 0;
 
 /*
-** We echo each command just as it is executed iff this variable is TRUE.
+** We echo each command just as it is executed iff this variable is TRUE,
+** unless we're using GNU readline.  If we're using readline, then readline
+** echos things anyway, so in that case we ignore this variable.
 */
 
 static	bool			MR_echo_commands = FALSE;
@@ -441,10 +443,13 @@
 		MR_insert_line_at_head(MR_copy_string(semicolon + 1));
 	}
 
+	/* if we're using readline, then readline does the echoing */
+#ifdef MR_NO_USE_READLINE
 	if (MR_echo_commands) {
 		fputs(line, MR_mdb_out);
 		putc('\n', MR_mdb_out);
 	}
+#endif
 
 	problem = MR_trace_parse_line(line, &words, &word_max, &word_count);
 	if (problem != NULL) {
@@ -1083,13 +1088,31 @@
 	} else if (streq(words[0], "echo")) {
 		if (word_count == 2) {
 			if (streq(words[1], "off")) {
+#ifdef MR_NO_USE_READLINE
 				MR_echo_commands = FALSE;
 				if (MR_trace_internal_interacting) {
 					fprintf(MR_mdb_out,
 						"Command echo disabled.\n");
 				}
+#else
+				/* with readline, echoing is always enabled */
+				fprintf(MR_mdb_err, "Sorry, cannot disable "
+					"echoing when using GNU readline.\n");
+				
+#endif
 			} else if (streq(words[1], "on")) {
-				MR_echo_commands = TRUE;
+#ifdef MR_NO_USE_READLINE
+				if (!MR_echo_commands) {
+					/*
+					** echo the `echo on' command
+					** This is needed for testing, so that
+					** we get the same output both with
+					** and without readline.
+					*/
+					fprintf(MR_mdb_out, "echo on\n");
+					MR_echo_commands = TRUE;
+				}
+#endif
 				if (MR_trace_internal_interacting) {
 					fprintf(MR_mdb_out,
 						"Command echo enabled.\n");
@@ -1099,11 +1122,17 @@
 			}
 		} else if (word_count == 1) {
 			fprintf(MR_mdb_out, "Command echo is ");
+#ifdef MR_NO_USE_READLINE
 			if (MR_echo_commands) {
 				fprintf(MR_mdb_out, "on.\n");
 			} else {
 				fprintf(MR_mdb_out, "off.\n");
 			}
+#else
+			/* with readline, echoing is always enabled */
+			fprintf(MR_mdb_out, "on.\n");
+#endif
+			
 		} else {
 			MR_trace_usage("parameter", "echo");
 		}
-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3        |     -- the last words of T. S. Garp.



More information about the developers mailing list