bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: getprogname


From: Paul Eggert
Subject: Re: getprogname
Date: Tue, 10 Jan 2006 12:37:37 -0800
User-agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux)

Bruno Haible <address@hidden> writes:

> Well, my intention is basically this:

A few comments.....

This isn't as compatible as possible with BSD, as BSD setprogname
ignores its argument when the true program name is available from
the operating system.

LibGW32C-0.3 has getexecname (see
<http://sourceforge.net/project/shownotes.php?release_id=154242>), so
that function is not unique to Solaris.

I just looked it up, and on Solaris, getexecname might fail and return
NULL, on programs that are linked statically.

Surely you meant base_name rather than basename?

How about something like this instead?


#if !HAVE_GETEXECNAME
# define getexecname() NULL
#endif

#if !HAVE_GETPROGNAME

static const char *progname;

void
setprogname (const char *arg)
{
  progname = arg;
}

const char *
getprogname ()
{
#if HAVE_PROGRAM_INVOCATION_SHORT_NAME /* glibc */
  return program_invocation_short_name;
#else
  const char *p = getexecname ();
  return base_name (p ? p : progname);
#endif
}

#endif




reply via email to

[Prev in Thread] Current Thread [Next in Thread]