]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
ls: increase the allowed abmon width from 5 to 12
authorPádraig Brady <P@draigBrady.com>
Wed, 14 Mar 2018 18:31:43 +0000 (11:31 -0700)
committerPádraig Brady <P@draigBrady.com>
Fri, 16 Mar 2018 10:16:43 +0000 (03:16 -0700)
This will impact relatively few languages,
and will make Arabic or Catalan etc.
output unambiguous abbreviated month names.

* src/ls.c (MAX_MON_WIDTH): Increase from 5 to 12.
* NEWS: Mention the bug fix.
* tests/ls/abmon-align.sh: Augment to check for ambiguous output.
Fixes https://bugs.gnu.org/30814

NEWS
src/ls.c
tests/ls/abmon-align.sh

diff --git a/NEWS b/NEWS
index e5569eb4e5d0103e660eba2761f6f69f23fcfee2..351a0827bca8ef42b48285a5d4211e123502b2ba 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -21,6 +21,10 @@ GNU coreutils NEWS                                    -*- outline -*-
   Previously it would have set executable bits on created special files.
   [bug introduced with coreutils-8.20]
 
+  ls no longer truncates the abbreviated month names that have a
+  display width between 6 and 12 inclusive.  Previously this would have
+  output ambiguous months for Arabic or Catalan locales.
+
 ** Improvements
 
   stat and tail now know about the "exfs" file system, which is a
index cd6b09c8e847a6031ec9a6c75c169f446ca9b61b..c89a22f68b9ce796cdcde266d22764fa93b15533 100644 (file)
--- a/src/ls.c
+++ b/src/ls.c
@@ -1095,8 +1095,11 @@ file_escape_init (void)
    variable width abbreviated months and also precomputing/caching
    the names was seen to increase the performance of ls significantly.  */
 
-/* max number of display cells to use */
-enum { MAX_MON_WIDTH = 5 };
+/* max number of display cells to use.
+   As of 2018 the abmon for Arabic has entries with width 12.
+   It doesn't make much sense to support wider than this
+   and locales should aim for abmon entries of width <= 5.  */
+enum { MAX_MON_WIDTH = 12 };
 /* abformat[RECENT][MON] is the format to use for timestamps with
    recentness RECENT and month MON.  */
 enum { ABFORMAT_SIZE = 128 };
index b639ca933578453c97dd312fd54c10a83cc40eb7..d4ff7087365f740d99b828e2d763e0ac80f699a6 100755 (executable)
@@ -32,17 +32,20 @@ for format in "%b" "[%b" "%b]" "[%b]"; do
     # The sed usage here is slightly different from the original,
     # removing the \(.*\), to avoid triggering misbehavior in at least
     # GNU sed 4.2 (possibly miscompiled) on Mac OS X (Darwin 9.8.0).
-    n_widths=$(
+    months="$(
       LC_ALL=$LOC TIME_STYLE=+"$format" ls -lgG *.ts |
-      LC_ALL=C sed 's/.\{15\}//;s/ ..\.ts$//;s/ /./g' |
+      LC_ALL=C sed 's/.\{15\}//;s/ ..\.ts$//;s/ /./g')"
+    n_widths=$(echo "$months" |
       while read mon; do echo "$mon" | LC_ALL=$LOC wc -L; done |
       uniq | wc -l
     )
+    n_dupes=$(echo "$months" | sort | uniq -d | wc -l)
     test "$n_widths" = "1" || { fail=1; break 2; }
+    test "$n_dupes" = "0" || { fail=1; break 2; }
   done
 done
 if test "$fail" = "1"; then
-   echo "misalignment detected in $LOC locale:"
+   echo "misalignment or ambiguous output in $LOC locale:"
    LC_ALL=$LOC TIME_STYLE=+%b ls -lgG *.ts
 fi