浏览代码

clean up windows and path separator detection a bit

Dan Korostelev 9 年之前
父节点
当前提交
f60de5fa06
共有 4 个文件被更改,包括 8 次插入6 次删除
  1. 1 2
      src/macro/interp.ml
  2. 1 2
      src/main.ml
  3. 5 1
      src/typing/common.ml
  4. 1 1
      src/typing/typeload.ml

+ 1 - 2
src/macro/interp.ml

@@ -511,8 +511,7 @@ let rec dlopen dls =
 		None
 
 let neko =
-	let is_win = Sys.os_type = "Win32" || Sys.os_type = "Cygwin" in
-	match dlopen (if is_win then
+	match dlopen (if is_windows then
 		["neko.dll"]
 	else
 		(*

+ 1 - 2
src/main.ml

@@ -71,7 +71,6 @@ let measure_times = ref false
 let prompt = ref false
 let start_time = ref (get_time())
 
-let path_sep = if Sys.os_type = "Unix" then "/" else "\\"
 
 let executable_path() =
 	Extc.executable_path()
@@ -440,7 +439,7 @@ let run_command ctx cmd =
 		0
 	end else
 	let binary_string s =
-		if Sys.os_type <> "Win32" && Sys.os_type <> "Cygwin" then s else String.concat "\n" (Str.split (Str.regexp "\r\n") s)
+		if not is_windows then s else String.concat "\n" (Str.split (Str.regexp "\r\n") s)
 	in
 	let pout, pin, perr = Unix.open_process_full cmd (Unix.environment()) in
 	let iout = Unix.descr_of_in_channel pout in

+ 5 - 1
src/typing/common.ml

@@ -1127,7 +1127,11 @@ let find_file ctx f =
 
 let get_full_path f = try Extc.get_full_path f with _ -> f
 
-let unique_full_path = if Sys.os_type = "Win32" || Sys.os_type = "Cygwin" then (fun f -> String.lowercase (get_full_path f)) else get_full_path
+let is_windows = Sys.os_type = "Win32" || Sys.os_type = "Cygwin"
+
+let path_sep = if is_windows then "\\" else "/"
+
+let unique_full_path = if is_windows then (fun f -> String.lowercase (get_full_path f)) else get_full_path
 
 let get_real_path p =
 	try

+ 1 - 1
src/typing/typeload.ml

@@ -3468,7 +3468,7 @@ let type_types_into_module ctx m tdecls p =
 
 let handle_import_hx ctx m decls p =
 	let path_split = List.tl (List.rev (get_path_parts m.m_extra.m_file)) in
-	let join l = String.concat (if Sys.os_type = "Win32" || Sys.os_type = "Cygwin" then "\\" else "/") (List.rev ("import.hx" :: l)) in
+	let join l = String.concat path_sep (List.rev ("import.hx" :: l)) in
 	let rec loop path pack = match path,pack with
 		| _,[] -> [join path]
 		| (p :: path),(_ :: pack) -> (join (p :: path)) :: (loop path pack)