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 78265a5e61bda1eb1252008c1f00df5df02f5f2a..fcc7d4619ec458fbbddaf88e63605aa385f3d78b 100644
(file)
--- a/
basename.c
+++ b/
basename.c
@@
-21,21
+21,13
@@
*
*/
*
*/
-#include "
internal
.h"
+#include "
busybox
.h"
#include <stdio.h>
#include <stdio.h>
-const char *basename_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
-;
-
-
extern int basename_main(int argc, char **argv)
{
int m, n;
extern int basename_main(int argc, char **argv)
{
int m, n;
- char *s
, *s1
;
+ char *s;
if ((argc < 2) || (**(argv + 1) == '-')) {
usage(basename_usage);
if ((argc < 2) || (**(argv + 1) == '-')) {
usage(basename_usage);
@@
-43,14
+35,7
@@
extern int basename_main(int argc, char **argv)
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++;
@@
-60,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
;
}
}
-