diff: fix readline command-line echoing problem

Fergus Henderson fjh at cs.mu.OZ.AU
Thu Apr 8 22:32:20 AEST 1999


The debugging tests were failing, because they use `echo on',
and readline already does echoing, so all the commands were
getting echoed twice.

--------------------

Estimated hours taken: 0.75

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'.

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 08:32:56
@@ -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,11 +1088,18 @@
 	} 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;
 				if (MR_trace_internal_interacting) {
@@ -1099,11 +1111,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