aboutsummaryrefslogtreecommitdiff
path: root/coreutils/basename.c
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2000-07-10 16:44:03 +0000
committerEric Andersen <andersen@codepoet.org>2000-07-10 16:44:03 +0000
commit0b4551faf520e44a9a0bf2ac72b3dcd6a145a0a1 (patch)
tree4694959864edc8f08b950f9cc2547dfe87422819 /coreutils/basename.c
parenta03d86cf5496a24ccf81bfbf8fdbb10b1ad13a0a (diff)
downloadbusybox-0b4551faf520e44a9a0bf2ac72b3dcd6a145a0a1.tar.gz
From Matt Kraai <kraai@alumni.carnegiemellon.edu>:
Howdy, Bug #1006 reports that ln -s /tmp/foo . does not work correctly. In fact, it appears that any instantiation of ln -s FILE... DIRECTORY does not work. The following patch adds support for this form, which then fixes the particular instance noted in the bug report. In the process, I needed the basename function. This appears in the string.h provided by glibc, but not uC-libc. So I wrote my own to go in utility.c, called get_last_path_component. I also modified the basename utility to use this function. At some point it might be desirous to use the basename from the library if it exists, and otherwise compile our own. But I don't know how to do this. Matt
Diffstat (limited to 'coreutils/basename.c')
-rw-r--r--coreutils/basename.c10
1 files changed, 1 insertions, 9 deletions
diff --git a/coreutils/basename.c b/coreutils/basename.c
index ac371d274..fa15aa979 100644
--- a/coreutils/basename.c
+++ b/coreutils/basename.c
@@ -43,14 +43,7 @@ extern int basename_main(int argc, char **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++;
@@ -62,4 +55,3 @@ extern int basename_main(int argc, char **argv)
printf("%s\n", s);
return(TRUE);
}
-