summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Doligez <damien.doligez-inria.fr>2005-01-05 15:20:26 +0000
committerDamien Doligez <damien.doligez-inria.fr>2005-01-05 15:20:26 +0000
commitae4f94499c3419e9eb33146af6193b2663d7c00e (patch)
tree6b2dd6d219536dceba0c9ef8d9dddc3a555e9152
parentfd8179d8473f643d8fcdf09f7cdc0b706cbf5e6a (diff)
downloadocaml-ae4f94499c3419e9eb33146af6193b2663d7c00e.tar.gz
PR#3370 espaces dans les noms de fichiers
git-svn-id: http://caml.inria.fr/svn/ocaml/version/3.08@6743 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
-rw-r--r--tools/ocamldep.ml33
1 files changed, 30 insertions, 3 deletions
diff --git a/tools/ocamldep.ml b/tools/ocamldep.ml
index f0084732dd..b47aeefb15 100644
--- a/tools/ocamldep.ml
+++ b/tools/ocamldep.ml
@@ -75,19 +75,46 @@ let find_dependency modname (byt_deps, opt_deps) =
let (depends_on, escaped_eol) = (": ", "\\\n ")
+let print_filename s =
+ if not (String.contains s ' ') then begin
+ print_string s;
+ end else begin
+ let rec count n i =
+ if i >= String.length s then n
+ else if s.[i] = ' ' then count (n+1) (i+1)
+ else count n (i+1)
+ in
+ let spaces = count 0 0 in
+ let result = String.create (String.length s + spaces) in
+ let rec loop i j =
+ if i >= String.length s then ()
+ else if s.[i] = ' ' then begin
+ result.[j] <- '\\';
+ result.[j+1] <- ' ';
+ loop (i+1) (j+2);
+ end else begin
+ result.[j] <- s.[i];
+ loop (i+1) (j+1);
+ end
+ in
+ loop 0 0;
+ print_string result;
+ end
+;;
+
let print_dependencies target_file deps =
match deps with
[] -> ()
| _ ->
- print_string target_file; print_string depends_on;
+ print_filename target_file; print_string depends_on;
let rec print_items pos = function
[] -> print_string "\n"
| dep :: rem ->
if pos + String.length dep <= 77 then begin
- print_string dep; print_string " ";
+ print_filename dep; print_string " ";
print_items (pos + String.length dep + 1) rem
end else begin
- print_string escaped_eol; print_string dep; print_string " ";
+ print_string escaped_eol; print_filename dep; print_string " ";
print_items (String.length dep + 5) rem
end in
print_items (String.length target_file + 2) deps