Handle getenv("TMPDIR") in a getenv() wrapper.

This removes an #ifdef MINGW in path.c.

Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
This commit is contained in:
Johannes Sixt
2008-06-23 10:53:04 +02:00
parent 185fbb49c9
commit 3c965bf371
3 changed files with 16 additions and 7 deletions

View File

@@ -366,6 +366,19 @@ char *mingw_getcwd(char *pointer, int len)
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
* (Parsing C++ Command-Line Arguments)

View File

@@ -145,6 +145,9 @@ int mingw_open (const char *filename, int oflags, ...);
char *mingw_getcwd(char *pointer, int len);
#define getcwd mingw_getcwd
char *mingw_getenv(const char *name);
#define getenv mingw_getenv
struct hostent *mingw_gethostbyname(const char *host);
#define gethostbyname mingw_gethostbyname

7
path.c
View File

@@ -75,13 +75,6 @@ int git_mkstemp(char *path, size_t len, const char *template)
size_t n;
tmp = getenv("TMPDIR");
#ifdef __MINGW32__
/* on Windows it is TMP and TEMP */
if (!tmp)
tmp = getenv("TMP");
if (!tmp)
tmp = getenv("TEMP");
#endif
if (!tmp)
tmp = "/tmp";
n = snprintf(path, len, "%s/%s", tmp, template);