Skip to content

Commit 73353e0

Browse files
committed
Merge branch 'rs/inline-compat-path-macros'
* rs/inline-compat-path-macros: turn path macros into inline function
2 parents 8015a60 + bf72834 commit 73353e0

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

git-compat-util.h

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -264,19 +264,35 @@ extern char *gitbasename(char *);
264264
#endif
265265

266266
#ifndef has_dos_drive_prefix
267-
#define has_dos_drive_prefix(path) 0
267+
static inline int git_has_dos_drive_prefix(const char *path)
268+
{
269+
return 0;
270+
}
271+
#define has_dos_drive_prefix git_has_dos_drive_prefix
268272
#endif
269273

270-
#ifndef offset_1st_component
271-
#define offset_1st_component(path) (is_dir_sep((path)[0]))
274+
#ifndef is_dir_sep
275+
static inline int git_is_dir_sep(int c)
276+
{
277+
return c == '/';
278+
}
279+
#define is_dir_sep git_is_dir_sep
272280
#endif
273281

274-
#ifndef is_dir_sep
275-
#define is_dir_sep(c) ((c) == '/')
282+
#ifndef offset_1st_component
283+
static inline int git_offset_1st_component(const char *path)
284+
{
285+
return is_dir_sep(path[0]);
286+
}
287+
#define offset_1st_component git_offset_1st_component
276288
#endif
277289

278290
#ifndef find_last_dir_sep
279-
#define find_last_dir_sep(path) strrchr(path, '/')
291+
static inline char *git_find_last_dir_sep(const char *path)
292+
{
293+
return strrchr(path, '/');
294+
}
295+
#define find_last_dir_sep git_find_last_dir_sep
280296
#endif
281297

282298
#if defined(__HP_cc) && (__HP_cc >= 61000)

0 commit comments

Comments
 (0)