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 | |
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')
-rw-r--r-- | src/c99-to-c89.diff | 12 | ||||
-rw-r--r-- | src/remove.c | 15 |
2 files changed, 15 insertions, 12 deletions
diff --git a/src/c99-to-c89.diff b/src/c99-to-c89.diff index f6c7664ed..76ecad28c 100644 --- a/src/c99-to-c89.diff +++ b/src/c99-to-c89.diff @@ -13,7 +13,7 @@ diff -upr src/remove.c src/remove.c assert (top_len >= 2); /* Pop the specified length of file name. */ -@@ -419,10 +420,11 @@ AD_stack_top (Dirstack_state const *ds) +@@ -422,10 +423,11 @@ AD_stack_top (Dirstack_state const *ds) static void AD_stack_pop (Dirstack_state *ds) { @@ -26,7 +26,7 @@ diff -upr src/remove.c src/remove.c if (top->unremovable) hash_free (top->unremovable); obstack_blank (&ds->Active_dir, -(int) sizeof (struct AD_ent)); -@@ -904,6 +906,7 @@ prompt (int fd_cwd, Dirstack_state const +@@ -907,6 +909,7 @@ prompt (int fd_cwd, Dirstack_state const break; } @@ -34,7 +34,7 @@ diff -upr src/remove.c src/remove.c char const *quoted_name = quote (full_filename (filename)); if (0 < write_protected) -@@ -943,6 +946,7 @@ prompt (int fd_cwd, Dirstack_state const +@@ -946,6 +949,7 @@ prompt (int fd_cwd, Dirstack_state const : _("%s: remove %s %s? ")), program_name, file_type (sbuf), quoted_name); } @@ -42,7 +42,7 @@ diff -upr src/remove.c src/remove.c if (!yesno ()) return RM_USER_DECLINED; -@@ -1562,6 +1566,7 @@ rm_1 (Dirstack_state *ds, char const *fi +@@ -1565,6 +1569,7 @@ rm_1 (Dirstack_state *ds, char const *fi return RM_ERROR; } @@ -50,7 +50,7 @@ diff -upr src/remove.c src/remove.c struct stat st; cache_stat_init (&st); cycle_check_init (&ds->cycle_check_state); -@@ -1584,6 +1589,7 @@ rm_1 (Dirstack_state *ds, char const *fi +@@ -1587,6 +1592,7 @@ rm_1 (Dirstack_state *ds, char const *fi AD_push_initial (ds); AD_INIT_OTHER_MEMBERS (); @@ -58,7 +58,7 @@ diff -upr src/remove.c src/remove.c enum RM_status status = remove_entry (AT_FDCWD, ds, filename, DT_UNKNOWN, &st, x); if (status == RM_NONEMPTY_DIR) -@@ -1602,6 +1608,8 @@ rm_1 (Dirstack_state *ds, char const *fi +@@ -1605,6 +1611,8 @@ rm_1 (Dirstack_state *ds, char const *fi ds_clear (ds); return status; } 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); |