From b2476bc5232246278bc6a40e812785270bccb668 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Wed, 31 Jan 2024 15:21:31 +0100 Subject: Cygwin: globals: make __progname an alias of program_invocation_short_name On Linux, __progname and program_invocation_short_name are just different exported names of the same string. Do the same in Cygwin. This requires to tweak the mkglobals_h so as not to touch the EXPORT_ALIAS expression. Also, use the base variable program_invocation_short_name throughout. __progname is just the export for getopt. Signed-off-by: Corinna Vinschen --- winsup/cygwin/dcrt0.cc | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'winsup/cygwin/dcrt0.cc') diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc index fc1eec7..a40129c 100644 --- a/winsup/cygwin/dcrt0.cc +++ b/winsup/cygwin/dcrt0.cc @@ -924,17 +924,17 @@ dll_crt0_1 (void *) /* Set up standard fds in file descriptor table. */ cygheap->fdtab.stdio_init (); - /* Set up __progname for getopt error call. */ - if (__argv[0] && (__progname = strrchr (__argv[0], '/'))) - ++__progname; - else - __progname = __argv[0]; + /* Set up program_invocation_name and program_invocation_short_name. + __progname is an export alias for program_invocation_short_name. */ program_invocation_name = __argv[0]; - program_invocation_short_name = __progname; - if (__progname) + if (__argv[0] && (program_invocation_short_name = strrchr (__argv[0], '/'))) + ++program_invocation_short_name; + else + program_invocation_short_name = __argv[0]; + if (program_invocation_short_name) { - char *cp = strchr (__progname, '\0') - 4; - if (cp > __progname && ascii_strcasematch (cp, ".exe")) + char *cp = strchr (program_invocation_short_name, '\0') - 4; + if (cp > program_invocation_short_name && ascii_strcasematch (cp, ".exe")) *cp = '\0'; } SetThreadName (GetCurrentThreadId (), program_invocation_short_name); -- cgit v1.1