ash: support platforms that don't have '%m' printf specifier
authorRon Yorston <rmy@pobox.com>
Thu, 27 Jul 2017 12:53:39 +0000 (13:53 +0100)
committerDenys Vlasenko <vda.linux@googlemail.com>
Fri, 28 Jul 2017 13:39:26 +0000 (15:39 +0200)
commitbe366e5afac1d9f5b3958bd3899a389308d5d9d3
tree60c41a15eed758d0cee5a637c063fe53eff36046
parent619d9b5e6848a72350126ea9c1e413fd133181e3
ash: support platforms that don't have '%m' printf specifier

The '%m' conversion specifier prints an error message based on the
current value of 'errno'.  It is available in the GNU C library,
Cygwin (since 2012), uClibc and musl.

It is not available in various BSDs, BSD-derived systems (MacOS,
Android) or Microsoft Windows.

Use a symbol defined in platform.h to control how error messages
can be formatted to display the 'errno' message.  On platforms that
support it use '%m'; on other platforms use '%s' and strerror().

On platforms that have '%m' there is essentially no change in the
size of the binary.  Otherwise:

function                                             old     new   delta
redirect                                            1287    1310     +23
xtcsetpgrp                                            27      44     +17
dup2_or_raise                                         34      51     +17
setinputfile                                         267     275      +8
.rodata                                           163379  163371      -8
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/1 up/down: 65/-8)              Total: 57 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
include/platform.h
shell/ash.c