summaryrefslogtreecommitdiff
path: root/utility.c
diff options
context:
space:
mode:
authorEric Andersen2000-07-10 16:44:03 +0000
committerEric Andersen2000-07-10 16:44:03 +0000
commit0b4551faf520e44a9a0bf2ac72b3dcd6a145a0a1 (patch)
tree4694959864edc8f08b950f9cc2547dfe87422819 /utility.c
parenta03d86cf5496a24ccf81bfbf8fdbb10b1ad13a0a (diff)
downloadbusybox-0b4551faf520e44a9a0bf2ac72b3dcd6a145a0a1.zip
busybox-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 'utility.c')
-rw-r--r--utility.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/utility.c b/utility.c
index a15ae68..a313078 100644
--- a/utility.c
+++ b/utility.c
@@ -1675,6 +1675,23 @@ char process_escape_sequence(char **ptr)
}
#endif
+#if defined BB_BASENAME || defined BB_LN
+char *get_last_path_component(char *path)
+{
+ char *s=path+strlen(path)-1;
+
+ /* strip trailing slashes */
+ while (s && *s == '/') {
+ *s-- = '\0';
+ }
+
+ /* find last component */
+ s = strrchr(path, '/');
+ if (s==NULL) return path;
+ else return s+1;
+}
+#endif
+
/* END CODE */
/*
Local Variables: