File tree Expand file tree Collapse file tree 1 file changed +18
-5
lines changed Expand file tree Collapse file tree 1 file changed +18
-5
lines changed Original file line number Diff line number Diff line change @@ -24,13 +24,26 @@ let is_simple_filename s =
2424 | 'a' ..'z' | 'A' ..'Z' | '0' ..'9' | '.' | '-' | '/' | '_' | ':' | '@' | '+' | ',' -> loop (pos + 1 )
2525 | _ -> false in
2626 loop 0
27+
28+ (* ** Copied from ocaml/stdlib/filename.ml *)
29+ let generic_quote quotequote s =
30+ let l = String. length s in
31+ let b = Buffer. create (l + 20 ) in
32+ Buffer. add_char b '\' ';
33+ for i = 0 to l - 1 do
34+ if s.[i] = '\' '
35+ then Buffer. add_string b quotequote
36+ else Buffer. add_char b s.[i]
37+ done ;
38+ Buffer. add_char b '\' ';
39+ Buffer. contents b
40+
41+ let unix_quote = generic_quote " '\\ ''"
42+
2743let quote_filename_if_needed s =
2844 if is_simple_filename s then s
29- (* We should probably be using [Filename.unix_quote] except that function
30- * isn't exported. Users on Windows will have to live with not being able to
31- * install OCaml into c:\o'caml. Too bad. *)
32- else if Sys. win32 then Printf. sprintf " '%s'" s
33- else Filename. quote s
45+ else unix_quote s
46+
3447let chdir dir =
3548 reset_filesys_cache () ;
3649 Sys. chdir dir
You can’t perform that action at this time.
0 commit comments