Subject: Re: setting and using progname.
To: NetBSD Userlevel Technical Discussion List <tech-userlevel@netbsd.org>
From: Andrew Brown <atatat@atatdot.net>
List: tech-userlevel
Date: 10/03/2000 18:10:47
>	const char __progname[PATH_MAX];
>	
>	void
>	setprogname(argv0)
>		char *argv0;
>	{
>		char *p;
>		char *q;
>	
>		p = (q = strrchr(argv0, '/')) ? q + 1 : argv0;
>		strncpy(__progname, p, sizeof(__progname)-1);
>		__progname[sizeof(__progname)-1] = '\0';
>		if (q)
>			*q = '/';
>		return;
>	}

why the "if (q) *q = '/';" bit?  that seems a little superfluous.  as
if it, this routine could be simplified to:

	{
		char *q;
	
		q = strrchr(argv0, '/');
		strncpy(__progname, q ? q + 1 : argv0, sizeof(__progname)-1);
		__progname[sizeof(__progname)-1] = '\0';
	}

no?  i suppose if you wished, you could also stuff the strrchr() call
into the ?: operator in the strncpy() argument.  :)

-- 
|-----< "CODE WARRIOR" >-----|
codewarrior@daemon.org             * "ah!  i see you have the internet
twofsonet@graffiti.com (Andrew Brown)                that goes *ping*!"
andrew@crossbar.com       * "information is power -- share the wealth."