# HG changeset patch # User Jim Meyering # Date 1158346089 0 # Node ID eac21c5dbf2f840ce73fee8ddb512991aca30e08 # Parent 87cb6e41fd0966408fb88d60d8cc437137ab8b76 * 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. diff -r 87cb6e41fd09 -r eac21c5dbf2f lib/ChangeLog --- a/lib/ChangeLog Fri Sep 15 16:41:43 2006 +0000 +++ b/lib/ChangeLog Fri Sep 15 18:48:09 2006 +0000 @@ -1,5 +1,11 @@ 2006-09-15 Jim Meyering + * 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. diff -r 87cb6e41fd09 -r eac21c5dbf2f lib/rename-dest-slash.c --- a/lib/rename-dest-slash.c Fri Sep 15 16:41:43 2006 +0000 +++ b/lib/rename-dest-slash.c Fri Sep 15 18:48:09 2006 +0000 @@ -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);