[m-rev.] for review: fix call_trace_getline
Fergus Henderson
fjh at cs.mu.OZ.AU
Wed Aug 14 01:24:28 AEST 2002
Branches: main
Estimated hours taken: 3
Fix a bug which broke tests/debugger/interactive_query in non-GC grades,
e.g. asm_fast on murlibobo (dec-alpha-osf*).
browser/util.m:
Fix a bug: call_trace_getline needs to be annotated with
`will_not_call_mercury' instead of `may_call_mercury'.
This is required because the code for it accesses MR_hp,
which is only valid if `will_not_call_mercury' is specified.
The fix also required changing the return type from bool to int,
so that it can return the right value without calling Mercury code.
Workspace: /home/ceres/fjh/ws-ceres2/mercury
Index: browser/util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/browser/util.m,v
retrieving revision 1.18
diff -u -d -r1.18 util.m
--- browser/util.m 30 Jul 2002 10:24:36 -0000 1.18
+++ browser/util.m 13 Aug 2002 15:20:55 -0000
@@ -81,8 +81,7 @@
%---------------------------------------------------------------------------%
:- implementation.
-:- import_module bool, int, require.
-:- pragma foreign_import_module(c, bool).
+:- import_module int, require.
util__trace_getline(Prompt, Result) -->
io__input_stream(MdbIn),
@@ -91,16 +90,14 @@
util__trace_getline(Prompt, Result, MdbIn, MdbOut) -->
call_trace_getline(MdbIn, MdbOut, Prompt, Line, Success),
- {
- Success = yes,
+ { Success \= 0 ->
Result = ok(Line)
;
- Success = no,
Result = eof
}.
:- pred call_trace_getline(input_stream::in, output_stream::in, string::in,
- string::out, bool::out, io__state::di, io__state::uo) is det.
+ string::out, int::out, io__state::di, io__state::uo) is det.
:- pragma c_header_code("
#include ""mercury_wrapper.h""
@@ -113,7 +110,10 @@
:- pragma foreign_proc("C",
call_trace_getline(MdbIn::in, MdbOut::in, Prompt::in, Line::out,
Success::out, IO0::di, IO::uo),
- [may_call_mercury, promise_pure, tabled_for_io],
+ % We need to use will_not_call_mercury here,
+ % because MR_make_aligned_string_copy() references MR_hp,
+ % which only works for will_not_call_mercury foreign_procs.
+ [will_not_call_mercury, promise_pure, tabled_for_io],
"
char *line;
MercuryFile *mdb_in = (MercuryFile *) MdbIn;
@@ -130,11 +130,11 @@
if (line == NULL) {
/* we copy the null string to avoid warnings about const */
MR_make_aligned_string_copy(Line, """");
- Success = ML_bool_return_no();
+ Success = 0;
} else {
MR_make_aligned_string_copy(Line, line);
MR_free(line);
- Success = ML_bool_return_yes();
+ Success = 1;
}
").
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
The University of Melbourne | of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list