From 904cbe5ce8d5c1d9d68e6c2697709a5abd036f3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Ojeda=20B=C3=A4r?= Date: Fri, 18 Jun 2021 13:04:57 +0200 Subject: [PATCH] Path.Local: backslashes are not canonical on Windows (#4745) --- CHANGES.md | 3 +++ otherlibs/stdune-unstable/path.ml | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 800eafd6adf..7b684089584 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -166,6 +166,9 @@ Unreleased - Handle renaming of `coq.kernel` library to `coq-core.kernel` in Coq 8.14 (#4713, @proux01) +- Fix generation of merlin configuration when using `(include_subdirs + unqualified)` on Windows (#4745, @nojb) + 2.8.5 (28/03/2021) ------------------ diff --git a/otherlibs/stdune-unstable/path.ml b/otherlibs/stdune-unstable/path.ml index 735fa941aa2..ae4761b0b47 100644 --- a/otherlibs/stdune-unstable/path.ml +++ b/otherlibs/stdune-unstable/path.ml @@ -302,6 +302,10 @@ end = struct User_error.raise ?loc:error_loc [ Pp.textf "path outside the workspace: %s from %s" path (to_string t) ] + (* Check whether a path is in canonical form: no '.' or '..' components, no + repeated '/' components, no backslashes '\\' (on Windows only), and not + ending in a slash '/'. *) + let is_canonicalized = let rec before_slash s i = if i < 0 then @@ -310,6 +314,7 @@ end = struct match s.[i] with | '/' -> false | '.' -> before_dot_slash s (i - 1) + | '\\' when Sys.win32 -> false | _ -> in_component s (i - 1) and before_dot_slash s i = if i < 0 then @@ -318,6 +323,7 @@ end = struct match s.[i] with | '/' -> false | '.' -> before_dot_dot_slash s (i - 1) + | '\\' when Sys.win32 -> false | _ -> in_component s (i - 1) and before_dot_dot_slash s i = if i < 0 then @@ -325,6 +331,7 @@ end = struct else match s.[i] with | '/' -> false + | '\\' when Sys.win32 -> false | _ -> in_component s (i - 1) and in_component s i = if i < 0 then @@ -332,6 +339,7 @@ end = struct else match s.[i] with | '/' -> before_slash s (i - 1) + | '\\' when Sys.win32 -> false | _ -> in_component s (i - 1) in fun s ->