summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorXavier Leroy <xavier.leroy@inria.fr>2006-08-30 11:22:24 +0000
committerXavier Leroy <xavier.leroy@inria.fr>2006-08-30 11:22:24 +0000
commitf6fc1f39c1c303f8cbb942ad66e904ca8cfe56ba (patch)
tree5ff2ac8cf79e9589e5ad2229cbe2e589fb0964cb /tools
parent5120db57c66ebb42722f4e1708023ad007ddacb5 (diff)
downloadocaml-f6fc1f39c1c303f8cbb942ad66e904ca8cfe56ba.tar.gz
Revu traitement de l'option -slash (PR#4050). A tester.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@7574 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'tools')
-rw-r--r--tools/ocamldep.ml20
1 files changed, 14 insertions, 6 deletions
diff --git a/tools/ocamldep.ml b/tools/ocamldep.ml
index 7e632d3556..e91a70f308 100644
--- a/tools/ocamldep.ml
+++ b/tools/ocamldep.ml
@@ -25,6 +25,18 @@ let native_only = ref false
let force_slash = ref false
let error_occurred = ref false
+(* Fix path to use '/' as directory separator instead of '\'.
+ Only under Windows. *)
+
+let fix_slash s =
+ if Sys.os_type = "Unix" then s else begin
+ let r = String.copy s in
+ for i = 0 to String.length r - 1 do
+ if r.[i] = '\\' then r.[i] <- '/'
+ done;
+ r
+ end
+
let add_to_load_path dir =
try
let dir = Misc.expand_directory Config.standard_library dir in
@@ -34,11 +46,6 @@ let add_to_load_path dir =
fprintf Format.err_formatter "@[Bad -I option: %s@]@." msg;
error_occurred := true
-let concat_filename dirname filename =
- if dirname = Filename.current_dir_name then filename
- else if !force_slash then dirname ^ "/" ^ filename
- else Filename.concat dirname filename
-
let find_file name =
let uname = String.uncapitalize name in
let rec find_in_array a pos =
@@ -50,7 +57,7 @@ let find_file name =
[] -> raise Not_found
| (dir, contents) :: rem ->
match find_in_array contents 0 with
- Some truename -> concat_filename dir truename
+ Some truename -> Filename.concat dir truename
| None -> find_in_path rem in
find_in_path !load_path
@@ -76,6 +83,7 @@ let find_dependency modname (byt_deps, opt_deps) =
let (depends_on, escaped_eol) = (": ", "\\\n ")
let print_filename s =
+ let s = if !force_slash then fix_slash s else s in
if not (String.contains s ' ') then begin
print_string s;
end else begin