This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
Re: Portability fix for argp/argp.h.
- From: Simon Josefsson <jas at extundo dot com>
- To: libc-alpha at sources dot redhat dot com
- Date: Thu, 10 Jul 2003 12:12:15 +0200
- Subject: Re: Portability fix for argp/argp.h.
- References: <iluadcno9vu.fsf@latte.josefsson.org><iluptkik88b.fsf@latte.josefsson.org>
Simon Josefsson <jas@extundo.com> writes:
> @@ -1813,13 +1830,21 @@ __argp_failure (const struct argp_state
> #ifdef USE_IN_LIBIO
> if (_IO_fwide (stream, 0) > 0)
> __fwprintf (stream, L": %s",
> +#if defined _LIBC
> __strerror_r (errnum, buf, sizeof (buf)));
> +#else
> + __fwprintf (stream, L": %s", strerror (errnum));
> +#endif
> else
> #endif
Sigh, this was clearly broken. Here's a new patch for argp-help.c.
Index: argp-help.c
===================================================================
RCS file: /cvs/glibc/libc/argp/argp-help.c,v
retrieving revision 1.37
diff -u -p -u -w -r1.37 argp-help.c
--- argp-help.c 13 Jun 2003 20:38:13 -0000 1.37
+++ argp-help.c 10 Jul 2003 10:20:48 -0000
@@ -50,7 +50,6 @@ char *alloca ();
#include <string.h>
#include <assert.h>
#include <stdarg.h>
-#include <malloc.h>
#include <ctype.h>
#ifdef USE_IN_LIBIO
# include <wchar.h>
@@ -70,6 +69,24 @@ char *alloca ();
# endif
#endif
+#ifndef __attribute
+# define __attribute(xyz) /* Ignore */
+#endif
+
+#ifndef __strchrnul
+# define __strchrnul strchrnul
+#endif
+
+#ifndef __strndup
+# define __strndup strndup
+#endif
+
+#ifndef _LIBC
+# if !HAVE_DECL_STRERROR
+char *strerror ();
+# endif
+#endif
+
#include "argp.h"
#include "argp-fmtstream.h"
#include "argp-namefrob.h"
@@ -1812,14 +1829,22 @@ __argp_failure (const struct argp_state
#ifdef USE_IN_LIBIO
if (_IO_fwide (stream, 0) > 0)
+#if defined _LIBC
__fwprintf (stream, L": %s",
__strerror_r (errnum, buf, sizeof (buf)));
+#else
+ __fwprintf (stream, L": %s", strerror (errnum));
+#endif
else
#endif
{
putc_unlocked (':', stream);
putc_unlocked (' ', stream);
+#if defined _LIBC
fputs (__strerror_r (errnum, buf, sizeof (buf)), stream);
+#else
+ fputs (strerror (errnum), stream);
+#endif
}
}