[BACK]Return to test-progname.c CVS log [TXT][DIR] Up to [cvsweb.bsd.lv] / mandoc

File: [cvsweb.bsd.lv] / mandoc / test-progname.c (download)

Revision 1.1, Sun Oct 11 21:12:55 2015 UTC (8 years, 6 months ago) by schwarze
Branch: MAIN

Finally use __progname, err(3) and warn(3).
That's more readable and less error-prone than fumbling around
with argv[0], fprintf(3), strerror(3), perror(3), and exit(3).

It's a bad idea to boycott good interfaces merely because standards
committees ignore them.  Instead, let's provide compatibility modules
for archaic systems (like commercial Solaris) that still don't have
them.  The compat module has an UCB Copyright (c) 1993...

#include <string.h>

extern char *__progname;

int
main(void)
{
	return !!strcmp(__progname, "test-progname");
}