projects
/
oweals
/
busybox.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Support for tar -z option for uncompressing only
[oweals/busybox.git]
/
basename.c
diff --git
a/basename.c
b/basename.c
index 10ae761889ec809689a8c24af17dc5598e5fd8b9..fcc7d4619ec458fbbddaf88e63605aa385f3d78b 100644
(file)
--- a/
basename.c
+++ b/
basename.c
@@
-21,32
+21,21
@@
*
*/
*
*/
-#include "
internal
.h"
+#include "
busybox
.h"
#include <stdio.h>
extern int basename_main(int argc, char **argv)
{
int m, n;
#include <stdio.h>
extern int basename_main(int argc, char **argv)
{
int m, n;
- char *s
, *s1
;
+ char *s;
if ((argc < 2) || (**(argv + 1) == '-')) {
if ((argc < 2) || (**(argv + 1) == '-')) {
- usage("basename FILE [SUFFIX]\n"
-#ifndef BB_FEATURE_TRIVIAL_HELP
- "\nStrips directory path and suffixes from FILE.\n"
- "If specified, also removes any trailing SUFFIX.\n"
-#endif
- );
+ usage(basename_usage);
}
}
+
argv++;
argv++;
- s1=*argv+strlen(*argv)-1;
- while (s1 && *s1 == '/') {
- *s1 = '\0';
- s1--;
- }
- s = strrchr(*argv, '/');
- if (s==NULL) s=*argv;
- else s++;
+ s = get_last_path_component(*argv);
if (argc>2) {
argv++;
if (argc>2) {
argv++;
@@
-56,6
+45,5
@@
extern int basename_main(int argc, char **argv)
s[m-n] = '\0';
}
printf("%s\n", s);
s[m-n] = '\0';
}
printf("%s\n", s);
-
exit(TRUE)
;
+
return EXIT_SUCCESS
;
}
}
-