From eba23038af62124b3e75016f9b7294637e7022c2 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Thu, 27 Jun 2002 16:01:38 +0000 Subject: [PATCH] * dcrt0.cc (dll_crt0_1): Let __progname point to the applications basename. Move eliminating ".exe" suffix from argv[0] so that it always also affects __progname. --- winsup/cygwin/ChangeLog | 6 ++++++ winsup/cygwin/dcrt0.cc | 14 ++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 871ab64f2..b6e99f0e1 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,9 @@ +2002-06-27 Corinna Vinschen + + * dcrt0.cc (dll_crt0_1): Let __progname point to the applications + basename. Move eliminating ".exe" suffix from argv[0] so that it + always also affects __progname. + 2002-06-27 Thomas Pfaff * thread.cc (pthread::create): Added trace printf to get CreateThread diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc index da2865112..a27e8e4eb 100644 --- a/winsup/cygwin/dcrt0.cc +++ b/winsup/cygwin/dcrt0.cc @@ -704,9 +704,6 @@ dll_crt0_1 () { char *new_argv0 = (char *) alloca (MAX_PATH); cygwin_conv_to_posix_path (__argv[0], new_argv0); - char *p = strchr (new_argv0, '\0') - 4; - if (p > new_argv0 && strcasematch (p, ".exe")) - *p = '\0'; __argv[0] = new_argv0; } } @@ -719,7 +716,16 @@ dll_crt0_1 () cygheap->fdtab.stdio_init (); /* Set up __progname for getopt error call. */ - __progname = __argv[0]; + if (__argv[0] && (__progname = strrchr (__argv[0], '/'))) + ++__progname; + else + __progname = __argv[0]; + if (__progname) + { + char *cp = strchr (__progname, '\0') - 4; + if (cp > __progname && strcasematch (cp, ".exe")) + *cp = '\0'; + } /* Set new console title if appropriate. */