From 746b67cdfab321e3f13565cb6e3e2b7931367e22 Mon Sep 17 00:00:00 2001 From: Edwin Groothuis Date: Mon, 30 Aug 2010 22:24:26 +0000 Subject: Use basename(3) to determine the name of the program. Submitted by: Alexander Best --- usr.bin/ncal/ncal.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'usr.bin/ncal') diff --git a/usr.bin/ncal/ncal.c b/usr.bin/ncal/ncal.c index 5ab9a21c0d84..44e31fec1db6 100644 --- a/usr.bin/ncal/ncal.c +++ b/usr.bin/ncal/ncal.c @@ -33,6 +33,7 @@ static const char rcsid[] = #include #include #include +#include #include #include #include @@ -245,9 +246,7 @@ main(int argc, char *argv[]) * Get the filename portion of argv[0] and set flag_backward if * this program is called "cal". */ - cp = strrchr(argv[0], '/'); - cp = (cp == NULL) ? argv[0] : cp + 1; - if (strcmp("cal", cp) == 0) + if (strncmp(basename(argv[0]), "cal", strlen("cal")) == 0) flag_backward = 1; /* Set the switch date to United Kingdom if backwards compatible */ -- cgit v1.2.3