[m-dev.] diff: fix bugs with --filenames-from-stdin
Fergus Henderson
fjh at cs.mu.OZ.AU
Fri Jul 16 17:57:31 AEST 1999
Estimated hours taken: 0.5
compiler/mercury_compile.m:
Fix a couple of bugs with the handling of `--filenames-from-stdin':
- it wasn't removing the newline at the end of each line
- if --filenames-from-stdin is specified, it shouldn't complain
if there aren't any arguments on the command line
Note that currently there seems to be a problem with the conservative
garbage collector which causes a memory leak when you specify a lot of
file names. So the `--filenames-from-stdin' option is still
not very usable yet.
Workspace: /home/mercury0/fjh/mercury
Index: compiler/mercury_compile.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mercury_compile.m,v
retrieving revision 1.134
diff -u -r1.134 mercury_compile.m
--- mercury_compile.m 1999/07/12 06:21:20 1.134
+++ mercury_compile.m 1999/07/16 07:56:40
@@ -66,6 +66,8 @@
main_2(no, Args, Link) -->
globals__io_lookup_bool_option(help, Help),
globals__io_lookup_bool_option(output_grade_string, OutputGrade),
+ globals__io_lookup_bool_option(filenames_from_stdin,
+ FileNamesFromStdin),
( { Help = yes } ->
long_usage
; { OutputGrade = yes } ->
@@ -73,11 +75,9 @@
{ compute_grade(Globals, Grade) },
io__write_string(Grade),
io__write_string("\n")
- ; { Args = [] } ->
+ ; { Args = [], FileNamesFromStdin = no } ->
usage
;
- globals__io_lookup_bool_option(filenames_from_stdin,
- FileNamesFromStdin),
( { FileNamesFromStdin = yes } ->
process_stdin_arg_list([], ModulesToLink)
;
@@ -124,10 +124,14 @@
:- mode process_stdin_arg_list(in, out, di, uo) is det.
process_stdin_arg_list(Modules0, Modules) -->
- io__read_line(FileResult),
+ io__read_line_as_string(FileResult),
(
- { FileResult = ok(Arg0) },
- { string__from_char_list(Arg0, Arg) },
+ { FileResult = ok(Line) },
+ { string__remove_suffix(Line, "\n", Arg0) ->
+ Arg = Arg0
+ ;
+ Arg = Line
+ },
process_arg(Arg, Module), !,
{ list__append(Module, Modules0, Modules1) },
process_stdin_arg_list(Modules1, Modules)
--
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.
--------------------------------------------------------------------------
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