equal
deleted
inserted
replaced
7 required). |
7 required). |
8 *) |
8 *) |
9 |
9 |
10 signature USE = |
10 signature USE = |
11 sig |
11 sig |
12 val use_text: string -> string -> unit |
|
13 val use: string -> unit |
12 val use: string -> unit |
14 val exit_use: string -> unit |
13 val exit_use: string -> unit |
15 val time_use: string -> unit |
14 val time_use: string -> unit |
16 val cd: string -> unit |
15 val cd: string -> unit |
17 end; |
16 end; |
18 |
17 |
19 structure Use: USE = |
18 structure Use: USE = |
20 struct |
19 struct |
21 |
|
22 |
|
23 (* use_text *) |
|
24 |
|
25 val use_orig = use; |
|
26 |
|
27 fun use_text name txt = |
|
28 let |
|
29 val tmp_name = File.tmp_name ("." ^ Path.base_name name); |
|
30 val _ = File.write tmp_name txt; |
|
31 val rm = OS.FileSys.remove; |
|
32 in |
|
33 use_orig tmp_name handle exn => (rm tmp_name; raise exn); |
|
34 rm tmp_name |
|
35 end; |
|
36 |
|
37 |
20 |
38 (* generate suffix *) |
21 (* generate suffix *) |
39 |
22 |
40 fun append_suffix name = |
23 fun append_suffix name = |
41 let |
24 let |
46 in try ["", ".ML", ".sml"] end; |
29 in try ["", ".ML", ".sml"] end; |
47 |
30 |
48 |
31 |
49 (* input filtering *) |
32 (* input filtering *) |
50 |
33 |
|
34 val use_orig = use; |
|
35 |
51 val use_filter = |
36 val use_filter = |
52 if not needs_filtered_use then use_orig |
37 if not needs_filtered_use then use_orig |
53 else |
38 else |
54 fn name => |
39 fn name => |
55 let |
40 let |
56 val txt = File.read name; |
41 val txt = File.read name; |
57 val txt_out = Symbol.input txt; |
42 val txt_out = Symbol.input txt; |
58 in |
43 in |
59 if txt = txt_out then use_orig name |
44 if txt = txt_out then use_orig name |
60 else use_text name txt_out |
45 else |
|
46 let |
|
47 val tmp_name = File.tmp_name ("." ^ Path.base_name name); |
|
48 val _ = File.write tmp_name txt_out; |
|
49 val rm = OS.FileSys.remove; |
|
50 in |
|
51 use_orig tmp_name handle exn => (rm tmp_name; raise exn); |
|
52 rm tmp_name |
|
53 end |
61 end; |
54 end; |
62 |
55 |
63 |
56 |
64 (* use commands *) |
57 (* use commands *) |
65 |
58 |