aboutsummaryrefslogtreecommitdiffstats
path: root/syscall.c
diff options
context:
space:
mode:
authorMartin Pool <mbp@samba.org>2002-03-25 03:51:17 +0000
committerMartin Pool <mbp@samba.org>2002-03-25 03:51:17 +0000
commitc127e8aaec2b0ea408a3cd3a36fd910520249332 (patch)
tree0349338dd7657a63b898eff715822489a29493a1 /syscall.c
parentbf4e725d5d3c0a06c9a8d74cb9b1c183e161f148 (diff)
downloadandroid_external_rsync-c127e8aaec2b0ea408a3cd3a36fd910520249332.tar.gz
android_external_rsync-c127e8aaec2b0ea408a3cd3a36fd910520249332.tar.bz2
android_external_rsync-c127e8aaec2b0ea408a3cd3a36fd910520249332.zip
Add a test case for trim_trailing_slashes, and make it handle other cases.
Diffstat (limited to 'syscall.c')
-rw-r--r--syscall.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/syscall.c b/syscall.c
index b4b581b9..b198dbf4 100644
--- a/syscall.c
+++ b/syscall.c
@@ -113,15 +113,19 @@ int do_rename(char *fname1, char *fname2)
void trim_trailing_slashes(char *name)
{
- char *p;
+ int l;
/* Some BSD systems cannot make a directory if the name
* contains a trailing slash.
* <http://www.opensource.apple.com/bugs/X/BSD%20Kernel/2734739.html> */
- if (!*name)
- return; /* empty string */
- p = strchr(name, '\0') - 1;
- while (p == '/') {
- p-- = '\0';
+
+ /* Don't change empty string; and also we can't improve on
+ * "/" */
+
+ l = strlen(name);
+ while (l > 1) {
+ if (name[--l] != '/')
+ break;
+ name[l] = '\0';
}
}