mirror of
https://github.com/git/git.git
synced 2026-03-15 03:00:07 +01:00
Define is_dir_sep conditionally in compat/mingw.h and git-compat-util.h.
By doing it there we can reduce yet another bunch of conditionals from setup.c. Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
This commit is contained in:
@@ -193,6 +193,7 @@ sig_handler_t mingw_signal(int sig, sig_handler_t handler);
|
||||
*/
|
||||
|
||||
#define has_dos_drive_prefix(path) (isalpha(*(path)) && (path)[1] == ':')
|
||||
#define is_dir_sep(c) ((c) == '/' || (c) == '\\')
|
||||
#define PATH_SEP ';'
|
||||
#define PRIuMAX "I64u"
|
||||
|
||||
|
||||
@@ -117,6 +117,10 @@
|
||||
#define has_dos_drive_prefix(path) 0
|
||||
#endif
|
||||
|
||||
#ifndef is_dir_sep
|
||||
#define is_dir_sep(c) ((c) == '/')
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define NORETURN __attribute__((__noreturn__))
|
||||
#else
|
||||
|
||||
33
setup.c
33
setup.c
@@ -4,23 +4,16 @@
|
||||
static int inside_git_dir = -1;
|
||||
static int inside_work_tree = -1;
|
||||
|
||||
#ifdef __MINGW32__
|
||||
static inline int is_dir_sep(char c) { return c == '/' || c == '\\'; }
|
||||
#else
|
||||
static inline int is_dir_sep(char c) { return c == '/'; }
|
||||
#endif
|
||||
|
||||
static int sanitary_path_copy(char *dst, const char *src)
|
||||
{
|
||||
char *dst0 = dst;
|
||||
char *dst0;
|
||||
|
||||
#ifdef __MINGW32__
|
||||
if (isalpha(*src) && src[1] == ':') {
|
||||
if (has_dos_drive_prefix(src)) {
|
||||
*dst++ = *src++;
|
||||
*dst++ = *src++;
|
||||
dst0 = dst;
|
||||
}
|
||||
#endif
|
||||
dst0 = dst;
|
||||
|
||||
if (is_dir_sep(*src)) {
|
||||
*dst++ = '/';
|
||||
while (is_dir_sep(*src))
|
||||
@@ -39,30 +32,22 @@ static int sanitary_path_copy(char *dst, const char *src)
|
||||
* (4) "../" -- strip one, eat slash and continue.
|
||||
*/
|
||||
if (c == '.') {
|
||||
switch (src[1]) {
|
||||
case '\0':
|
||||
if (!src[1]) {
|
||||
/* (1) */
|
||||
src++;
|
||||
break;
|
||||
case '/':
|
||||
#ifdef __MINGW32__
|
||||
case '\\':
|
||||
#endif
|
||||
} else if (is_dir_sep(src[1])) {
|
||||
/* (2) */
|
||||
src += 2;
|
||||
while (is_dir_sep(*src))
|
||||
src++;
|
||||
continue;
|
||||
case '.':
|
||||
switch (src[2]) {
|
||||
case '\0':
|
||||
} else if (src[1] == '.') {
|
||||
if (!src[2]) {
|
||||
/* (3) */
|
||||
src += 2;
|
||||
goto up_one;
|
||||
case '/':
|
||||
#ifdef __MINGW32__
|
||||
case '\\':
|
||||
#endif
|
||||
} else if (is_dir_sep(src[2])) {
|
||||
/* (4) */
|
||||
src += 3;
|
||||
while (is_dir_sep(*src))
|
||||
|
||||
Reference in New Issue
Block a user