diff options
| author | Martin Pool <mbp@samba.org> | 2002-03-25 03:51:17 +0000 |
|---|---|---|
| committer | Martin Pool <mbp@samba.org> | 2002-03-25 03:51:17 +0000 |
| commit | c127e8aaec2b0ea408a3cd3a36fd910520249332 (patch) | |
| tree | 0349338dd7657a63b898eff715822489a29493a1 /syscall.c | |
| parent | bf4e725d5d3c0a06c9a8d74cb9b1c183e161f148 (diff) | |
| download | android_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.c | 16 |
1 files changed, 10 insertions, 6 deletions
@@ -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'; } } |
