summaryrefslogtreecommitdiff
path: root/utility.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 /utility.c
parenta03d86cf5496a24ccf81bfbf8fdbb10b1ad13a0a (diff)
downloadbusybox-w32-0b4551faf520e44a9a0bf2ac72b3dcd6a145a0a1.tar.gz
busybox-w32-0b4551faf520e44a9a0bf2ac72b3dcd6a145a0a1.tar.bz2
busybox-w32-0b4551faf520e44a9a0bf2ac72b3dcd6a145a0a1.zip
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 a15ae68da..a313078cf 100644
--- a/utility.c
+++ b/utility.c
@@ -1675,6 +1675,23 @@ char process_escape_sequence(char **ptr)
1675} 1675}
1676#endif 1676#endif
1677 1677
1678#if defined BB_BASENAME || defined BB_LN
1679char *get_last_path_component(char *path)
1680{
1681 char *s=path+strlen(path)-1;
1682
1683 /* strip trailing slashes */
1684 while (s && *s == '/') {
1685 *s-- = '\0';
1686 }
1687
1688 /* find last component */
1689 s = strrchr(path, '/');
1690 if (s==NULL) return path;
1691 else return s+1;
1692}
1693#endif
1694
1678/* END CODE */ 1695/* END CODE */
1679/* 1696/*
1680Local Variables: 1697Local Variables: