summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2013-06-22 16:16:56 +0300
committerEli Zaretskii <eliz@gnu.org>2013-06-22 16:16:56 +0300
commitab1f791983e24c5116738a50c45d9a06b0f7aae0 (patch)
tree9b6704597ca3d61b04cae5e36d4f0e9c0182ba13
parente952841ff3506bf69e61202e5870c24b4b0992d4 (diff)
downloadmake-ab1f791983e24c5116738a50c45d9a06b0f7aae0.tar.gz
Fix a fatal error at startup on Windows due to non-ASCII characters in PATH.
main.c (find_and_set_default_shell): Don't use file_exists_p or dir_file_exists_p, as those call readdir, which can fail if PATH includes directories with non-ASCII characters, and that would cause Make to fail at startup with confusing diagnostics. See https://sourceforge.net/mailarchive/message.php?msg_id=30846737 for the details.
-rw-r--r--ChangeLog9
-rw-r--r--main.c21
2 files changed, 21 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index fe7cd99f..c01a3233 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2013-06-22 Eli Zaretskii <eliz@gnu.org>
+
+ * main.c (find_and_set_default_shell): Don't use file_exists_p or
+ dir_file_exists_p, as those call readdir, which can fail if PATH
+ includes directories with non-ASCII characters, and that would
+ cause Make to fail at startup with confusing diagnostics. See
+ https://sourceforge.net/mailarchive/message.php?msg_id=30846737
+ for the details.
+
2013-06-22 Paul Smith <psmith@gnu.org>
Improve performance by using a character map to determine where we
diff --git a/main.c b/main.c
index 147f77d7..fe8d3559 100644
--- a/main.c
+++ b/main.c
@@ -956,7 +956,7 @@ find_and_set_default_shell (const char *token)
/* no new information, path already set or known */
sh_found = 1;
}
- else if (file_exists_p (search_token))
+ else if (_access (search_token, 0) == 0)
{
/* search token path was found */
sprintf (sh_path, "%s", search_token);
@@ -982,9 +982,9 @@ find_and_set_default_shell (const char *token)
{
*ep = '\0';
- if (dir_file_exists_p (p, search_token))
+ sprintf (sh_path, "%s/%s", p, search_token);
+ if (_access (sh_path, 0) == 0)
{
- sprintf (sh_path, "%s/%s", p, search_token);
default_shell = xstrdup (w32ify (sh_path, 0));
sh_found = 1;
*ep = PATH_SEPARATOR_CHAR;
@@ -1002,12 +1002,15 @@ find_and_set_default_shell (const char *token)
}
/* be sure to check last element of Path */
- if (p && *p && dir_file_exists_p (p, search_token))
- {
- sprintf (sh_path, "%s/%s", p, search_token);
- default_shell = xstrdup (w32ify (sh_path, 0));
- sh_found = 1;
- }
+ if (p && *p)
+ {
+ sprintf (sh_path, "%s/%s", p, search_token);
+ if (_access (sh_path, 0) == 0)
+ {
+ default_shell = xstrdup (w32ify (sh_path, 0));
+ sh_found = 1;
+ }
+ }
if (sh_found)
DB (DB_VERBOSE,