Mercurial > hg > octave-nkf > gnulib-hg
changeset 7308:eac21c5dbf2f
* rename-dest-slash.c (has_trailing_slash): Use
FILE_SYSTEM_PREFIX_LEN, for non-POSIX systems.
(rpl_rename_dest_slash): Perform the cheaper trailing slash
test before testing whether SRC is a directory.
Suggestions from Bruno Haible.
author | Jim Meyering <jim@meyering.net> |
---|---|
date | Fri, 15 Sep 2006 18:48:09 +0000 |
parents | 87cb6e41fd09 |
children | 901d31516630 |
files | lib/ChangeLog lib/rename-dest-slash.c |
diffstat | 2 files changed, 12 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,5 +1,11 @@ 2006-09-15 Jim Meyering <jim@meyering.net> + * rename-dest-slash.c (has_trailing_slash): Use + FILE_SYSTEM_PREFIX_LEN, for non-POSIX systems. + (rpl_rename_dest_slash): Perform the cheaper trailing slash + test before testing whether SRC is a directory. + Suggestions from Bruno Haible. + Avoid a warning about an unused variable. * regex_internal.c (re_dfa_add_node): Move declaration of "type" into the #ifdef block where it's used.
--- a/lib/rename-dest-slash.c +++ b/lib/rename-dest-slash.c @@ -42,7 +42,7 @@ has_trailing_slash (char const *file, size_t len) { /* Don't count "/" as having a trailing slash. */ - if (len <= 1) + if (len <= FILE_SYSTEM_PREFIX_LEN (file) + 1) return false; char last = file[len - 1]; @@ -64,6 +64,11 @@ if (ret_val == 0 || errno != ENOENT) return ret_val; + /* Don't call rename again if there are no trailing slashes. */ + d_len = strlen (dst); + if ( ! has_trailing_slash (dst, d_len)) + return ret_val; + { /* Fail now, unless SRC is a directory. */ struct stat sb; @@ -71,11 +76,6 @@ return ret_val; } - /* Don't call rename again if there are no trailing slashes. */ - d_len = strlen (dst); - if ( ! has_trailing_slash (dst, d_len)) - return ret_val; - { char *dst_temp; dst_temp = xmemdup (dst, d_len + 1);