Windows: shorten code by re-using convert_slashes()
Make a few more spots more readable by using the recently introduced, Windows-specific helper. Signed-off-by: Johannes Sixt <j6t@kdbg.org> Acked-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>maint
parent
8257d3b458
commit
8e9b20804a
|
@ -167,7 +167,6 @@ const char *prefix_filename(const char *pfx, int pfx_len, const char *arg)
|
||||||
strbuf_add(&path, pfx, pfx_len);
|
strbuf_add(&path, pfx, pfx_len);
|
||||||
strbuf_addstr(&path, arg);
|
strbuf_addstr(&path, arg);
|
||||||
#else
|
#else
|
||||||
char *p;
|
|
||||||
/* don't add prefix to absolute paths, but still replace '\' by '/' */
|
/* don't add prefix to absolute paths, but still replace '\' by '/' */
|
||||||
strbuf_reset(&path);
|
strbuf_reset(&path);
|
||||||
if (is_absolute_path(arg))
|
if (is_absolute_path(arg))
|
||||||
|
@ -175,9 +174,7 @@ const char *prefix_filename(const char *pfx, int pfx_len, const char *arg)
|
||||||
else if (pfx_len)
|
else if (pfx_len)
|
||||||
strbuf_add(&path, pfx, pfx_len);
|
strbuf_add(&path, pfx, pfx_len);
|
||||||
strbuf_addstr(&path, arg);
|
strbuf_addstr(&path, arg);
|
||||||
for (p = path.buf + pfx_len; *p; p++)
|
convert_slashes(path.buf + pfx_len);
|
||||||
if (*p == '\\')
|
|
||||||
*p = '/';
|
|
||||||
#endif
|
#endif
|
||||||
return path.buf;
|
return path.buf;
|
||||||
}
|
}
|
||||||
|
|
|
@ -763,15 +763,12 @@ struct tm *localtime_r(const time_t *timep, struct tm *result)
|
||||||
|
|
||||||
char *mingw_getcwd(char *pointer, int len)
|
char *mingw_getcwd(char *pointer, int len)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
wchar_t wpointer[MAX_PATH];
|
wchar_t wpointer[MAX_PATH];
|
||||||
if (!_wgetcwd(wpointer, ARRAY_SIZE(wpointer)))
|
if (!_wgetcwd(wpointer, ARRAY_SIZE(wpointer)))
|
||||||
return NULL;
|
return NULL;
|
||||||
if (xwcstoutf(pointer, wpointer, len) < 0)
|
if (xwcstoutf(pointer, wpointer, len) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
for (i = 0; pointer[i]; i++)
|
convert_slashes(pointer);
|
||||||
if (pointer[i] == '\\')
|
|
||||||
pointer[i] = '/';
|
|
||||||
return pointer;
|
return pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2112,9 +2109,7 @@ static void setup_windows_environment()
|
||||||
* executable (by not mistaking the dir separators
|
* executable (by not mistaking the dir separators
|
||||||
* for escape characters).
|
* for escape characters).
|
||||||
*/
|
*/
|
||||||
for (; *tmp; tmp++)
|
convert_slashes(tmp);
|
||||||
if (*tmp == '\\')
|
|
||||||
*tmp = '/';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* simulate TERM to enable auto-color (see color.c) */
|
/* simulate TERM to enable auto-color (see color.c) */
|
||||||
|
|
Loading…
Reference in New Issue