get_progname and .exe suffix

Started by Andrew Dunstanabout 21 years ago2 messages
#1Andrew Dunstan
andrew@dunslane.net

My original code for initdb stripped the .exe suffix off the progname
stored, in this snippet of code:

carg0 = xstrdup(argv[0]);
canonicalise_path(carg0);

lastsep = strrchr(carg0, *'/'*);
progname = lastsep ? xstrdup(lastsep + 1) : carg0;

#*if* *defined*(__CYGWIN__) || *defined*(WIN32)
*if* (strlen(progname) > 4 &&
(exe = progname + (strlen(progname) - 4)) &&
stricmp(exe, EXE) == 0)
{
//* strip .exe suffix, regardless of case *//
*exe = *'\0'*;
}
#*endif* //* defined(__CYGWIN__) || defined(WIN32) */

Somewhere along the way, probably when we moved to using a generalised get_progname(), that seems to have been lost. Not only is keeping the .exe suffix ugly, but it breaks the contrib installcheck regression tests on windows (hasn't anyone run these?)

A simple fix for this last problem would be to put some similar code to the above into psql, but something cleaner and applicable to all users of get_progname might be nicer.

Thoughts?

andrew

/

#2Dave Page
dpage@vale-housing.co.uk
In reply to: Andrew Dunstan (#1)
Re: get_progname and .exe suffix

-----Original Message-----
From: pgsql-hackers-owner@postgresql.org
[mailto:pgsql-hackers-owner@postgresql.org] On Behalf Of
Andrew Dunstan
Sent: 15 October 2004 15:07
To: PostgreSQL-development
Subject: [HACKERS] get_progname and .exe suffix

Somewhere along the way, probably when we moved to using a
generalised get_progname(), that seems to have been lost. Not
only is keeping the .exe suffix ugly, but it breaks the
contrib installcheck regression tests on windows (hasn't
anyone run these?)

Yes, and reported the problem...

Regards, Dave