From 16502c915ff3bc148c53eaae773eb0dbe895caa9 Mon Sep 17 00:00:00 2001 From: Johannes Sixt Date: Mon, 23 Jun 2008 10:59:12 +0200 Subject: [PATCH] Hand-roll the search for the program name to remove #ifdef MINGW. We now use is_dir_sep() to scan argv[0] for the program name. Signed-off-by: Johannes Sixt --- git.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/git.c b/git.c index 39db13a202..871b93ca7e 100644 --- a/git.c +++ b/git.c @@ -396,8 +396,8 @@ static void handle_internal_command(int argc, const char **argv) int main(int argc, const char **argv) { - const char *cmd = argv[0] ? argv[0] : "git-help"; - char *slash = strrchr(cmd, '/'); + const char *cmd = argv[0] && *argv[0] ? argv[0] : "git-help"; + char *slash = (char *)cmd + strlen(cmd); const char *cmd_path = NULL; int done_alias = 0; @@ -406,12 +406,10 @@ int main(int argc, const char **argv) * name, and the dirname as the default exec_path * if we don't have anything better. */ -#ifdef __MINGW32__ - char *bslash = strrchr(cmd, '\\'); - if (!slash || (bslash && bslash > slash)) - slash = bslash; -#endif - if (slash) { + do + --slash; + while (cmd <= slash && !is_dir_sep(*slash)); + if (cmd <= slash) { *slash++ = 0; cmd_path = cmd; cmd = slash;