From d1c69255a1014ccaeb9841f2114e20f048556391 Mon Sep 17 00:00:00 2001 From: Theo Niessink Date: Fri, 27 May 2011 18:00:39 +0200 Subject: real_path: do not assume '/' is the path seperator real_path currently assumes it's input had '/' as path seperator. This assumption does not hold true for the code-path from prefix_path (on Windows), where real_path can be called before normalize_path_copy. Fix real_path so it doesn't make this assumption. Create a helper function to reverse-search for the last path-seperator in a string. Signed-off-by: Theo Niessink Signed-off-by: Erik Faye-Lund Signed-off-by: Junio C Hamano --- compat/mingw.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'compat') diff --git a/compat/mingw.h b/compat/mingw.h index 14211c621..bea909d76 100644 --- a/compat/mingw.h +++ b/compat/mingw.h @@ -299,6 +299,15 @@ int winansi_fprintf(FILE *stream, const char *format, ...) __attribute__((format #define has_dos_drive_prefix(path) (isalpha(*(path)) && (path)[1] == ':') #define is_dir_sep(c) ((c) == '/' || (c) == '\\') +static inline char *mingw_find_last_dir_sep(const char *path) +{ + char *ret = NULL; + for (; *path; ++path) + if (is_dir_sep(*path)) + ret = (char *)path; + return ret; +} +#define find_last_dir_sep mingw_find_last_dir_sep #define PATH_SEP ';' #define PRIuMAX "I64u" -- cgit v1.2.1