OSDN Git Service

[REFACTOR]move os-depend code to Config.OS moudle
authormzp <mzpppp@gmail.com>
Wed, 28 Jan 2009 13:41:38 +0000 (22:41 +0900)
committermzp <mzpppp@gmail.com>
Wed, 28 Jan 2009 13:41:38 +0000 (22:41 +0900)
base/config.ml
driver/main.ml
scm/src/main.ml

index b43c24b..88abf31 100644 (file)
@@ -2,3 +2,26 @@
 let version =
   "0.4.1[2009-xx-xx]+auto-import"
 
+module OS = struct
+  let dir_sep =
+    if Sys.os_type = "Win32" then
+      ";"
+    else
+      ":"
+
+  let base =
+    Filename.dirname Sys.executable_name
+
+  let default_includes =
+    if Sys.os_type = "Win32" then
+      [Filename.concat base "./lib";"."]
+    else
+      [Filename.concat base "../lib/habc/";"."]
+
+  let default_template =
+    if Sys.os_type = "Win32" then
+      Filename.concat base "./template.xml"
+    else
+      Filename.concat base "../share/habc/template.xml"
+end
+
index 6f04e8e..1e37169 100644 (file)
@@ -1,26 +1,13 @@
+open Base
 open OptParse
 
-let (@@) f g =  f g
-let ($) f g x = f (g x)
-let flip f x y = f y x
-let tee f x = try ignore (f x); x with _ -> x
-
-let default_template =
-  let base =
-    Filename.dirname Sys.executable_name in
-    if Sys.os_type = "Win32" then
-      Filename.concat base "./template.xml"
-    else
-      Filename.concat base "../share/habc/template.xml"
-
-
 (* options *)
 let opt_parser =
   OptParser.make ~version:Config.version ~usage:"habc [options] <file>" ()
 
 let template =
   StdOpt.str_option
-    ~default:default_template
+    ~default:Config.OS.default_template
     ~metavar:"TEMPLATE" ()
 
 let output =
index d48245a..33c5262 100644 (file)
@@ -137,7 +137,8 @@ let parse_arguments _ =
   let inputs =
     OptParser.parse_argv opt in
   let includes =
-    "." :: (Str.split (Str.regexp ":") @@ get_option include_dir) in
+    (Str.split (Str.regexp Config.OS.dir_sep) @@ get_option include_dir) @
+      Config.OS.default_includes in
     if inputs = [] then begin
       OptParser.usage opt ();
       exit 0
@@ -189,5 +190,3 @@ let main () =
 let _ =
   if not !Sys.interactive then
     main ()
-
-