turn path macros into inline function
Use static inline functions instead of macros for has_dos_drive_prefix, offset_1st_component, is_dir_sep and find_last_dir_sep in order to let the compiler do type checking. The definitions of offset_1st_component and is_dir_sep are switched around because the former uses the latter. Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
c2369bdf7f
commit
bf7283465b
@ -267,19 +267,35 @@ extern char *gitbasename(char *);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef has_dos_drive_prefix
|
#ifndef has_dos_drive_prefix
|
||||||
#define has_dos_drive_prefix(path) 0
|
static inline int git_has_dos_drive_prefix(const char *path)
|
||||||
#endif
|
{
|
||||||
|
return 0;
|
||||||
#ifndef offset_1st_component
|
}
|
||||||
#define offset_1st_component(path) (is_dir_sep((path)[0]))
|
#define has_dos_drive_prefix git_has_dos_drive_prefix
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef is_dir_sep
|
#ifndef is_dir_sep
|
||||||
#define is_dir_sep(c) ((c) == '/')
|
static inline int git_is_dir_sep(int c)
|
||||||
|
{
|
||||||
|
return c == '/';
|
||||||
|
}
|
||||||
|
#define is_dir_sep git_is_dir_sep
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef offset_1st_component
|
||||||
|
static inline int git_offset_1st_component(const char *path)
|
||||||
|
{
|
||||||
|
return is_dir_sep(path[0]);
|
||||||
|
}
|
||||||
|
#define offset_1st_component git_offset_1st_component
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef find_last_dir_sep
|
#ifndef find_last_dir_sep
|
||||||
#define find_last_dir_sep(path) strrchr(path, '/')
|
static inline char *git_find_last_dir_sep(const char *path)
|
||||||
|
{
|
||||||
|
return strrchr(path, '/');
|
||||||
|
}
|
||||||
|
#define find_last_dir_sep git_find_last_dir_sep
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__HP_cc) && (__HP_cc >= 61000)
|
#if defined(__HP_cc) && (__HP_cc >= 61000)
|
||||||
|
Loading…
Reference in New Issue
Block a user