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>

Johannes Sixt committed Apr 2, 2016 at 21:03 UTC 8e9b20804a9900d4560e9ace4bb8c5d048a2097e
2 files changed +3 -11
abspath.c
+1 -4
@@ -167,7 +167,6 @@ const char *prefix_filename(const char *pfx, int pfx_len, const char *arg)
167 strbuf_add(&path, pfx, pfx_len);
168 strbuf_addstr(&path, arg);
169 #else
170 - char *p;
170 /* don't add prefix to absolute paths, but still replace '\' by '/' */
171 strbuf_reset(&path);
172 if (is_absolute_path(arg))
@@ -175,9 +174,7 @@ const char *prefix_filename(const char *pfx, int pfx_len, const char *arg)
174 else if (pfx_len)
175 strbuf_add(&path, pfx, pfx_len);
176 strbuf_addstr(&path, arg);
178 - for (p = path.buf + pfx_len; *p; p++)
179 - if (*p == '\\')
180 - *p = '/';
177 + convert_slashes(path.buf + pfx_len);
178 #endif
179 return path.buf;
180 }
compat/mingw.c
+2 -7
@@ -763,15 +763,12 @@ struct tm *localtime_r(const time_t *timep, struct tm *result)
763
764 char *mingw_getcwd(char *pointer, int len)
765 {
766 - int i;
766 wchar_t wpointer[MAX_PATH];
767 if (!_wgetcwd(wpointer, ARRAY_SIZE(wpointer)))
768 return NULL;
769 if (xwcstoutf(pointer, wpointer, len) < 0)
770 return NULL;
772 - for (i = 0; pointer[i]; i++)
773 - if (pointer[i] == '\\')
774 - pointer[i] = '/';
771 + convert_slashes(pointer);
772 return pointer;
773 }
774
@@ -2112,9 +2109,7 @@ static void setup_windows_environment()
2109 * executable (by not mistaking the dir separators
2110 * for escape characters).
2111 */
2115 - for (; *tmp; tmp++)
2116 - if (*tmp == '\\')
2117 - *tmp = '/';
2112 + convert_slashes(tmp);
2113 }
2114
2115 /* simulate TERM to enable auto-color (see color.c) */