From 70aa4faf57b62c52e61bc9cd866dd3392bd4db93 Mon Sep 17 00:00:00 2001 From: Johannes Sixt Date: Thu, 13 Mar 2008 13:06:20 +0100 Subject: [PATCH] Define PATH_SEP to ':' or ';' as needed. This reduces the number of conditionals in the code. Signed-off-by: Johannes Sixt --- compat/mingw.h | 1 + exec_cmd.c | 6 +----- git-compat-util.h | 4 ++++ help.c | 7 +------ sha1_file.c | 6 +----- 5 files changed, 8 insertions(+), 16 deletions(-) diff --git a/compat/mingw.h b/compat/mingw.h index 64e0ac79e3..93ef42b9cf 100644 --- a/compat/mingw.h +++ b/compat/mingw.h @@ -192,6 +192,7 @@ sig_handler_t mingw_signal(int sig, sig_handler_t handler); * git specific compatibility */ +#define PATH_SEP ';' #define PRIuMAX "I64u" /* diff --git a/exec_cmd.c b/exec_cmd.c index 6d2f740949..84db7ee664 100644 --- a/exec_cmd.c +++ b/exec_cmd.c @@ -70,11 +70,7 @@ static void add_path(struct strbuf *out, const char *path) else strbuf_addstr(out, make_absolute_path(path)); -#ifdef __MINGW32__ - strbuf_addch(out, ';'); -#else - strbuf_addch(out, ':'); -#endif + strbuf_addch(out, PATH_SEP); } } diff --git a/git-compat-util.h b/git-compat-util.h index aac06bfefe..4144605725 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -109,6 +109,10 @@ #define PRIuMAX "llu" #endif +#ifndef PATH_SEP +#define PATH_SEP ':' +#endif + #ifdef __GNUC__ #define NORETURN __attribute__((__noreturn__)) #else diff --git a/help.c b/help.c index 8d83df5466..04ceed8efd 100644 --- a/help.c +++ b/help.c @@ -240,11 +240,6 @@ static unsigned int load_command_list(void) const char *env_path = getenv("PATH"); char *paths, *path, *colon; const char *exec_path = git_exec_path(); -#ifdef __MINGW32__ - char sep = ';'; -#else - char sep = ':'; -#endif if (exec_path) longest = list_commands_in_dir(&main_cmds, exec_path); @@ -256,7 +251,7 @@ static unsigned int load_command_list(void) path = paths = xstrdup(env_path); while (1) { - if ((colon = strchr(path, sep))) + if ((colon = strchr(path, PATH_SEP))) *colon = 0; len = list_commands_in_dir(&other_cmds, path); diff --git a/sha1_file.c b/sha1_file.c index 2192407494..45231593c7 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -394,11 +394,7 @@ void prepare_alt_odb(void) if (!alt) alt = ""; alt_odb_tail = &alt_odb_list; -#ifdef __MINGW32__ - link_alt_odb_entries(alt, alt + strlen(alt), ';', NULL, 0); -#else - link_alt_odb_entries(alt, alt + strlen(alt), ':', NULL, 0); -#endif + link_alt_odb_entries(alt, alt + strlen(alt), PATH_SEP, NULL, 0); read_info_alternates(get_object_directory(), 0); } -- 2.11.4.GIT