mirror of
https://github.com/git/git.git
synced 2026-03-13 10:23:30 +01:00
Fix prefix_filename() function.
The previous implementation translated '\' to '/' on non-Windows, too (in those cases where the prefix was actually prepended to the path). Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
This commit is contained in:
10
setup.c
10
setup.c
@@ -82,21 +82,23 @@ const char *prefix_path(const char *prefix, int len, const char *path)
|
||||
const char *prefix_filename(const char *pfx, int pfx_len, const char *arg)
|
||||
{
|
||||
static char path[PATH_MAX];
|
||||
char *p;
|
||||
#ifndef __MINGW32__
|
||||
if (!pfx || !*pfx || is_absolute_path(arg))
|
||||
return arg;
|
||||
memcpy(path, pfx, pfx_len);
|
||||
strcpy(path + pfx_len, arg);
|
||||
#else
|
||||
/* don't add prefix to absolute paths */
|
||||
char *p;
|
||||
/* don't add prefix to absolute paths, but still replace '\' by '/' */
|
||||
if (is_absolute_path(arg))
|
||||
pfx_len = 0;
|
||||
else
|
||||
#endif
|
||||
memcpy(path, pfx, pfx_len);
|
||||
memcpy(path, pfx, pfx_len);
|
||||
strcpy(path + pfx_len, arg);
|
||||
for (p = path + pfx_len; *p; p++)
|
||||
if (*p == '\\')
|
||||
*p = '/';
|
||||
#endif
|
||||
return path;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user