X-Git-Url: http://git.madism.org/?a=blobdiff_plain;f=tools%2Fcpkg2c.mll;h=0abfe8b9dd2b938fab1de937b3377c7c59131b3a;hb=a30218f8b3d68023d354d75b7c4674ae0c528f28;hp=cefc38990eaafe3776bb4b1c601a57d62b24dbd2;hpb=c855a6e8e9522ac9add840b18a869c831030f569;p=apps%2Fmadmutt.git diff --git a/tools/cpkg2c.mll b/tools/cpkg2c.mll index cefc389..0abfe8b 100644 --- a/tools/cpkg2c.mll +++ b/tools/cpkg2c.mll @@ -621,21 +621,21 @@ int luaopen_%s(lua_State *L) (* }}} *) let usage () = - output_string stderr "usage: cpkg2c (-h | -c) file.cpkg -o output\n"; + output_string stderr "usage: cpkg2c file.cpkg header.out source.out\n"; exit 1 + let warn ob = output_endline ob "/*** THIS FILE IS AUTOGENERATED !!! ***/" + + let process fn file l = + try Unix.unlink file with _ -> (); + let ob = open_out_gen [ Open_trunc ; Open_wronly; Open_creat ] 0o444 file in + warn ob; fn ob l; close_out ob + let _ = - let warn ob = output_endline ob "/*** THIS FILE IS AUTOGENERATED !!! ***/" in - if Array.length Sys.argv != 5 then usage(); - let file = Sys.argv.(2) in + if Array.length Sys.argv != 4 then usage(); + let file = Sys.argv.(1) in let lexbuf = L.from_channel (open_in file) in let l = (startchunk cLine file lexbuf) in - if Sys.argv.(3) = "-o" then - let ob = open_out_gen [ Open_trunc ; Open_wronly; Open_creat ] 0444 Sys.argv.(4) in - match Sys.argv.(1) with - | "-h" -> warn ob; do_h ob l; close_out ob - | "-c" -> warn ob; do_c ob l; close_out ob - | _ -> usage () - else - usage(); + process do_h Sys.argv.(2) l; + process do_c Sys.argv.(3) l }