This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Portability fix for argp/argp.h.


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
 		}
 	    }
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]