From: Pascal Obry <pascal@obry.net>
To: git@vger.kernel.org
Cc: Theo Niessink <theo@taletn.com>
Subject: [PATCH 1/2] git-compat-util: add generic find_last_dir_sep that respects is_dir_sep
Date: Fri, 5 Aug 2011 18:10:13 +0200 [thread overview]
Message-ID: <1312560614-20772-2-git-send-email-pascal@obry.net> (raw)
In-Reply-To: <1312560614-20772-1-git-send-email-pascal@obry.net>
From: Theo Niessink <theo@taletn.com>
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>
Acked-by: Pascal Obry <pascal@obry.net>
---
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.404.g5d2fc
next prev parent reply other threads:[~2011-08-05 16:11 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-05 16:10 [PATH 0/2] On Cygwin support both UNIX and DOS style path-names Pascal Obry
2011-08-05 16:10 ` Pascal Obry [this message]
2011-08-05 16:10 ` [PATCH 2/2] " Pascal Obry
2011-08-05 17:29 ` Erik Faye-Lund
2011-08-05 17:35 ` Pascal Obry
2011-08-05 17:39 ` Erik Faye-Lund
2011-08-05 17:51 ` Erik Faye-Lund
2011-08-05 18:39 ` Pascal Obry
2011-08-09 17:30 ` Ramsay Jones
2011-08-09 17:26 ` Ramsay Jones
2011-08-05 17:48 ` Junio C Hamano
2011-08-05 17:58 ` Erik Faye-Lund
2011-08-06 7:01 ` Pascal Obry
2011-08-09 17:24 ` Ramsay Jones
2011-08-09 20:38 ` Pascal Obry
2011-08-11 20:35 ` Ramsay Jones
2011-08-13 17:34 ` Pascal Obry
2011-08-10 2:44 ` Vijay Lakshminarayanan
2011-08-09 19:47 ` Johannes Sixt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1312560614-20772-2-git-send-email-pascal@obry.net \
--to=pascal@obry.net \
--cc=git@vger.kernel.org \
--cc=theo@taletn.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.