From 37d6897f940032617bc020461ae50fc3d3c2dfe6 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Thu, 7 Oct 2010 10:35:32 +0200 Subject: cal: use EXIT_* and program_invocation_short_name Signed-off-by: Karel Zak --- misc-utils/cal.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'misc-utils/cal.c') diff --git a/misc-utils/cal.c b/misc-utils/cal.c index 65d517a8c..4d46c1b1b 100644 --- a/misc-utils/cal.c +++ b/misc-utils/cal.c @@ -64,6 +64,7 @@ #include #include #include +#include #include "c.h" #include "nls.h" @@ -257,21 +258,14 @@ void monthly3(int, int, int); void trim_trailing_spaces(char *); void usage(void); void headers_init(void); -extern char *__progname; int main(int argc, char **argv) { struct tm *local_time; time_t now; int ch, day, month, year, yflag; - char *progname, *p; int num_months = NUM_MONTHS; - progname = argv[0]; - if ((p = strrchr(progname, '/')) != NULL) - progname = p+1; - __progname = progname; - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); @@ -345,9 +339,9 @@ main(int argc, char **argv) { yflag = 1; break; case 'V': - printf(_("%s from %s\n"), - progname, PACKAGE_STRING); - return 0; + printf(_("%s from %s\n"), program_invocation_short_name, + PACKAGE_STRING); + return EXIT_SUCCESS; case '?': default: usage(); @@ -403,7 +397,8 @@ main(int argc, char **argv) { monthly(day, month, year); else if (num_months == 3) monthly3(day, month, year); - exit(0); + + return EXIT_SUCCESS; } void headers_init(void) @@ -783,6 +778,7 @@ void usage() { - fprintf(stderr, _("usage: cal [-13smjyV] [[[day] month] year]\n")); - exit(1); + fprintf(stderr, _("usage: %s [-13smjyV] [[[day] month] year]\n"), + program_invocation_short_name); + exit(EXIT_FAILURE); } -- cgit v1.2.3-55-g7522