]> git.ipfire.org Git - thirdparty/coreutils.git/commit
stat: optimize and translate default format strings
authorEric Blake <eblake@redhat.com>
Fri, 1 Oct 2010 17:44:05 +0000 (11:44 -0600)
committerEric Blake <eblake@redhat.com>
Fri, 1 Oct 2010 21:24:39 +0000 (15:24 -0600)
commit2c14ec962a46ae53d39149112ae6902ed771d497
tree12e5f290f2d543e6155894bf6339a398768030ee
parent9069af45e691d1252c727da66aa4f3f3c7f1ea29
stat: optimize and translate default format strings

Yes, this patch intentionally leaks the results of default_format(),
since it is called only twice, and since the results are in scope
until main() exits.  Not worth the extra code to pacify valgrind.

* src/stat.c (main): Hoist default format computation out of loop.
(do_statfs, do_stat): Move default format generation...
(default_format): ...into new function.  Allocate the result in
pieces, rather than repeating mostly-similar chunks.  Allow
translation of verbose format.  Pass a second format to do_stat,
for the one aspect of the default format that is conditional on
file type.
* NEWS: Document the translation aspect.
NEWS
src/stat.c