From a91b91b1ae298c128f61daed7e1590526237f005 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 27 Aug 2013 20:16:56 -0700 Subject: [PATCH] Fix parsing PATH on windows Thanks to @vadimcn for the patch! --- src/win/process.c | 51 ++++++++++++++++++++++------------------------- 1 file changed, 24 insertions(+), 27 deletions(-) diff --git a/src/win/process.c b/src/win/process.c index 88a141950d..dfc855cd06 100644 --- a/src/win/process.c +++ b/src/win/process.c @@ -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; @@ -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++; } }