[m-dev.] for review: use readline in the browser

Mark Anthony BROWN dougl at cs.mu.OZ.AU
Thu May 13 15:18:16 AEST 1999


Zoltan Somogyi writes:
> 
> 
> > +:- pragma c_code(call_trace_getline(Prompt::in, Line::out),
> > +	[will_not_call_mercury],
> > +	"
> > +		char		*line;
> > +		char		*mercury_string;
> > +
> > +		line = MR_address_of_trace_getline((char *)Prompt);
> 
> The change looks good, except I would write the above as
> 
> 		line = (*MR_address_of_trace_getline)((char *) Prompt);
> 
> to make clear what is happening.

OK.

> 
> Being paranoid, I would also check beforehand whether the function pointer
> is NULL.
> 

OK.  I will go ahead and commit it now, but I have appended a
relative diff in case anyone is interested.

The log message has the following added to it:

runtime/mercury_trace_base.c:
runtime/mercury_trace_base.h:
	Export MR_tracing_not_enabled() for use by browser/util.m.

Cheers,
Mark.


--- browser/util.m	Wed May 12 16:03:14 1999
+++ /home/pgrad/dougl/ws2/mercury/browser/util.m	Wed May 12 18:44:29 1999
@@ -1,5 +1,5 @@
 %---------------------------------------------------------------------------%
-% Copyright (C) 1998 The University of Melbourne.
+% Copyright (C) 1998-1999 The University of Melbourne.
 % This file may only be copied under the terms of the GNU Library General
 % Public License - see the file COPYING.LIB in the Mercury distribution.
 %---------------------------------------------------------------------------%
@@ -47,6 +47,7 @@
 :- pragma c_header_code("
 	#include ""mercury_wrapper.h""
 	#include ""mercury_string.h""
+	#include ""mercury_trace_base.h""
 	#include ""mercury_trace_internal.h""
 ").
 
@@ -56,7 +57,12 @@
 		char		*line;
 		char		*mercury_string;
 
-		line = MR_address_of_trace_getline((char *)Prompt);
+		if (MR_address_of_trace_getline != NULL) {
+			line = (*MR_address_of_trace_getline)((char *) Prompt);
+		} else {
+			MR_tracing_not_enabled();
+			/* not reached */
+		}
 
 		if (line == NULL) {
 			SUCCESS_INDICATOR = FALSE;


--- runtime/mercury_trace_base.h	Mon May 10 21:16:33 1999
+++ /home/pgrad/dougl/ws2/mercury/runtime/mercury_trace_base.h	Wed May 12 18:43:31 1999
@@ -137,6 +137,14 @@
 extern	void	MR_trace_report_raw(int fd);
 
 /*
+** This function prints an error message and aborts.  It should be
+** called in situations where tracing is required, but `--trace' was
+** not passed to c2init.
+*/
+
+extern	void	MR_tracing_not_enabled(void);
+
+/*
 ** If MR_TRACE_HISTOGRAM is defined, MR_trace maintains two arrays of integers,
 ** MR_trace_histogram_all and MR_trace_histogram_exp, in which the element
 ** with subscript d is incremented when a trace event occurs at depth d.


--- runtime/mercury_trace_base.c	Mon May 10 21:16:33 1999
+++ /home/pgrad/dougl/ws2/mercury/runtime/mercury_trace_base.c	Wed May 12 18:38:27 1999
@@ -212,7 +212,7 @@
 			path, max_r_num);
 }
 
-static void
+void
 MR_tracing_not_enabled(void)
 {
 	fatal_error("This executable is not set up for debugging.\n"


-- 
Mark Brown  (dougl at cs.mu.oz.au)       )O+   |  For Microsoft to win,
MEngSc student,                             |  the customer must lose
Dept of Computer Science, Melbourne Uni     |          -- Eric S. Raymond
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list