提交 1fd7ef2e 编写于 作者: J Junio C Hamano

Merge branch 'js/i18n-windows'

* js/i18n-windows:
  Windows: teach getenv to do a case-sensitive search
  mingw.c: move definition of mingw_getenv down
  sh-i18n--envsubst: do not crash when no arguments are given
...@@ -178,7 +178,7 @@ static int ask_yes_no_if_possible(const char *format, ...) ...@@ -178,7 +178,7 @@ static int ask_yes_no_if_possible(const char *format, ...)
vsnprintf(question, sizeof(question), format, args); vsnprintf(question, sizeof(question), format, args);
va_end(args); va_end(args);
if ((retry_hook[0] = getenv("GIT_ASK_YESNO"))) { if ((retry_hook[0] = mingw_getenv("GIT_ASK_YESNO"))) {
retry_hook[1] = question; retry_hook[1] = question;
return !run_command_v_opt(retry_hook, 0); return !run_command_v_opt(retry_hook, 0);
} }
...@@ -599,19 +599,6 @@ char *mingw_getcwd(char *pointer, int len) ...@@ -599,19 +599,6 @@ char *mingw_getcwd(char *pointer, int len)
return ret; return ret;
} }
#undef getenv
char *mingw_getenv(const char *name)
{
char *result = getenv(name);
if (!result && !strcmp(name, "TMPDIR")) {
/* on Windows it is TMP and TEMP */
result = getenv("TMP");
if (!result)
result = getenv("TEMP");
}
return result;
}
/* /*
* See http://msdn2.microsoft.com/en-us/library/17w5ykft(vs.71).aspx * See http://msdn2.microsoft.com/en-us/library/17w5ykft(vs.71).aspx
* (Parsing C++ Command-Line Arguments) * (Parsing C++ Command-Line Arguments)
...@@ -711,7 +698,7 @@ static const char *parse_interpreter(const char *cmd) ...@@ -711,7 +698,7 @@ static const char *parse_interpreter(const char *cmd)
*/ */
static char **get_path_split(void) static char **get_path_split(void)
{ {
char *p, **path, *envpath = getenv("PATH"); char *p, **path, *envpath = mingw_getenv("PATH");
int i, n = 0; int i, n = 0;
if (!envpath || !*envpath) if (!envpath || !*envpath)
...@@ -1128,6 +1115,36 @@ char **make_augmented_environ(const char *const *vars) ...@@ -1128,6 +1115,36 @@ char **make_augmented_environ(const char *const *vars)
return env; return env;
} }
#undef getenv
/*
* The system's getenv looks up the name in a case-insensitive manner.
* This version tries a case-sensitive lookup and falls back to
* case-insensitive if nothing was found. This is necessary because,
* as a prominent example, CMD sets 'Path', but not 'PATH'.
* Warning: not thread-safe.
*/
static char *getenv_cs(const char *name)
{
size_t len = strlen(name);
int i = lookup_env(environ, name, len);
if (i >= 0)
return environ[i] + len + 1; /* skip past name and '=' */
return getenv(name);
}
char *mingw_getenv(const char *name)
{
char *result = getenv_cs(name);
if (!result && !strcmp(name, "TMPDIR")) {
/* on Windows it is TMP and TEMP */
result = getenv_cs("TMP");
if (!result)
result = getenv_cs("TEMP");
}
return result;
}
/* /*
* Note, this isn't a complete replacement for getaddrinfo. It assumes * Note, this isn't a complete replacement for getaddrinfo. It assumes
* that service contains a numerical port, or that it is null. It * that service contains a numerical port, or that it is null. It
......
...@@ -73,6 +73,7 @@ main (int argc, char *argv[]) ...@@ -73,6 +73,7 @@ main (int argc, char *argv[])
{ {
case 1: case 1:
error ("we won't substitute all variables on stdin for you"); error ("we won't substitute all variables on stdin for you");
break;
/* /*
all_variables = 1; all_variables = 1;
subst_from_stdin (); subst_from_stdin ();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册