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.
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];
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;
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);