Conversation
|
Thank you! |
|
Anyone to review this ? Perhaps @nojb ? |
|
I will take a look. |
nojb
left a comment
There was a problem hiding this comment.
LGTM.
I wonder if we should document in the doc for check_suffix and chop_suffix_opt that under Windows we compare the extension modulo ASCII-case folding (which may not match the underlying OS behaviour in the case of non-ASCII characters, see https://blogs.msdn.microsoft.com/greggm/2005/09/21/comparing-file-names-in-native-code/).
Also, don't forget to update Changes with GPR number.
|
Thanks, all comments addressed. Btw, do you know why we don't use (pseudo)-case insensitive comparison under MacOS as well? |
No idea. |
|
MacOS supports both case-sensitive and case-insensitive file systems. And I wouldn't be surprised if Windows did too... |
|
Windows supports case-sensitive and case-insensitive directories: https://blogs.msdn.microsoft.com/commandline/2018/02/28/per-directory-case-sensitivity-and-wsl/ |
This supersedes #1858 and somehow addresses parts of MPR#7812. cc @whitequark
A new function is added:
The goal is to deprecate
Filename.chop_suffixeventually. That function is dangerous: it only removes the final characters from the filename, without actually checking the suffix matches; and it raises only when the filename is "too short", which is rare enough to have the bugs fly under the radar for a long time.Following the "modern" style in the stdlib, the new function returns an option instead of raising an exception in case of mismatch. This could avoid bugs such as MPR#1858.
The function uses a labelled argument to avoid the possible confusion between the two arguments.
check_suffix/chop_suffixare rare cases where I always need to look up the documentation to know the ordering of arguments.This PR does not rewrite the uses of chop_suffix in the core distribution to use the new function. This can be done as a follow-up PR.
Also, this PR does not mark
Filename.chop_suffixas being deprecated; in the latest caml-devel meeting, it was mentioned that having one full major version of OCaml with the new functions before deprecating the "old" ones is considered to be the polite behavior towards the community.