Skip to content
This repository has been archived by the owner on Nov 21, 2018. It is now read-only.

Commit

Permalink
Fix parsing PATH on windows
Browse files Browse the repository at this point in the history
Thanks to @vadimcn for the patch!
  • Loading branch information
alexcrichton committed Feb 16, 2014
1 parent 6f62d62 commit a91b91b
Showing 1 changed file with 24 additions and 27 deletions.
51 changes: 24 additions & 27 deletions src/win/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -373,15 +373,6 @@ static WCHAR* search_path(const WCHAR *file,
name_has_ext);

while (result == NULL) {
if (*dir_end == L'\0') {
break;
}

/* Skip the separator that dir_end now points to */
if (dir_end != path) {
dir_end++;
}

/* Next slice starts just after where the previous one ended */
dir_start = dir_end;

Expand All @@ -392,27 +383,33 @@ static WCHAR* search_path(const WCHAR *file,
}

/* If the slice is zero-length, don't bother */
if (dir_end - dir_start == 0) {
continue;
if (dir_end - dir_start > 0) {
dir_path = dir_start;
dir_len = dir_end - dir_start;

/* Adjust if the path is quoted. */
if (dir_path[0] == '"' || dir_path[0] == '\'') {
++dir_path;
--dir_len;
}

if (dir_path[dir_len - 1] == '"' || dir_path[dir_len - 1] == '\'') {
--dir_len;
}

result = path_search_walk_ext(dir_path, dir_len,
file, file_len,
cwd, cwd_len,
name_has_ext);
}

dir_path = dir_start;
dir_len = dir_end - dir_start;

/* Adjust if the path is quoted. */
if (dir_path[0] == '"' || dir_path[0] == '\'') {
++dir_path;
--dir_len;
}

if (dir_path[dir_len - 1] == '"' || dir_path[dir_len - 1] == '\'') {
--dir_len;
/* Stop if reached end of the line */
if (*dir_end == L'\0') {
break;
}

result = path_search_walk_ext(dir_path, dir_len,
file, file_len,
cwd, cwd_len,
name_has_ext);

/* Skip the separator that dir_end now points to */
dir_end++;
}
}

Expand Down

0 comments on commit a91b91b

Please sign in to comment.