1
0
mirror of git://git.sv.gnu.org/coreutils.git synced 2026-08-17 17:08:20 +02:00

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 `/.'.
This commit is contained in:
Jim Meyering
2003-01-04 09:45:54 +00:00
parent b09da5c9d0
commit a3e6d3aa63
+15 -5
View File
@@ -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;
}