src/Pure/ML-Systems/smlnj.ML
author wenzelm
Wed, 13 Oct 1999 19:42:46 +0200
changeset 7855 092a6435afad
parent 6227 3198f547f8af
child 7890 0aa16bc2abdb
permissions -rw-r--r--
system; use_text: pass print function;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4403
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
     1
(*  Title:      Pure/ML-Systems/smlnj.ML
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
     2
    ID:         $Id$
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
     3
    Author:     Carsten Clasohm and Markus Wenzel, TU Muenchen
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
     4
5708
fb09ab6a447f dropped support for SML/NJ 109.x;
wenzelm
parents: 5090
diff changeset
     5
Compatibility file for Standard ML of New Jersey 110 or later.
4403
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
     6
*)
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
     7
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
     8
(** ML system related **)
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
     9
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    10
(* restore old-style character / string functions *)
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    11
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    12
fun ord s = Char.ord (String.sub (s, 0));
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    13
val chr = str o Char.chr;
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    14
val explode = (map str) o String.explode;
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    15
val implode = String.concat;
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    16
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    17
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    18
(* New Jersey ML parameters *)
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    19
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    20
val _ =
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    21
 (Compiler.Control.Print.printLength := 1000;
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    22
  Compiler.Control.Print.printDepth := 350;
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    23
  Compiler.Control.Print.stringDepth := 250;
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    24
  Compiler.Control.Print.signatures := 2);
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    25
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    26
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    27
(* Poly/ML emulation *)
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    28
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    29
fun quit () = exit 0;
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    30
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    31
(*limit the printing depth -- divided by 2 for comparibility with Poly/ML*)
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    32
fun print_depth n =
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    33
 (Compiler.Control.Print.printDepth := n div 2;
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    34
  Compiler.Control.Print.printLength := n);
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    35
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    36
5816
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
    37
(* compiler-independent timing functions *)
4403
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    38
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    39
(*Note start point for timing*)
5816
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
    40
fun startTiming() =
4403
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    41
  let val CPUtimer = Timer.startCPUTimer();
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    42
      val time = Timer.checkCPUTimer(CPUtimer)
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    43
  in  (CPUtimer,time)  end;
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    44
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    45
(*Finish timing and return string*)
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    46
fun endTiming (CPUtimer, {gc,sys,usr}) =
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    47
  let open Time  (*...for Time.toString, Time.+ and Time.- *)
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    48
      val {gc=gc2,sys=sys2,usr=usr2} = Timer.checkCPUTimer(CPUtimer)
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    49
  in  "User " ^ toString (usr2-usr) ^
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    50
      "  GC " ^ toString (gc2-gc) ^
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    51
      "  All "^ toString (sys2-sys + usr2-usr + gc2-gc) ^
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    52
      " secs"
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    53
      handle Time => ""
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    54
  end;
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    55
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    56
4977
6cec2c0ffdbf added ml_prompts;
wenzelm
parents: 4428
diff changeset
    57
(* prompts *)
6cec2c0ffdbf added ml_prompts;
wenzelm
parents: 4428
diff changeset
    58
6cec2c0ffdbf added ml_prompts;
wenzelm
parents: 4428
diff changeset
    59
fun ml_prompts p1 p2 =
6cec2c0ffdbf added ml_prompts;
wenzelm
parents: 4428
diff changeset
    60
  (Compiler.Control.primaryPrompt := p1; Compiler.Control.secondaryPrompt := p2);
6cec2c0ffdbf added ml_prompts;
wenzelm
parents: 4428
diff changeset
    61
6cec2c0ffdbf added ml_prompts;
wenzelm
parents: 4428
diff changeset
    62
4403
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    63
(* toplevel pretty printing (see also Pure/install_pp.ML) *)
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    64
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    65
fun make_pp path pprint =
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    66
  let
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    67
    open Compiler.PrettyPrint;
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    68
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    69
    fun pp pps obj =
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    70
      pprint obj
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    71
        (add_string pps, begin_block pps INCONSISTENT,
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    72
          fn wd => add_break pps (wd, 0), fn () => add_newline pps,
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    73
          fn () => end_block pps);
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    74
  in
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    75
    (path, pp)
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    76
  end;
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    77
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    78
fun install_pp (path, pp) = Compiler.PPTable.install_pp path pp;
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    79
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    80
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    81
(* ML command execution *)
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    82
7855
092a6435afad system;
wenzelm
parents: 6227
diff changeset
    83
fun use_text print verbose txt =
5090
75ac9b451ae0 use_text: verbose flag;
wenzelm
parents: 5038
diff changeset
    84
  let
75ac9b451ae0 use_text: verbose flag;
wenzelm
parents: 5038
diff changeset
    85
    val ref out_orig = Compiler.Control.Print.out;
75ac9b451ae0 use_text: verbose flag;
wenzelm
parents: 5038
diff changeset
    86
75ac9b451ae0 use_text: verbose flag;
wenzelm
parents: 5038
diff changeset
    87
    val out_buffer = ref ([]: string list);
75ac9b451ae0 use_text: verbose flag;
wenzelm
parents: 5038
diff changeset
    88
    val out = {say = (fn s => out_buffer := s :: ! out_buffer), flush = (fn () => ())};
75ac9b451ae0 use_text: verbose flag;
wenzelm
parents: 5038
diff changeset
    89
75ac9b451ae0 use_text: verbose flag;
wenzelm
parents: 5038
diff changeset
    90
    fun show_output () = print (implode (rev (! out_buffer)));
75ac9b451ae0 use_text: verbose flag;
wenzelm
parents: 5038
diff changeset
    91
  in
