summaryrefslogtreecommitdiff
path: root/git-compat-util.h
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2014-08-16 23:48:33 +0200
committerJunio C Hamano <gitster@pobox.com>2014-08-18 09:45:39 -0700
commitbf7283465b42e43b8822a8575abd1a7c6c82e7c9 (patch)
tree8902206a26d80f529a7f1ece7b7f49565be302b6 /git-compat-util.h
parentc2369bdf7ff082d588c4a4efe280bc4a483d0192 (diff)
downloadgit-bf7283465b42e43b8822a8575abd1a7c6c82e7c9.tar.gz
turn path macros into inline functionrs/inline-compat-path-macros
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>
Diffstat (limited to 'git-compat-util.h')
-rw-r--r--git-compat-util.h28
1 files changed, 22 insertions, 6 deletions
diff --git a/git-compat-util.h b/git-compat-util.h
index ec41cfb23c..73a0f3e139 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -267,19 +267,35 @@ extern char *gitbasename(char *);
#endif
#ifndef has_dos_drive_prefix
-#define has_dos_drive_prefix(path) 0
+static inline int git_has_dos_drive_prefix(const char *path)
+{
+ return 0;
+}
+#define has_dos_drive_prefix git_has_dos_drive_prefix
#endif
-#ifndef offset_1st_component
-#define offset_1st_component(path) (is_dir_sep((path)[0]))
+#ifndef is_dir_sep
+static inline int git_is_dir_sep(int c)
+{
+ return c == '/';
+}
+#define is_dir_sep git_is_dir_sep
#endif
-#ifndef is_dir_sep
-#define is_dir_sep(c) ((c) == '/')
+#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
#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
#if defined(__HP_cc) && (__HP_cc >= 61000)