From e6f4b28275316895ad8808a9d0abcc468df8780b Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Mon, 8 Oct 2007 10:34:04 +0200 Subject: 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. --- src/remove.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/remove.c') 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); -- cgit v1.2.3-54-g00ecf