From 1db94ee969b984bbd00b97c6abbe2f69db8e0000 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 19 Sep 2016 12:36:18 -0700 Subject: ls: fix %%b format and precompute more The old code mishandled --time-spec='+%%b', as it misinterpreted the '%b' as being the month abbreviation. Also, it mishandled the extremely unlikely case of a month abbreviation containing '%'. The performance part of this patch sped up 'ls' by about 1% on my little benchmark of 'ls -lR' on the source directory in the en_US.UTF-8 locale (Fedora 24 x86-64). * NEWS: Document the bug fix. * src/ls.c (first_percent_b, abformat_init): New static functions. (ABFORMAT_SIZE): New constant. (use_abformat): New static var. (abmon, required_mon_width): Remove these static vars. (abmon_init): Now accepts a pointer to abmon, and returns a boolean. All callers changed. Reject month abbrs containing '%', as these would mess up strftime. Simplify mbsalign result checking, since (size_t) -1 exceeds ABFORMAT_SIZE. (abformat_init, align_nstrftime): Precompute all 24 formats at startup, rather than computing a format for each time stamp. (decode_switches): Call abformat_init instead of abmon_init. (align_nstrftime): Accept recentness bool instead of format. All callers changed. * tests/misc/time-style.sh: Test for format with '%%b'. --- NEWS | 3 +++ 1 file changed, 3 insertions(+) (limited to 'NEWS') diff --git a/NEWS b/NEWS index 580c5f4d7..beba7742e 100644 --- a/NEWS +++ b/NEWS @@ -25,6 +25,9 @@ GNU coreutils NEWS -*- outline -*- factor again outputs immediately when numbers are input interactively. [bug introduced in coreutils-8.24] + ls --time-style no longer mishandles '%%b' in formats. + [bug introduced in coreutils-7.2] + nl now resets numbering for each page section rather than just for each page. [This bug was present in "the beginning".] -- cgit v1.2.3-70-g09d2