[PATCH] ash: avoid GLIBC'ism %m

Markus Gothe nietzsche at lysator.liu.se
Wed Jul 19 18:34:14 UTC 2017


Look over here http://pubs.opengroup.org/onlinepubs/9699919799/functions/scanf.html instead:

[CX]  The %c, %s, and %[ conversion specifiers shall accept an optional assignment-allocation character 'm', which shall cause a memory buffer to be allocated to hold the string converted including a terminating null character. In such a case, the argument corresponding to the conversion specifier should be a reference to a pointer variable that will receive a pointer to the allocated buffer. The system shall allocate a buffer as if malloc() had been called. The application shall be responsible for freeing the memory after usage. If there is insufficient memory to allocate a buffer, the function shall set errno to [ENOMEM] and a conversion error shall result. If the function returns EOF, any memory successfully allocated for parameters using assignment-allocation character 'm' by this call shall be freed before the function returns.

I rest my case…

//Markus - The panama-hat hacker

On 19 Jul 2017, at 03:47 , Jody Bruchon <jody at jodybruchon.com> wrote:

> On 2017-07-18 9:15 PM, Kang-Che Sung wrote:
>> On Wed, Jul 19, 2017 at 2:11 AM, Markus Gothe <nietzsche at lysator.liu.se> wrote:
>>> Actually last time I checked ‘%m’ is POSIX contrary to glibc’s deprecated '%a’. However, I agree that it should not be used since at least uClibc can be built without support for it.
>> How come %m is POSIX when I didn't see any mention of it in this page? http://pubs.opengroup.org/onlinepubs/9699919799/functions/fprintf.html
> It does not appear to be part of POSIX or the Single UNIX Specification. The glibc man page (as of 2016-12-12) even indicates that it is a glibc-specific extension:
> 
> *m *(Glibc extension; supported by uClibc and musl.) Print output of /strerror(errno)/. No argument is required.
> 
> The Gnulib manual has a pretty nice page mentioning several printf() incompatibilities and the operating systems they don't play nicely with: https://www.gnu.org/software/gnulib/manual/html_node/fprintf.html
> 
> 
> -Jody Bruchon
> _______________________________________________
> busybox mailing list
> busybox at busybox.net
> http://lists.busybox.net/mailman/listinfo/busybox

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/busybox/attachments/20170719/3aaeea6c/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: opt-start.gif
Type: image/gif
Size: 69 bytes
Desc: not available
URL: <http://lists.busybox.net/pipermail/busybox/attachments/20170719/3aaeea6c/attachment-0002.gif>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: opt-end.gif
Type: image/gif
Size: 65 bytes
Desc: not available
URL: <http://lists.busybox.net/pipermail/busybox/attachments/20170719/3aaeea6c/attachment-0003.gif>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 824 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.busybox.net/pipermail/busybox/attachments/20170719/3aaeea6c/attachment-0001.asc>


More information about the busybox mailing list