[m-rev.] For review: use XML browser to browse terms in mdb
Zoltan Somogyi
zs at cs.mu.OZ.AU
Thu Dec 9 14:32:22 AEDT 2004
On 09-Dec-2004, Ian MacLarty <maclarty at cs.mu.OZ.AU> wrote:
> XML is dumped and the command used to browse the XML. The defaults assume
> xsltproc and mozilla are installed.
How easy would it be to not require xsltproc? For example, my laptop doesn't
have it installed. This is a question, not an objection.
> +save_term_to_file_xml(FileName, BrowserTerm, OutStream, !IO) :-
> + io__tell(FileName, FileStreamRes, !IO),
> + (
> + FileStreamRes = ok,
> + (
> + BrowserTerm = plain_term(Univ),
> + Term = univ_value(Univ),
> + term_to_xml.write_xml_doc_cc(Term, simple,
> + no_stylesheet, no_dtd, _, !IO)
> + ;
> + BrowserTerm = synthetic_term(Functor, Args, MaybeRes),
> + (
> + MaybeRes = no,
> + PredicateTerm = predicate(Functor, Args),
> + term_to_xml.write_xml_doc_cc(PredicateTerm,
> + simple, no_stylesheet, no_dtd, _, !IO)
> + ;
> + MaybeRes = yes(Result),
> + FunctionTerm = function(Functor, Args, Result),
> + term_to_xml.write_xml_doc_cc(FunctionTerm,
> + simple, no_stylesheet, no_dtd, _, !IO)
> )
> ),
The format of the synthetic terms is not the best possible, but it is OK
for now. However, you should put an XXX there as a reminder.
> --- tests/debugger/browser_test.inp 5 Nov 2004 06:30:20 -0000 1.11
> +++ tests/debugger/browser_test.inp 9 Dec 2004 01:38:16 -0000
> @@ -36,6 +36,10 @@
> cdr 3 ../1/..
> ls
> quit
> +set xml_tmp_filename './tmp.xml'
> +set xml_browser_cmd 'cat ./tmp.xml'
> +browse --xml 1
> +browse -x Data
> set -A -f depth 1
You should add tmp.xml to the list of filenames to be removed by mmake clean
in that directory.
> +static char MR_xml_browser_command[MR_XML_BROWSER_COMMAND_LENGTH] = "";
> +static char MR_xml_tmp_filename[MR_XML_TMP_FILENAME_LENGTH] = "";
The command name definitely should have dynamic size; as big as needed.
This would also be nice for the filename.
> +static void
> +MR_trace_browse_xml(MR_Word type_info, MR_Word value,
> + MR_Browse_Caller_Type caller, MR_Browse_Format format)
> +{
> + MR_Word browser_term;
> +
> + browser_term = MR_type_value_to_browser_term((MR_TypeInfo) type_info,
> + value);
> +
> + MR_trace_save_term_xml("tmp.xml", browser_term);
> +
> + MR_trace_save_and_invoke_xml_browser(browser_term);
> +}
Why the fixed filename here?
> - if (! MR_trace_options_param_set(&print_set, &browse_set,
> + if (word_count == 3 && MR_streq(words[1], "xml_browser_cmd")) {
> + strcpy(MR_xml_browser_command, words[2]);
> + } else if (word_count == 3 && MR_streq(words[1], "xml_tmp_filename")) {
> + strcpy(MR_xml_tmp_filename, words[2]);
> + } else if (! MR_trace_options_param_set(&print_set, &browse_set,
At the very least, check the length of words[2] before doing the assignment.
Otherwise, the diff is fine. Commit when you have fixed the above.
Zoltan.
--------------------------------------------------------------------------
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