Re: [PATCH v6 2/3] compat: add a basename() compatibility function
From: David Aguilar <hidden>
Date: 2016-06-15 22:46:53
On Sat, May 30, 2009 at 09:37:54PM -0700, David Aguilar wrote:
quoted hunk ↗ jump to hunk
Some systems such as Windows lack libgen.h so provide a basename() implementation for cross-platform use. [...]diff --git a/compat/basename.c b/compat/basename.c new file mode 100644 index 0000000..c45716a --- /dev/null +++ b/compat/basename.c@@ -0,0 +1,19 @@ +#include "../git-compat-util.h" + +/* Adapted from libiberty's basename.c. */ +char *gitbasename (char *path) +{ + const char *base; + +#ifdef USE_WIN32_FS + /* Skip over the disk name in MSDOS pathnames. */ + if (isalpha(path[0]) && path[1] == ':') + path += 2; +#endif
Thanks for bearing through this series everyone.. ;) Can someone with better win32 knowledge let me know if the USE_WIN32_FS stuff is needed for msysgit? I would really like it if there was a way to do without the #define.
+ for (base = path; *path; path++) {
+ if (is_dir_sep(*path)) {
+ base = path + 1;
+ }
+ }
+ return (char *)base;
+}-- David