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:
Johannes Sixt
2007-12-08 20:51:36 +01:00
parent bd8d78a159
commit 4a8d948eac

10
setup.c
View File

@@ -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;
}