Index: trunk/phase3/math/render.ml |
— | — | @@ -1,17 +1,19 @@ |
2 | | -let cmd_dvips tmpprefix = "dvips -q -R -E " ^ tmpprefix ^ ".dvi -f" |
| 2 | +let cmd_dvips tmpprefix = "dvips -R -E " ^ tmpprefix ^ ".dvi -f >" ^ tmpprefix ^ ".ps" |
3 | 3 | let cmd_latex tmpprefix = "latex " ^ tmpprefix ^ ".tex >/dev/null" |
4 | | -let cmd_convert finalpath = "convert -quality 100 -density 120 ps:- " ^ finalpath ^ " >/dev/null 2>/dev/null" |
| 4 | +let cmd_convert tmpprefix finalpath = "convert -quality 100 -density 120 " ^ tmpprefix ^ ".ps " ^ finalpath ^ " >/dev/null 2>/dev/null" |
5 | 5 | |
6 | 6 | exception ExternalCommandFailure of string |
7 | 7 | |
8 | 8 | let render tmppath finalpath outtex md5 = |
9 | | - let tmpprefix = (tmppath^"/"^(string_of_int (Unix.getpid ()))^"_"^md5) in |
| 9 | + let tmpprefix0 = (string_of_int (Unix.getpid ()))^"_"^md5 in |
| 10 | + let tmpprefix = (tmppath^"/"^tmpprefix0) in |
10 | 11 | let unlink_all () = |
11 | 12 | begin |
12 | 13 | Sys.remove (tmpprefix ^ ".dvi"); |
13 | 14 | Sys.remove (tmpprefix ^ ".aux"); |
14 | 15 | Sys.remove (tmpprefix ^ ".log"); |
15 | | - Sys.remove (tmpprefix ^ ".tex") |
| 16 | + Sys.remove (tmpprefix ^ ".tex"); |
| 17 | + Sys.remove (tmpprefix ^ ".ps"); |
16 | 18 | end in |
17 | 19 | let f = (Util.open_out_unless_exists (tmpprefix ^ ".tex")) in |
18 | 20 | begin |
— | — | @@ -19,9 +21,11 @@ |
20 | 22 | output_string f outtex; |
21 | 23 | output_string f (Texutil.get_footer ()); |
22 | 24 | close_out f; |
23 | | - if Util.run_in_other_directory tmppath (cmd_latex tmpprefix) != 0 |
| 25 | + if Util.run_in_other_directory tmppath (cmd_latex tmpprefix0) != 0 |
24 | 26 | then (unlink_all (); raise (ExternalCommandFailure "latex")) |
25 | | - else if (Sys.command ((cmd_dvips tmpprefix) ^ " | " ^ (cmd_convert (finalpath^"/"^md5^".png"))) != 0) |
26 | | - then (unlink_all (); raise (ExternalCommandFailure ("dvips"))) |
| 27 | + else if (Sys.command (cmd_dvips tmpprefix) != 0) |
| 28 | + then (unlink_all (); raise (ExternalCommandFailure "dvips")) |
| 29 | + else if (Sys.command (cmd_convert tmpprefix (finalpath^"/"^md5^".png")) != 0) |
| 30 | + then (unlink_all (); raise (ExternalCommandFailure "convert")) |
27 | 31 | else unlink_all () |
28 | 32 | end |