compat: add a basename() compatibility function
Some systems such as Windows lack libgen.h so provide a basename() implementation for cross-platform use. This introduces the NO_LIBGEN_H construct to the Makefile and autoconf scripts. Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
0620b39b3b
commit
e1c0688692
15
compat/basename.c
Normal file
15
compat/basename.c
Normal file
@ -0,0 +1,15 @@
|
||||
#include "../git-compat-util.h"
|
||||
|
||||
/* Adapted from libiberty's basename.c. */
|
||||
char *gitbasename (char *path)
|
||||
{
|
||||
const char *base;
|
||||
/* Skip over the disk name in MSDOS pathnames. */
|
||||
if (has_dos_drive_prefix(path))
|
||||
path += 2;
|
||||
for (base = path; *path; path++) {
|
||||
if (is_dir_sep(*path))
|
||||
base = path + 1;
|
||||
}
|
||||
return (char *)base;
|
||||
}
|
||||
Reference in New Issue
Block a user