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

RE: [PATCH] On Cygwin support both UNIX and DOS style path-names

From
Theo Niessink <theo@taletn.com>
Date
Jul 28, 2011, 10:44 UTC
Message-ID
<214795D425BD400EB32D9D140BB8C1F6@martinic.local>
In-Reply-To
<4E312BD6.6020901@obry.net>
Pascal Obry wrote:
> Thanks for the review/feedback. Will work on that and propose another
> patch.
Perhaps something like this on top of (or before) your patch?
-- >8 --
Subject: [PATCH] git-compat-util: add generic find_last_dir_sep that respects
 is_dir_sep

Move MinGW's find_last_dir_sep to git-compat-util.h, so it can also be used on other platforms that define is_dir_sep, e.g. Cygwin.

Signed-off-by: Theo Niessink <theo@taletn.com>
---
 compat/mingw.h    |    9 ---------
 git-compat-util.h |   12 ++++++++++++
 2 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/compat/mingw.h b/compat/mingw.h
index ce9dd98..547568b 100644
--- a/compat/mingw.h
+++ b/compat/mingw.h
@@ -300,15 +300,6 @@ int winansi_fprintf(FILE *stream, const char *format, ...) __attribute__((format
 
 #define has_dos_drive_prefix(path) (isalpha(*(path)) && (path)[1] == ':')
 #define is_dir_sep(c) ((c) == '/' || (c) == '\\')
-static inline char *mingw_find_last_dir_sep(const char *path)
-{
-	char *ret = NULL;
-	for (; *path; ++path)
-		if (is_dir_sep(*path))
-			ret = (char *)path;
-	return ret;
-}
-#define find_last_dir_sep mingw_find_last_dir_sep
 #define PATH_SEP ';'
 #define PRIuMAX "I64u"
 
diff --git a/git-compat-util.h b/git-compat-util.h
index ddfbf77..c2c94cd 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -211,6 +211,18 @@ extern char *gitbasename(char *);
 #define has_dos_drive_prefix(path) 0
 #endif
 
+#if !defined(find_last_dir_sep) && defined(is_dir_sep)
+static inline char *compat_find_last_dir_sep(const char *path)
+{
+	char *ret = NULL;
+	for (; *path; ++path)
+		if (is_dir_sep(*path))
+			ret = (char *)path;
+	return ret;
+}
+#define find_last_dir_sep compat_find_last_dir_sep
+#endif
+
 #ifndef is_dir_sep
 #define is_dir_sep(c) ((c) == '/')
 #endif
-- 
1.7.6.msysgit.0
Previous: Pascal Obry
Message 3 of 3 in “Re: [PATCH] On Cygwin support both UNIX and DOS style path-names”
  1. Theo NiessinkJul 27, 2011
  2. Pascal ObryJul 28, 2011
  3. Theo NiessinkJul 28, 2011

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.