aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/basename/basename.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/basename/basename.c')
-rw-r--r--usr.bin/basename/basename.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/usr.bin/basename/basename.c b/usr.bin/basename/basename.c
index 18ff63686de0..29c43bf41660 100644
--- a/usr.bin/basename/basename.c
+++ b/usr.bin/basename/basename.c
@@ -38,22 +38,28 @@ char copyright[] =
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)basename.c 5.1 (Berkeley) 3/9/91";
+/*static char sccsid[] = "from: @(#)basename.c 5.1 (Berkeley) 3/9/91";*/
+static char rcsid[] = "$Id: basename.c,v 1.2 1993/11/23 00:01:06 jtc Exp $";
#endif /* not lint */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <locale.h>
+static void usage __P((void));
+
+int
main(argc, argv)
int argc;
char **argv;
{
- extern int optind;
register char *p;
int ch;
- while ((ch = getopt(argc, argv, "")) != EOF)
+ setlocale(LC_ALL, "");
+
+ while ((ch = getopt(argc, argv, "")) != -1)
switch(ch) {
case '?':
default:
@@ -89,8 +95,10 @@ main(argc, argv)
* (3) If there are any trailing slash characters in string, they
* shall be removed.
*/
- for (; *p; ++p);
- while (*--p == '/');
+ for (; *p; ++p)
+ ;
+ while (*--p == '/')
+ ;
*++p = '\0';
/*
@@ -125,6 +133,7 @@ main(argc, argv)
exit(0);
}
+static void
usage()
{
(void)fprintf(stderr, "usage: basename string [suffix]\n");