bug-gnulib
[Top][All Lists]
Advanced

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

Re: use of program_name


From: Paul Eggert
Subject: Re: use of program_name
Date: Fri, 06 Jan 2006 15:51:29 -0800
User-agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux)

Thanks for taking this on.

James Youngman <address@hidden> writes:

> --- doc/standards.texi        25 Dec 2005 23:59:50 -0000      1.10
> +++ doc/standards.texi        6 Jan 2006 11:35:14 -0000

This part we should funnel through the standards maintainer.  There
shouldn't be any problem with it, it's just that it should get
installed upstream, after we update gnulib itself.

> +const char *program_name(void)
> +{
> +  return myname;
> +}

Please use the normal GNU style for indentation, here and elsewhere.

const char *
program_name (void)
{
  return myname;
}

> -  program_name = (char *) argv[0];
> +  myname = (char *) argv[0];

The cast shouldn't be needed.  (It shouldn't have been needed in
the original.)

> -      fprintf (stderr, "Usage: %s [VERSION_CONTROL]\n", program_name);
> +      fprintf (stderr, "Usage: %s [VERSION_CONTROL]\n", program_name());

Please put in a space before the '(', here and elsewhere.

> -   Copyright (C) 2002, 2004 Free Software Foundation, Inc.
> +   Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.

2006, surely (here and elsewhere).

> +char *myname;

Should be 'char const *'.  (By the way, Jim and I prefer that style
to 'const char *', so outside glibc-derived code let's go that way.)

> -# define program_name program_invocation_name

Let's omit this '#define', and change all uses of program_name to
program_name in the rest of the code.  The other arm of the #if can
then contain

#define program_invocation_name program_name ()

This will make things easier for the glibc maintainers.

> +/* program_name() should be defined by the application and should 
> + * return the program's name.  This is normally the same string as was
> + * passed to main() as argv[0].
> + */
> +extern const char *program_name(void);

We should not change error.h that way, since it shouldn't be added to
glibc.  Let's leave error.h alone.  The decl should be in progname.h,
and error.c should include progname.h (not in glibc mode of course).

> -const char *program_name = NULL;
> +static const char *the_program_name = NULL;

Change this to

static char const *myname;

for consistency with the other examples.  There's no need to
initialize it to NULL; on some systems startup is faster if you don't.




reply via email to

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