diff options
author | Jim Meyering <meyering@redhat.com> | 2007-10-08 10:34:04 +0200 |
---|---|---|
committer | Jim Meyering <meyering@redhat.com> | 2007-10-08 10:47:40 +0200 |
commit | e6f4b28275316895ad8808a9d0abcc468df8780b (patch) | |
tree | 7bd4c3e13a773b3dfd074077f22ec75bbe1c7a22 /src/remove.c | |
parent | 689186b88ccf025664ca24ac8efa68699f12d85d (diff) | |
download | coreutils-e6f4b28275316895ad8808a9d0abcc468df8780b.tar.xz |
When forming a truncated name, use the "[...]" prefix even for
an extremely long name in the current directory.
* src/remove.c (full_filename_): Rename a local variable.
Use two separate "truncated" variables, in case the second
call to right_justify does not indicate any truncation -- which
would happen only if the single component FILENAME were longer
than 511 bytes and DIR_NAME were empty.
Diffstat (limited to 'src/remove.c')
-rw-r--r-- | src/remove.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/remove.c b/src/remove.c index 1023048ff..1c6166d5e 100644 --- a/src/remove.c +++ b/src/remove.c @@ -383,17 +383,20 @@ full_filename_ (Dirstack_state const *ds, const char *filename) #define SBUF_SIZE 512 #define ELLIPSES_PREFIX "[...]" static char static_buf[SBUF_SIZE]; - bool truncated; - size_t len; + bool file_truncated; + bool dir_truncated; + size_t n_bytes_remaining; char *p; char *dir_name = obstack_base (&ds->dir_stack); size_t dir_len = obstack_object_size (&ds->dir_stack); free (g_buf); - len = right_justify (static_buf, SBUF_SIZE, filename, - strlen (filename) + 1, &p, &truncated); - right_justify (static_buf, len, dir_name, dir_len, &p, &truncated); - if (truncated) + n_bytes_remaining = right_justify (static_buf, SBUF_SIZE, filename, + strlen (filename) + 1, &p, + &file_truncated); + right_justify (static_buf, n_bytes_remaining, dir_name, dir_len, + &p, &dir_truncated); + if (file_truncated || dir_truncated) { memcpy (static_buf, ELLIPSES_PREFIX, sizeof (ELLIPSES_PREFIX) - 1); |