summaryrefslogtreecommitdiff
path: root/usr.bin/ncal
diff options
context:
space:
mode:
authorEdwin Groothuis <edwin@FreeBSD.org>2010-08-30 22:24:26 +0000
committerEdwin Groothuis <edwin@FreeBSD.org>2010-08-30 22:24:26 +0000
commit746b67cdfab321e3f13565cb6e3e2b7931367e22 (patch)
treec81824ceb048520965c52e8e8d684f50fd85b529 /usr.bin/ncal
parent89513bce113664394f9bebd3f214d820972a5a28 (diff)
downloadsrc-test-746b67cdfab321e3f13565cb6e3e2b7931367e22.tar.gz
src-test-746b67cdfab321e3f13565cb6e3e2b7931367e22.zip
Use basename(3) to determine the name of the program.
Submitted by: Alexander Best <arundel@>
Notes
Notes: svn path=/head/; revision=212032
Diffstat (limited to 'usr.bin/ncal')
-rw-r--r--usr.bin/ncal/ncal.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/usr.bin/ncal/ncal.c b/usr.bin/ncal/ncal.c
index 5ab9a21c0d848..44e31fec1db6b 100644
--- a/usr.bin/ncal/ncal.c
+++ b/usr.bin/ncal/ncal.c
@@ -33,6 +33,7 @@ static const char rcsid[] =
#include <ctype.h>
#include <err.h>
#include <langinfo.h>
+#include <libgen.h>
#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
@@ -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 */