r4186 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r4185‎ | r4186 | r4187 >
Date:11:09, 28 June 2004
Author:taw
Status:old
Tags:
Comment:
render.ml updated to support newer ImageMagick and relative filepaths
Modified paths:
  • /trunk/phase3/math/render.ml (modified) (history)

Diff [purge]

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"
33 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"
55
66 exception ExternalCommandFailure of string
77
88 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
1011 let unlink_all () =
1112 begin
1213 Sys.remove (tmpprefix ^ ".dvi");
1314 Sys.remove (tmpprefix ^ ".aux");
1415 Sys.remove (tmpprefix ^ ".log");
15 - Sys.remove (tmpprefix ^ ".tex")
 16+ Sys.remove (tmpprefix ^ ".tex");
 17+ Sys.remove (tmpprefix ^ ".ps");
1618 end in
1719 let f = (Util.open_out_unless_exists (tmpprefix ^ ".tex")) in
1820 begin
@@ -19,9 +21,11 @@
2022 output_string f outtex;
2123 output_string f (Texutil.get_footer ());
2224 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
2426 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"))
2731 else unlink_all ()
2832 end

Status & tagging log