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 <johannes.sixt@telecom.at>
This commit is contained in:
Johannes Sixt
2008-06-23 10:59:12 +02:00
parent b0115de333
commit 16502c915f

14
git.c
View File

@@ -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;