git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v6 2/3] compat: add a basename() compatibility function

From
David Aguilar <davvid@gmail.com>
Date
May 31, 2009, 04:42 UTC
Message-ID
<20090531044246.GA23995@gmail.com>
In-Reply-To
<1243744675-24160-2-git-send-email-davvid@gmail.com>
On Sat, May 30, 2009 at 09:37:54PM -0700, David Aguilar wrote:
Show 21 quoted lines
> 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.

Show 7 quoted lines
> +	for (base = path; *path; path++) {
> +		if (is_dir_sep(*path)) {
> +			base = path + 1;
> +		}
> +	}
> +	return (char *)base;
> +}
-- 
		David
Previous: David AguilarNext: Junio C Hamano
Message 4 of 5 in “compat: add a mkstemps() compatibility function”
  1. 1/3 compat: add a mkstemps() compatibility functionDavid Aguilar, May 31, 2009
  2. 2/3 compat: add a basename() compatibility functionDavid Aguilar, May 31, 2009
  3. 3/3 diff: generate pretty filenames in prep_temp_blob()David Aguilar, May 31, 2009
  4. David AguilarMay 31, 2009
  5. Junio C HamanoMay 31, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.