Skip to contentSkip to conversation

compat: add a basename() compatibility function

PATCH [email protected] 1 participant 1 message Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

On Sun 31/05/09 06:42 , David Aguilar [email protected] sent:

Quoted 25 lines · David Aguilar
Quoted 11 lines

Some systems such as Windows lack libgen.h so provide a basename() implementation for cross-platform use. [...]

compat/basename.c new file +2 -0
new file mode 100644
index 0000000..c45716a
@@ -0,0 +1,19 @@
+#include "../git-compat-util.h"
+

compat/basename.c line 12

Quoted 10 lines
compat/basename.c new file +10 -0
+/* 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.. ;)

Quoted 2 lines

Can someone with better win32 knowledge let me know if the USE_WIN32_FS stuff is needed for msysgit?

No, you don't need it: use

	if (has_dos_drive_prefix(path))
		path += 2;

without any #ifdef.

Thank _you_ for going through so many iterations.

Unfortunately, it may take me a day or two until I can test the patches on Windows again.

-- Hannes