From 4a8d948eaccda45f1afded4dc545e35207a0847f Mon Sep 17 00:00:00 2001 From: Johannes Sixt Date: Sat, 8 Dec 2007 20:51:36 +0100 Subject: [PATCH] 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 --- setup.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/setup.c b/setup.c index a89152d630..2cbe8733a5 100644 --- a/setup.c +++ b/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; }