On Windows, cause get_progname to strip any .EXE suffix.
Andrew Dunstan
This commit is contained in:
parent
0f845a9f09
commit
39fccf0277
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/port/path.c,v 1.36 2004/09/24 05:16:35 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/port/path.c,v 1.37 2004/10/24 22:08:19 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -175,15 +175,38 @@ canonicalize_path(char *path)
|
||||
|
||||
|
||||
/*
|
||||
* Extracts the actual name of the program as called.
|
||||
* Extracts the actual name of the program as called -
|
||||
* stripped of .exe suffix if any
|
||||
*/
|
||||
const char *
|
||||
get_progname(const char *argv0)
|
||||
{
|
||||
const char *nodir_name;
|
||||
|
||||
if (!last_dir_separator(argv0))
|
||||
return argv0;
|
||||
nodir_name = argv0;
|
||||
else
|
||||
return last_dir_separator(argv0) + 1;
|
||||
nodir_name = last_dir_separator(argv0) + 1;
|
||||
|
||||
#if defined(__CYGWIN__) || defined(WIN32)
|
||||
/* strip .exe suffix, regardless of case */
|
||||
if (strlen(nodir_name) > 4 &&
|
||||
stricmp(nodir_name + (strlen(nodir_name) - 4), EXE) == 0)
|
||||
{
|
||||
char *progname;
|
||||
|
||||
progname = strdup(nodir_name);
|
||||
if (progname == NULL)
|
||||
{
|
||||
fprintf(stderr, "%s: out of memory\n", nodir_name);
|
||||
exit(1);
|
||||
}
|
||||
progname[strlen(progname) - 4] = '\0';
|
||||
nodir_name = progname;
|
||||
}
|
||||
#endif
|
||||
|
||||
return nodir_name;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user