diff options
author | Karel Zak | 2010-10-07 10:35:32 +0200 |
---|---|---|
committer | Karel Zak | 2010-10-07 10:35:32 +0200 |
commit | 37d6897f940032617bc020461ae50fc3d3c2dfe6 (patch) | |
tree | 7342efbcae3dbe3415b7715c0f63c2194b58a7ff /misc-utils/cal.c | |
parent | lscpu: really use 'mode' argument in path_fopen() (diff) | |
download | kernel-qcow2-util-linux-37d6897f940032617bc020461ae50fc3d3c2dfe6.tar.gz kernel-qcow2-util-linux-37d6897f940032617bc020461ae50fc3d3c2dfe6.tar.xz kernel-qcow2-util-linux-37d6897f940032617bc020461ae50fc3d3c2dfe6.zip |
cal: use EXIT_* and program_invocation_short_name
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'misc-utils/cal.c')
-rw-r--r-- | misc-utils/cal.c | 22 |
1 files changed, 9 insertions, 13 deletions
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 <time.h> #include <unistd.h> #include <err.h> +#include <errno.h> #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); } |