[PATCH] stdio: Add %m
Shaun Jackman
sjackman at gmail.com
Mon Jun 5 16:49:38 UTC 2006
This patch to newlib adds the %m format, which outputs
strerror(errno). This format is a glibc extension. I'm not usually a
champion of non-standard extensions to any libc. However, this
particular extension is used fairly widely and is mostly non-invasive.
In particular, busybox uses %m and the maintainers will not accept
patches converting this format to %s and strerror(errno) due to the
latter taking more space by making, typically, two additional function
calls -- one to __errno_location and one to strerror.
Cheers,
Shaun
2006-06-05 Shaun Jackman <sjackman at gmail.com>
* newlib/libc/stdio/vfprintf.c (_vfprintf_r, _vfiprintf_r): Add
the %m format, which outputs strerror(errno). This format is a
glibc extension.
Index: newlib/libc/stdio/vfprintf.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/stdio/vfprintf.c,v
retrieving revision 1.43
diff -u -r1.43 vfprintf.c
--- newlib/libc/stdio/vfprintf.c 28 Oct 2005 21:38:59 -0000 1.43
+++ newlib/libc/stdio/vfprintf.c 5 Jun 2006 16:34:50 -0000
@@ -905,6 +905,10 @@
sign = '-';
break;
#endif /* FLOATING_POINT */
+ case 'm': /* glibc extension */
+ cp = strerror(errno);
+ size = strlen(cp);
+ break;
case 'n':
#ifndef _NO_LONGLONG
if (flags & QUADINT)
-------------- next part --------------
2006-06-05 Shaun Jackman <sjackman at gmail.com>
* newlib/libc/stdio/vfprintf.c (_vfprintf_r, _vfiprintf_r): Add
the %m format, which outputs strerror(errno). This format is a
glibc extension.
Index: newlib/libc/stdio/vfprintf.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/stdio/vfprintf.c,v
retrieving revision 1.43
diff -u -r1.43 vfprintf.c
--- newlib/libc/stdio/vfprintf.c 28 Oct 2005 21:38:59 -0000 1.43
+++ newlib/libc/stdio/vfprintf.c 5 Jun 2006 16:34:50 -0000
@@ -905,6 +905,10 @@
sign = '-';
break;
#endif /* FLOATING_POINT */
+ case 'm': /* glibc extension */
+ cp = strerror(errno);
+ size = strlen(cp);
+ break;
case 'n':
#ifndef _NO_LONGLONG
if (flags & QUADINT)
More information about the busybox
mailing list