75ac9b451ae0 use_text: verbose flag;
wenzelm
parents: 5038
diff changeset
    92
    Compiler.Control.Print.out := out;
75ac9b451ae0 use_text: verbose flag;
wenzelm
parents: 5038
diff changeset
    93
    Compiler.Interact.useStream (TextIO.openString txt) handle exn =>
75ac9b451ae0 use_text: verbose flag;
wenzelm
parents: 5038
diff changeset
    94
      (Compiler.Control.Print.out := out_orig; show_output (); raise exn);
75ac9b451ae0 use_text: verbose flag;
wenzelm
parents: 5038
diff changeset
    95
    Compiler.Control.Print.out := out_orig;
75ac9b451ae0 use_text: verbose flag;
wenzelm
parents: 5038
diff changeset
    96
    if verbose then show_output () else ()
75ac9b451ae0 use_text: verbose flag;
wenzelm
parents: 5038
diff changeset
    97
  end;
4403
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    98
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
    99
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
   100
5816
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   101
(** interrupts **)
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   102
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   103
local
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   104
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   105
datatype 'a result =
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   106
  Result of 'a |
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   107
  Exn of exn;
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   108
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   109
fun capture f x = Result (f x) handle exn => Exn exn;
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   110
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   111
fun release (Result x) = x
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   112
  | release (Exn exn) = raise exn;
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   113
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   114
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   115
val sig_int = Signals.sigINT;
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   116
val sig_int_mask = Signals.MASK [Signals.sigINT];
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   117
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   118
fun interruptible () =
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   119
  (case Signals.masked () of
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   120
    Signals.MASKALL => false
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   121
  | Signals.MASK sigs => List.all (fn s => s <> sig_int) sigs);
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   122
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   123
val mask_signals = Signals.maskSignals;
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   124
val unmask_signals = Signals.unmaskSignals;
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   125
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   126
fun change_mask ok change unchange f x =
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   127
  if ok () then f x
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   128
  else
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   129
    let
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   130
      val _ = change sig_int_mask;
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   131
      val result = capture f x;
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   132
      val _ = unchange sig_int_mask;
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   133
    in release result end;
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   134
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   135
in
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   136
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   137
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   138
(* mask / unmask interrupt *)
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   139
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   140
fun mask_interrupt f = change_mask (not o interruptible) mask_signals unmask_signals f;
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   141
fun unmask_interrupt f = change_mask interruptible unmask_signals mask_signals f;
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   142
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   143
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   144
(* exhibit interrupt (via exception) *)
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   145
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   146
exception Interrupt;
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   147
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   148
fun exhibit_interrupt f x =
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   149
  let
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   150
    val orig_handler = Signals.inqHandler sig_int;
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   151
    fun reset_handler () = (Signals.setHandler (sig_int, orig_handler); ());
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   152
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   153
    val interrupted = ref false;
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   154
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   155
    fun set_handler cont =
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   156
      Signals.setHandler (sig_int, Signals.HANDLER (fn _ => (interrupted := true; cont)));
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   157
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   158
    fun proceed cont =
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   159
      let
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   160
        val _ = set_handler cont;
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   161
        val result = unmask_interrupt (capture f) x;
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   162
        val _ = reset_handler ();
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   163
      in release result end;
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   164
  in
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   165
    SMLofNJ.Cont.callcc proceed;
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   166
    reset_handler ();
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   167
    if ! interrupted then raise Interrupt else ()
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   168
   end;
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   169
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   170
end;
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   171
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   172
6f3cb53502fa smart interrupt handler;
wenzelm
parents: 5708
diff changeset
   173
4403
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
   174
(** OS related **)
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
   175
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
   176
(* system command execution *)
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
   177
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
   178
(*execute Unix command which doesn't take any input from stdin and
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
   179
  sends its output to stdout; could be done more easily by Unix.execute,
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
   180
  but that function doesn't use the PATH*)
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
   181
fun execute command =
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
   182
  let
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
   183
    val tmp_name = OS.FileSys.tmpName ();
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
   184
    val is = (OS.Process.system (command ^ " > " ^ tmp_name); TextIO.openIn tmp_name);
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
   185
    val result = TextIO.inputAll is;
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
   186
  in
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
   187
    TextIO.closeIn is;
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
   188
    OS.FileSys.remove tmp_name;
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
   189
    result
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
   190
  end;
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
   191
7855
092a6435afad system;
wenzelm
parents: 6227
diff changeset
   192
(*plain version; with return code*)
092a6435afad system;
wenzelm
parents: 6227
diff changeset
   193
val system = OS.Process.system: string -> int; 
092a6435afad system;
wenzelm
parents: 6227
diff changeset
   194
4403
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
   195
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
   196
(* file handling *)
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
   197
6227
3198f547f8af fixed file_info;
wenzelm
parents: 5816
diff changeset
   198
(*get time of last modification*)
3198f547f8af fixed file_info;
wenzelm
parents: 5816
diff changeset
   199
fun file_info name = Time.toString (OS.FileSys.modTime name) handle _ => "";
4403
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
   200
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
   201
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
   202
(* getenv *)
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
   203
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
   204
fun getenv var =
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
   205
  (case OS.Process.getEnv var of
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
   206
    NONE => ""
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
   207
  | SOME txt => txt);
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
   208
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
   209
4428
5c26253b8a2e tuned comment;
wenzelm
parents: 4407
diff changeset
   210
(* non-ASCII input (see also Thy/use.ML) *)
4403
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
   211
1914f727f93f Compatibility file for Standard ML of New Jersey.
wenzelm
parents:
diff changeset
   212
val needs_filtered_use = false;