summaryrefslogtreecommitdiff
path: root/otherlibs
diff options
context:
space:
mode:
authorGabriel Scherer <gabriel.scherer@gmail.com>2022-07-12 15:08:29 +0200
committerGitHub <noreply@github.com>2022-07-12 15:08:29 +0200
commit08b1a90d632599cb9fa8f06bf35386c891b71892 (patch)
treeeefee38a55ccca76a7c4bff12ed29962a5a67ad4 /otherlibs
parentef376dd4160f53970a21b6129cb83d460b97614b (diff)
parente0e523d1338900a662eb5d3e9a077644868c8de5 (diff)
downloadocaml-08b1a90d632599cb9fa8f06bf35386c891b71892.tar.gz
Merge pull request #11431 from hhugo/modern-string-api
Use modern string api
Diffstat (limited to 'otherlibs')
-rw-r--r--otherlibs/unix/unix_win32.ml17
1 files changed, 5 insertions, 12 deletions
diff --git a/otherlibs/unix/unix_win32.ml b/otherlibs/unix/unix_win32.ml
index e65b24b7ef..0396ac29e1 100644
--- a/otherlibs/unix/unix_win32.ml
+++ b/otherlibs/unix/unix_win32.ml
@@ -216,10 +216,8 @@ type wait_flag =
type file_descr
let maybe_quote f =
- if String.contains f ' ' ||
- String.contains f '\"' ||
- String.contains f '\t' ||
- f = ""
+ if f = ""
+ || String.exists (function ' ' | '\"'| '\t' -> true | _ -> false) f
then Filename.quote f
else f
@@ -369,8 +367,7 @@ external realpath : string -> string = "caml_unix_realpath"
let realpath p =
let cleanup p = (* Remove any \\?\ prefix. *)
- if String.length p <= 4 then p else
- if p.[0] = '\\' && p.[1] = '\\' && p.[2] = '?' && p.[3] = '\\'
+ if String.starts_with ~prefix:{|\\?\|} p
then (String.sub p 4 (String.length p - 4))
else p
in
@@ -516,12 +513,8 @@ external symlink_stub : bool -> string -> string -> unit = "caml_unix_symlink"
Windows call GetFullPathName to do this because we need relative paths to
stay relative. *)
let normalize_slashes path =
- if String.length path >= 4 && path.[0] = '\\' && path.[1] = '\\'
- && path.[2] = '?' && path.[3] = '\\' then
- path
- else
- String.init (String.length path)
- (fun i -> match path.[i] with '/' -> '\\' | c -> c)
+ if String.starts_with ~prefix:{|\\?\|} path then path
+ else String.map (function '/' -> '\\' | c -> c) path
let symlink ?to_dir source dest =
let to_dir =