]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
ls: better align month abbreviations containing digits
authorDaming Yang <lion@aosc.io>
Tue, 19 Feb 2019 04:04:08 +0000 (20:04 -0800)
committerPádraig Brady <P@draigBrady.com>
Tue, 19 Feb 2019 04:06:05 +0000 (20:06 -0800)
* src/ls.c (abmon_init): Align numeric abbreviations right.
* NEWS: Mention the improvement.

NEWS
src/ls.c

diff --git a/NEWS b/NEWS
index fdde47593b2979f3a548b2ed073be66fa3911ded..e400554bbb41638588d222aabba005e05e79db43 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -75,6 +75,9 @@ GNU coreutils NEWS                                    -*- outline -*-
 
 ** Improvements
 
+  ls -l now better aligns abbreviated months containing digits,
+  which is common in Asian locales.
+
   stat and tail now know about the "sdcardfs" file system on Android.
   stat -f -c%T now reports the file system type, and tail -f uses inotify.
 
index 243c1860a34cc5829e3a837b0a0befc52481cbd1..120ce153e34036975ec4991af217711c437d69bd 100644 (file)
--- a/src/ls.c
+++ b/src/ls.c
@@ -1131,8 +1131,10 @@ abmon_init (char abmon[12][ABFORMAT_SIZE])
           char const *abbr = nl_langinfo (ABMON_1 + i);
           if (strchr (abbr, '%'))
             return false;
+          mbs_align_t alignment = isdigit (to_uchar (*abbr))
+                                  ? MBS_ALIGN_RIGHT : MBS_ALIGN_LEFT;
           size_t req = mbsalign (abbr, abmon[i], ABFORMAT_SIZE,
-                                 &width, MBS_ALIGN_LEFT, 0);
+                                 &width, alignment, 0);
           if (! (req < ABFORMAT_SIZE))
             return false;
           required_mon_width = MAX (required_mon_width, width);