summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2003-01-04 09:45:54 +0000
committerJim Meyering <jim@meyering.net>2003-01-04 09:45:54 +0000
commita3e6d3aa63ef885e69e9a8835c5a138666ba0a49 (patch)
tree032f8726502088ab94ca6b0b53ffdd867036fa22 /src
parentb09da5c9d0bcff53bd6fd3fca3561ca5c94d38d4 (diff)
downloadcoreutils-a3e6d3aa63ef885e69e9a8835c5a138666ba0a49.tar.xz
Don't include trailing /. in diagnostics about directories.
(full_filename_): When FILENAME is just `.' and there is a nonempty directory-name part, don't append `/.'.
Diffstat (limited to 'src')
-rw-r--r--src/remove.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/remove.c b/src/remove.c
index 6269c5097..67e09ccf1 100644
--- a/src/remove.c
+++ b/src/remove.c
@@ -312,11 +312,21 @@ full_filename_ (DS const *ds, const char *filename)
}
}
- /* Copy directory part, including trailing slash, and then
- append the filename part, including a trailing zero byte. */
- memcpy (mempcpy (buf, dir_name, dir_len), filename, filename_len + 1);
-
- assert (strlen (buf) + 1 == n_bytes_needed);
+ if (filename_len == 1 && *filename == '.' && dir_len)
+ {
+ /* FILENAME is just `.' and dir_len is nonzero.
+ Copy the directory part, omitting the trailing slash,
+ and append a trailing zero byte. */
+ char *p = mempcpy (buf, dir_name, dir_len - 1);
+ *p = 0;
+ }
+ else
+ {
+ /* Copy the directory part, including trailing slash, and then
+ append the filename part, including a trailing zero byte. */
+ memcpy (mempcpy (buf, dir_name, dir_len), filename, filename_len + 1);
+ assert (strlen (buf) + 1 == n_bytes_needed);
+ }
return buf;
}