Index: libc/include/string.h =================================================================== RCS file: /cvs/src/src/newlib/libc/include/string.h,v retrieving revision 1.15 diff -u -u -b -r1.15 string.h --- libc/include/string.h 24 Jan 2005 18:46:08 -0000 1.15 +++ libc/include/string.h 17 Mar 2005 17:16:38 -0000 @@ -62,7 +62,7 @@ char *_EXFUN(_strdup_r,(struct _reent *, const char *)); char *_EXFUN(strndup,(const char *, size_t)); char *_EXFUN(_strndup_r,(struct _reent *, const char *, size_t)); -char *_EXFUN(strerror_r,(int, char *, size_t)); +int _EXFUN(strerror_r,(int, char *, size_t)); size_t _EXFUN(strlcat,(char *, const char *, size_t)); size_t _EXFUN(strlcpy,(char *, const char *, size_t)); int _EXFUN(strncasecmp,(const char *, const char *, size_t)); Index: libc/string/strerror_r.c =================================================================== RCS file: /cvs/src/src/newlib/libc/string/strerror_r.c,v retrieving revision 1.1 diff -u -u -b -r1.1 strerror_r.c --- libc/string/strerror_r.c 24 May 2002 23:44:37 -0000 1.1 +++ libc/string/strerror_r.c 17 Mar 2005 17:16:38 -0000 @@ -7,11 +7,11 @@ ANSI_SYNOPSIS #include - char *strerror_r(int <[errnum]>, char *<[buffer]>, size_t <[n]>); + int strerror_r(int <[errnum]>, char *<[buffer]>, size_t <[n]>); TRAD_SYNOPSIS #include - char *strerror_r(<[errnum]>, <[buffer]>, <[n]>) + int strerror_r(<[errnum]>, <[buffer]>, <[n]>) int <[errnum]>; char *<[buffer]>; size_t <[n]>; @@ -26,11 +26,12 @@ See <> for how strings are mapped to <>. RETURNS -This function returns a pointer to a string. Your application must -not modify that string. +This function returns 0 on success and ERANGE if there is insufficient +storage. PORTABILITY -<> is a gnu extension. +<> is required by the Thread-Safe Functions option of +POSIX 1003.1, 2001 Edition. <> requires no supporting OS subroutines. @@ -40,7 +41,7 @@ #include #include -char * +int _DEFUN (strerror_r, (errnum, buffer, n), int errnum _AND char *buffer _AND @@ -48,6 +49,6 @@ { char *error; error = strerror (errnum); - - return strncpy (buffer, (const char *)error, n); + strncpy (buffer, error, n); + return strlen (error) + 1 > n ? ERANGE : 0; } Index: libc/sys/linux/argp/argp-help.c =================================================================== RCS file: /cvs/src/src/newlib/libc/sys/linux/argp/argp-help.c,v retrieving revision 1.1 diff -u -u -b -r1.1 argp-help.c --- libc/sys/linux/argp/argp-help.c 29 Aug 2002 23:53:06 -0000 1.1 +++ libc/sys/linux/argp/argp-help.c 17 Mar 2005 17:16:38 -0000 @@ -1,5 +1,5 @@ /* Hierarchial argument parsing help output - Copyright (C) 1995-2000, 2001 Free Software Foundation, Inc. + Copyright (C) 1995-2000, 2001, 2005 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Miles Bader . @@ -1833,14 +1833,17 @@ #ifdef USE_IN_LIBIO if (_IO_fwide (stream, 0) > 0) - __fwprintf (stream, L": %s", - strerror_r (errnum, buf, sizeof (buf))); + { + strerror_r (errnum, buf, sizeof (buf)); + __fwprintf (stream, L": %s", buf); + } else #endif { putc_unlocked (':', stream); putc_unlocked (' ', stream); - fputs (strerror_r (errnum, buf, sizeof (buf)), stream); + strerror_r (errnum, buf, sizeof (buf)); + fputs (buf, stream); } }