summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2016-04-29 14:16:01 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2016-04-29 14:16:01 -0700
commit0c1a8ec8da53c3d5c7ce1fae8599f18bce6a4b2d (patch)
tree0a563a660ba00490501c7bf4f3895ffb9d2cd0b2
parentMerge branch 'ep/trace-doc-sample-fix' into maint (diff)
parentWindows: shorten code by re-using convert_slashes() (diff)
downloadtgif-0c1a8ec8da53c3d5c7ce1fae8599f18bce6a4b2d.tar.xz
Merge branch 'js/mingw-tests-2.8' into maint
Code clean-up. * js/mingw-tests-2.8: Windows: shorten code by re-using convert_slashes()
-rw-r--r--abspath.c5
-rw-r--r--compat/mingw.c9
2 files changed, 3 insertions, 11 deletions
diff --git a/abspath.c b/abspath.c
index 5edb4e7816..2825de8591 100644
--- a/abspath.c
+++ b/abspath.c
@@ -167,7 +167,6 @@ const char *prefix_filename(const char *pfx, int pfx_len, const char *arg)
strbuf_add(&path, pfx, pfx_len);
strbuf_addstr(&path, arg);
#else
- char *p;
/* don't add prefix to absolute paths, but still replace '\' by '/' */
strbuf_reset(&path);
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)
strbuf_add(&path, pfx, pfx_len);
strbuf_addstr(&path, arg);
- for (p = path.buf + pfx_len; *p; p++)
- if (*p == '\\')
- *p = '/';
+ convert_slashes(path.buf + pfx_len);
#endif
return path.buf;
}
diff --git a/compat/mingw.c b/compat/mingw.c
index 54c82ecf20..0413d5c3cd 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -763,15 +763,12 @@ struct tm *localtime_r(const time_t *timep, struct tm *result)
char *mingw_getcwd(char *pointer, int len)
{
- int i;
wchar_t wpointer[MAX_PATH];
if (!_wgetcwd(wpointer, ARRAY_SIZE(wpointer)))
return NULL;
if (xwcstoutf(pointer, wpointer, len) < 0)
return NULL;
- for (i = 0; pointer[i]; i++)
- if (pointer[i] == '\\')
- pointer[i] = '/';
+ convert_slashes(pointer);
return pointer;
}
@@ -2112,9 +2109,7 @@ static void setup_windows_environment()
* executable (by not mistaking the dir separators
* for escape characters).
*/
- for (; *tmp; tmp++)
- if (*tmp == '\\')
- *tmp = '/';
+ convert_slashes(tmp);
}
/* simulate TERM to enable auto-color (see color.c) */