tuned use_text;
authorwenzelm
Fri, 08 Dec 2006 23:25:54 +0100
changeset 21715 9c19f90272e8
parent 21714 d64cb19c79e2
child 21716 8fcacb0e3b15
tuned use_text; eval command line: skip over -q option;
src/Pure/ML-Systems/polyml.ML
--- a/src/Pure/ML-Systems/polyml.ML	Fri Dec 08 23:25:53 2006 +0100
+++ b/src/Pure/ML-Systems/polyml.ML	Fri Dec 08 23:25:54 2006 +0100
@@ -90,19 +90,11 @@
 
 (* ML command execution -- 'eval' *)
 
-local
-
-fun drop_last [] = []
-  | drop_last [x] = []
-  | drop_last (x :: xs) = x :: drop_last xs;
-
-in
-
 fun use_text (print, err) verbose txt =
   let
     val in_buffer = ref (explode txt);
     val out_buffer = ref ([]: string list);
-    fun output () = implode (drop_last (rev (! out_buffer)));
+    fun output () = implode (rev (case ! out_buffer of "\n" :: cs => cs | cs => cs));
 
     fun get () =
       (case ! in_buffer of
@@ -119,14 +111,13 @@
     if verbose then print (output ()) else ()
   end;
 
-end;
-
 
 (*eval command line arguments*)
 local
   fun println s =
     (TextIO.output (TextIO.stdOut, s ^ "\n"); TextIO.flushOut TextIO.stdOut);
-  val eval = use_text (println, println) true;
+  fun eval "-q" = ()
+    | eval txt = use_text (println, println) false txt;
 in
   val _ = PolyML.onEntry (fn () => app eval (CommandLine.arguments ()));
 end;