Mercurial > hg > octave-kai > gnulib-hg
changeset 14270:9dc44fa092bd
strerror_r-posix: port to cygwin
* lib/strerror_r.c (strerror_r) [__CYGWIN__]: Add cygwin
implementation.
* m4/strerror_r.m4 (gl_FUNC_STRERROR_R): Adjust comment.
* tests/test-strerror_r.c (main): Fix test.
* doc/posix-functions/strerror_r.texi (strerror_r): Document the
issue.
Signed-off-by: Eric Blake <eblake@redhat.com>
author | Eric Blake <eblake@redhat.com> |
---|---|
date | Sat, 05 Feb 2011 12:15:59 -0700 |
parents | 2841c44d4d34 |
children | b4cc3c41ca79 |
files | ChangeLog doc/posix-functions/strerror_r.texi lib/strerror_r.c m4/strerror_r.m4 tests/test-strerror_r.c |
diffstat | 5 files changed, 21 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2011-02-05 Eric Blake <eblake@redhat.com> + + strerror_r-posix: port to cygwin + * lib/strerror_r.c (strerror_r) [__CYGWIN__]: Add cygwin + implementation. + * m4/strerror_r.m4 (gl_FUNC_STRERROR_R): Adjust comment. + * tests/test-strerror_r.c (main): Fix test. + * doc/posix-functions/strerror_r.texi (strerror_r): Document the + issue. + 2011-02-05 Bruno Haible <bruno@clisp.org> New module 'wmemchr'.
--- a/doc/posix-functions/strerror_r.texi +++ b/doc/posix-functions/strerror_r.texi @@ -12,7 +12,8 @@ This function is missing on some platforms: NetBSD 3.0, HP-UX 11.23, IRIX 6.5, Solaris 9, mingw. @item -glibc has an incompatible version of this function. The POSIX compliant code +glibc and Cygwin have an incompatible version of this function. The +POSIX compliant code @smallexample char *s = (strerror_r (err, buf, buflen) == 0 ? buf : NULL); @end smallexample
--- a/lib/strerror_r.c +++ b/lib/strerror_r.c @@ -27,7 +27,7 @@ #if HAVE_DECL_STRERROR_R && !(__GLIBC__ >= 2 || defined __UCLIBC__) && !EXTEND_STRERROR_R /* The system's strerror_r function is OK, except that its third argument - is 'int', not 'size_t'. */ + is 'int', not 'size_t', or its return type is wrong. */ # include <limits.h> @@ -61,6 +61,11 @@ else ret = strerror_r (errnum, buf, buflen); } +# elif defined __CYGWIN__ + /* Cygwin only provides the glibc interface, is thread-safe, and + always succeeds (although it may truncate). */ + strerror_r (errnum, buf, buflen); + ret = 0; # else ret = strerror_r (errnum, buf, buflen); # endif
--- a/m4/strerror_r.m4 +++ b/m4/strerror_r.m4 @@ -24,7 +24,7 @@ if test $ac_cv_func_strerror_r = yes; then if test -z "$ERRNO_H"; then dnl The POSIX prototype is: int strerror_r (int, char *, size_t); - dnl glibc's prototype: char *strerror_r (int, char *, size_t); + dnl glibc, Cygwin: char *strerror_r (int, char *, size_t); dnl AIX 5.1, OSF/1 5.1: int strerror_r (int, char *, int); AC_CACHE_CHECK([for strerror_r with POSIX signature], [gl_cv_func_strerror_r_posix_signature],
--- a/tests/test-strerror_r.c +++ b/tests/test-strerror_r.c @@ -74,8 +74,8 @@ if (ret == 0) { /* Truncated result. POSIX allows this, and it actually - happens on AIX 6.1. */ - ASSERT (strcmp (buf, "BADFACE") != 0); + happens on AIX 6.1 and Cygwin. */ + ASSERT ((strcmp (buf, "BADFACE") == 0) == (i == 0)); } else {