Skip to content

Commit

Permalink
dir_inside_of(): handle directory separators correctly
Browse files Browse the repository at this point in the history
On Windows, both the forward slash and the backslash are directory
separators. Which means that `a\b\c` really is inside `a/b`. Therefore,
we need to special-case the directory separators in the helper function
`cmp_icase()` that is used in the loop in `dir_inside_of()`.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  • Loading branch information
dscho committed Aug 16, 2023
1 parent d3620e3 commit 50c9bbe
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -3142,6 +3142,8 @@ static int cmp_icase(char a, char b)
{
if (a == b)
return 0;
if (is_dir_sep(a))
return is_dir_sep(b) ? 0 : -1;
if (ignore_case)
return toupper(a) - toupper(b);
return a - b;
Expand Down

0 comments on commit 50c9bbe

Please sign in to comment.