>From b75ed390aa86a3bb44f003ed9961a14613a1b6d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draig=20Brady?= Date: Mon, 17 Jun 2019 16:02:51 +0100 Subject: [PATCH] ls: align mixed user IDs left * src/ls.c [id_alignment]: A new global that is reset to align left upon successful user name or group lookup. Addresses https://bugs.gnu.org/36220 --- src/ls.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ls.c b/src/ls.c index 120ce15..0e2c46a 100644 --- a/src/ls.c +++ b/src/ls.c @@ -505,6 +505,9 @@ static bool print_group = true; static bool numeric_ids; +/* Default to numeric right alignment, but reset upon name lookup. */ +static mbs_align_t id_alignment = MBS_ALIGN_RIGHT; + /* True means mention the size in blocks of each file. -s */ static bool print_block_size; @@ -3943,7 +3946,7 @@ format_user_or_group (char const *name, unsigned long int id, int width) } else { - printf ("%*lu ", width, id); + printf ("%*lu ", width * (id_alignment == MBS_ALIGN_LEFT ? -1 : 1), id); len = width; } @@ -3976,6 +3979,7 @@ format_user_or_group_width (char const *name, unsigned long int id) { if (name) { + id_alignment = MBS_ALIGN_LEFT; int len = mbswidth (name, 0); return MAX (0, len); } -- 2.9.3