]> git.ipfire.org Git - thirdparty/coreutils.git/commit
ls: fix %%b format and precompute more
authorPaul Eggert <eggert@cs.ucla.edu>
Mon, 19 Sep 2016 19:36:18 +0000 (12:36 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Mon, 19 Sep 2016 19:48:32 +0000 (12:48 -0700)
commit1db94ee969b984bbd00b97c6abbe2f69db8e0000
treefcd52754a6a4337e07e4996cb6cf37939e2655f0
parente0953783024a113b186547aca186777f9ce3b798
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
src/ls.c
tests/misc/time-style.sh