lib/strerror_r.c


Log

Author Commit Date CI Message
Bruno Haible 1b612639 2012-01-04T14:31:33 Talk about "native Windows API", not "Win32". * lib/classpath.c: Update comments to mention native Windows. * lib/csharpexec.c: Likewise. * lib/dup2.c: Likewise. * lib/error.c: Likewise. * lib/fcntl.c: Likewise. * lib/filename.h: Likewise. * lib/findprog.c: Likewise. * lib/get-rusage-as.c: Likewise. * lib/get-rusage-data.c: Likewise. * lib/getpagesize.c: Likewise. * lib/javaexec.c: Likewise. * lib/msvc-inval.c: Likewise. * lib/msvc-nothrow.c: Likewise. * lib/nanosleep.c: Likewise. * lib/nonblocking.c: Likewise. * lib/printf-parse.c: Likewise. * lib/setlocale.c: Likewise. * lib/sigaction.c: Likewise. * lib/strerror_r.c: Likewise. * lib/tmpdir.c: Likewise. * lib/vasnprintf.c: Likewise. * lib/w32spawn.h: Likewise. * lib/waitpid.c: Likewise. * lib/stdio.in.h (fdopen, fopen, freopen): Likewise. * m4/locale-ar.m4: Likewise. * m4/locale-fr.m4: Likewise. * m4/locale-ja.m4: Likewise. * m4/locale-tr.m4: Likewise. * m4/locale-zh.m4: Likewise. * m4/printf.m4: Likewise. * tests/test-cloexec.c: Likewise. * tests/test-copy-acl.sh: Likewise. * tests/test-copy-file.sh: Likewise. * tests/test-file-has-acl.sh: Likewise. * tests/test-set-mode-acl.sh: Likewise. * tests/test-dup-safer.c: Likewise. * tests/test-dup2.c: Likewise. * tests/test-dup3.c: Likewise. * tests/test-fcntl.c: Likewise. * tests/test-nonblocking-pipe.h: Likewise. * tests/test-nonblocking-socket.h: Likewise. * tests/test-pipe.c: Likewise. * tests/test-pipe2.c: Likewise. * tests/test-spawn-pipe-child.c: Likewise. * doc/acl-resources.txt: Likewise. * lib/getaddrinfo.c (WINDOWS_NATIVE): Renamed from WIN32_NATIVE. * tests/test-poll.c (WINDOWS_NATIVE): Likewise. * tests/test-select.h (WINDOWS_NATIVE): Likewise. * lib/localcharset.c: Update comments to mention native Windows. (WINDOWS_NATIVE): Renamed from WIN32_NATIVE. * lib/localename.c: Likewise. * lib/progreloc.c: Likewise. * lib/relocatable.c: Likewise. * lib/poll.c (WINDOWS_NATIVE): Renamed from WIN32_NATIVE. (windows_compute_revents): Renamed from win32_compute_revents. (windows_compute_revents_socket): Renamed from win32_compute_revents_socket. * lib/select.c: Update comments to mention native Windows. (windows_poll_handle): Renamed from win32_poll_handle. * m4/threadlib.m4: Update comments to mention native Windows. (gl_THREADLIB_EARLY_BODY, gl_THREADLIB_BODY): Expect --enable-threads=windows instead of --enable-threads=win32. Set USE_WINDOWS_THREADS, not USE_WIN32_THREADS. * lib/glthread/lock.h: Update comments to mention native Windows. (USE_WINDOWS_THREADS): Renamed from USE_WIN32_THREADS. * lib/glthread/lock.c (USE_WINDOWS_THREADS): Renamed from USE_WIN32_THREADS. * lib/glthread/cond.h (USE_WINDOWS_THREADS): Likewise. * lib/glthread/cond.c (USE_WINDOWS_THREADS): Likewise. * lib/glthread/thread.h (USE_WINDOWS_THREADS): Likewise. * lib/glthread/thread.c (USE_WINDOWS_THREADS): Likewise. * lib/glthread/tls.h (USE_WINDOWS_THREADS): Likewise. * lib/glthread/tls.c (USE_WINDOWS_THREADS): Likewise. * lib/glthread/yield.h (USE_WINDOWS_THREADS): Likewise. * tests/test-cond.c (USE_WINDOWS_THREADS): Likewise. * tests/test-thread_create.c (USE_WINDOWS_THREADS): Likewise. * tests/test-lock.c (USE_WINDOWS_THREADS): Likewise. (TEST_WINDOWS_THREADS): Renamed from TEST_WIN32_THREADS. * tests/test-tls.c: Likewise. Rationale: Microsoft renamed the "Win32 API" to "Windows API", as it is available on both 32-bit and 64-bit Windows systems. But in gnulib, we treat Cygwin like a Unix platform, therefore the main line of distinction is between "native Windows" on one side and Unix/ POSIX systems on the other side. More details in <https://lists.gnu.org/archive/html/bug-gnulib/2012-01/msg00027.html>. Suggested by Paul Eggert.
Jim Meyering 1602f0af 2012-01-01T10:04:58 maint: update all copyright year number ranges Run "make update-copyright".
Bruno Haible c6ca5b79 2011-09-25T14:54:47 strerror_r-posix: Fix for MSVC 9. * lib/strerror_r.c (local_snprintf): New function. (snprintf): Define to local_snprintf, not to _snprintf.
Bruno Haible 4fe7feb9 2011-09-23T00:13:29 strerror_r-posix: Avoid a link error on MSVC. * m4/strerror_r.m4 (gl_PREREQ_STRERROR_R): Check for snprintf. * lib/strerror_r.c (snprintf): Define to _snprintf if it doesn't exist.
Eric Blake 23d3c1a2 2011-06-21T10:00:55 strerror_r: fix OpenBSD behavior on out-of-range On OpenBSD, strerror_r(1000,buf,19) gives "Unknown error: " rather than "Unknown error: 100" while failing with ERANGE. Admittedly, this behavior is nice, since a truncated integer is misleading, but all other platforms use maximal strings on ERANGE and we are already replacing strerror_r for other reasons, so it is easier to work around this behavior than to adjust the testsuite (how do you quickly decide if the only reason that the ERANGE string was shorter than maximal was because the implementation avoided truncating an integer?). This patch intentionally avoids dragging in the strnlen module. * lib/strerror_r.c (strerror_r): Always use maximal string. * doc/posix-functions/strerror_r.texi (strerror_r): Document it. Signed-off-by: Eric Blake <eblake@redhat.com>
Eric Blake c7487319 2011-06-21T08:50:51 strerror_r: fix OpenBSD behavior on 0 OpenBSD treats strerror_r(0,,) as a success, but with a message "Undefined error: 0"; while this is distinct from strerror_r(-1,,) returning "Unknown error: -1", it does not imply success. Meanwhile, if buf is short enough for ERANGE, then we can't use strstr to look for "Unknown" or "Undefined" in the resulting message, like we had been doing for strerror(). Fix this by shifting the burden - now the strerror-override code guarantees that 0 will have an override when needed. * lib/strerror-override.c (strerror_override): Also override 0 when needed. * lib/strerror-override.h (strerror_override): Likewise. * lib/strerror.c (strerror): Simplify, now that 0 override is done earlier. * lib/strerror_r.c (strerror_r): Likewise. * m4/strerror.m4 (gl_FUNC_STRERROR): Split detection of 0 behavior... (gl_FUNC_STRERROR_0): ...into new macro. * m4/strerror_r.m4 (gl_FUNC_STRERROR_R): Replace strerror_r if 0 is overridden. (gl_FUNC_STRERROR_R_WORKS): Avoid extra tests if 0 is broken. * modules/strerror-override (Files): Add strerror.m4. (configure.ac): Also provide override for 0 when needed. * doc/posix-functions/strerror.texi (strerror): Document this. * doc/posix-functions/perror.texi (perror): Likewise. Signed-off-by: Eric Blake <eblake@redhat.com>
Eric Blake 79d4e75d 2011-06-07T20:49:04 strerror_r-posix: fix on MacOS MacOS X 10.5 strerror(0) is "Unknown error: 0", which is not distinguished from "Unknown error: -1" for out-of-range. Worse, strerror_r(0,,) is "Undefined error: 0", although strerror_r for all other out-of-range values matches strerror. * m4/strerror.m4 (gl_FUNC_STRERROR): Flush out MacOS bug. * m4/strerror_r.m4 (gl_FUNC_STRERROR_R_WORKS): Likewise, and fix logic bug. * lib/strerror_r.c (strerror_r): Fix the bug. * lib/strerror.c (strerror): Likewise. * doc/posix-functions/strerror_r.texi (strerror_r): Document the problem. * doc/posix-functions/strerror.texi (strerror): Likewise. * doc/posix-functions/perror.texi (perror): Likewise. * tests/test-strerror.c (main): Enhance test. * tests/test-strerror_r.c (main): Likewise. Signed-off-by: Eric Blake <eblake@redhat.com>
Bruno Haible 23b18247 2011-06-04T13:01:55 strerror_r: Fix comments. * lib/strerror_r.c (strerror_r): Update comments after 2011-06-01 commit.
Eric Blake 63ce57e7 2011-05-24T15:33:49 strerror: drop strerror_r dependency Since the errno module is responsible for introducing replacement errno values, it should also be responsible for translating those new values into strings. And by moving the replacements into a file managed by the errno, we can then break the dependency between strerror and strerror_r, so that strerror no longer drags in multi-threading modules required by strerror_r. Tested on glibc with: gl_cv_header_errno_h_complete=no gl_cv_func_working_strerror=no \ gl_cv_func_strerror_r_works=no ./gnulib-tool --with-tests \ --test strerror strerror_r-posix * lib/strerror_r.c (strerror_r): Move gnulib replacement strings... * lib/strerror-override.c (strerror_override): ...to new file. * lib/strerror-override.h: Add prototype. * lib/strerror-impl.h: Delete. * lib/strerror.c (strerror): New implementation. * modules/errno (Files): Add new files. (configure.ac): Compile new file as appropriate. * modules/strerror (Files): Drop unused file. (Depends-on): Drop strerror_r-posix. * MODULES.html.sh: Document strerror_r-posix. Requested by Sam Steingold. Signed-off-by: Eric Blake <eblake@redhat.com>
Eric Blake 90a65c17 2011-06-01T08:14:34 strerror_r: fix includes for FreeBSD * lib/strerror_r.c (includes): Use <stdlib.h> unconditionally, since we use abort on some platforms. Reported by Matthias Bolte. Signed-off-by: Eric Blake <eblake@redhat.com>
Eric Blake 4131aa89 2011-05-24T14:30:38 strerror_r: fix missing header snprintf is not guaranteed to work without a declaration. * lib/strerror_r.c: Avoid compiler warning about snprintf. Signed-off-by: Eric Blake <eblake@redhat.com>
Eric Blake 8ea7a672 2011-05-23T21:37:11 strerror_r: fix AIX test failures Already documented as an AIX limitation. * lib/strerror_r.c (strerror_r): Convert silent truncation to ERANGE failure. Signed-off-by: Eric Blake <eblake@redhat.com>
Eric Blake e67e250d 2011-05-23T21:05:07 strerror_r: fix Solaris test failures Solaris 10 populates buf on EINVAL, but not on ERANGE. * lib/strerror_r.c (strerror_r): Partially populate buf on ERANGE failures. * doc/posix-functions/strerror_r.texi (strerror_r): Document this. Signed-off-by: Eric Blake <eblake@redhat.com>
Eric Blake 3a3fe58b 2011-05-18T15:19:51 strerror_r: enforce POSIX recommendations POSIX recommends (but does not require) that strerror_r populate buf even on error. But since we guarantee this behavior for strerror, we might as well also guarantee it for strerror_r. * lib/strerror_r.c (safe_copy): New helper method. (strerror_r): Guarantee a non-empty string. * tests/test-strerror_r.c (main): Enhance tests to incorporate recent POSIX rulings and to match our strerror guarantees. * doc/posix-functions/strerror_r.texi (strerror_r): Document this. Signed-off-by: Eric Blake <eblake@redhat.com>
Bruno Haible 29ab5525 2011-05-22T04:23:33 strerror_r: Fix comments. * lib/strerror_r.c (strerror_r): Fix comment about Cygwin and sys_nerr.
Eric Blake 2f035758 2011-05-21T10:08:28 strerror_r: avoid clobbering strerror on cygwin Avoid cygwin strerror_r, since it clobbers strerror buffer through cygwin 1.7.9. __xpg_strerror_r is okay, but if a program is compiled on cygwin 1.7.8 or earlier, it is not available. * lib/strerror_r.c (strerror_r): Don't use cygwin's strerror_r; fall back instead to sys_errlist. * modules/strerror (configure.ac): Add witness. * tests/test-strerror_r.c (main): Enhance test. * doc/posix-functions/strerror_r.texi (strerror_r): Document it. * tests/test-perror2.c (main): Free memory before exit. Signed-off-by: Eric Blake <eblake@redhat.com>
Eric Blake 9d9ff211 2011-05-20T15:19:05 strerror_r: simplify AIX code. * lib/strerror_r.c (strerror_r): Filter out buflen of 1 up front. Signed-off-by: Eric Blake <eblake@redhat.com>
Bruno Haible 4f4a5730 2011-05-20T04:01:43 strerror_r: Work around strerror_r() change in Cygwin 1.7.8. * lib/strerror_r.c (strerror_r) [CYGWIN]: Recognize when the system's strerror_r() returned without filling the buffer. Reported by Eric Blake.
Eric Blake 7f4877b4 2011-05-19T13:35:39 strerror_r: guarantee unchanged errno POSIX guarantees that strerror doesn't change errno on success, and since we implement strerror by using strerror_r, it makes sense to make the same guarantee for strerror_r (rather, going one step further to say that sterror_r does not corrupt errno, since it returns an error value explicitly). See also http://austingroupbugs.net/view.php?id=447 * lib/strerror_r.c (strerror_r): Guarantee unchanged errno. * lib/strerror-impl.h (strerror): Set errno to match strerror_r failure. * tests/test-strerror_r.c (main): Enhance test. Signed-off-by: Eric Blake <eblake@redhat.com>
Bruno Haible e18f296f 2011-05-19T21:59:46 strerror_r: Reorder #if blocks. * lib/strerror_r.c (strerror_r): Reorder conditionals in the function for consistency with the previous commit.
Eric Blake b79d3483 2011-05-19T12:51:36 strerror_r: fix on newer cygwin * lib/strerror_r.c (rpl_strerror_r): Cygwin now has __xpg_strerror_r, use it. Signed-off-by: Eric Blake <eblake@redhat.com>
Bruno Haible f99411b3 2011-05-19T20:57:21 strerror_r: Avoid clobbering the strerror buffer when possible. * lib/strerror.c: Define _NETBSD_SOURCE. Include <nl_types.h>. (sys_nerr, sys_errlist): New declarations. (strerror_r): Be careful not to clobber the strerror buffer on NetBSD, HP-UX, native Win32, IRIX, and 32-bit Solaris. * m4/strerror_r.m4 (gl_PREREQ_STRERROR_R): Test whether catgets exists.
Bruno Haible 4fe68d41 2011-05-19T20:45:59 strerror_r: Fix test failure on mingw. * m4/strerror_r.m4 (gl_FUNC_STRERROR_R): Don't define EXTEND_STRERROR_R. * lib/strerror_r.c (strerror_r): Test the various GNULIB_defined_* macros from errno.in.h instead.
Eric Blake 1608fbc0 2011-05-18T18:16:59 strerror: enforce POSIX ruling on strerror(0) http://austingroupbugs.net/view.php?id=382 requires that strerror(0) succeed, but FreeBSD reports "Unknown error: 0" and fails with EINVAL. * m4/strerror.m4 (gl_FUNC_STRERROR_SEPARATE): Expose BSD bug. * m4/strerror_r.m4 (gl_FUNC_STRERROR_R): Likewise. * lib/strerror_r.c (rpl_strerror_r): Work around it. * doc/posix-functions/strerror.texi (strerror): Document it. * doc/posix-functions/strerror_r.texi (strerror_r): Likewise. * tests/test-strerror.c (main): Strengthen test. * tests/test-strerror_r.c (main): Likewise. Signed-off-by: Eric Blake <eblake@redhat.com>
Bruno Haible d3455c00 2011-05-19T05:24:33 strerror_r: Avoid clobbering the strerror buffer when possible. * lib/strerror_r.c (strerror_r): Merge the three implementations. Handle gnulib defined errno values here. When strerror() returns NULL or an empty string, return EINVAL. * lib/strerror.c (strerror): Always call strerror_r. Don't handle gnulib defined errno values here. * modules/strerror (Depends-on): Add verify, strerror_r-posix.
Eric Blake cda784e7 2011-02-05T12:15:59 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>
Eric Blake d1e7b7e7 2011-01-21T08:48:39 strerror_r-posix: work with glibc 2.13 * lib/strerror_r.c (strerror_r): Fix return type. Signed-off-by: Eric Blake <eblake@redhat.com>
Jim Meyering d60f3b0c 2011-01-01T20:17:23 maint: update almost all copyright ranges to include 2011 Run the new "make update-copyright" rule.
Bruno Haible 63bc47a1 2010-11-20T18:54:00 Port to uClibc. * lib/relocatable.c (find_shared_library_fullname): Treat uClibc like glibc. * lib/strerror_r.c: Likewise. * m4/arpa_inet_h.m4 (gl_HEADER_ARPA_INET): Likewise. * m4/duplocale.m4 (gl_FUNC_DUPLOCALE): Likewise. * m4/fsusage.m4 (gl_FILE_SYSTEM_USAGE): Likewise. * m4/glibc21.m4 (gl_GLIBC21): Likewise. * tests/test-sigaction.c (handler, main): Likewise. * lib/localename.c (gl_locale_name_thread_unsafe, HAVE_LOCALE_NULL): Treat uClibc like a non-glibc platform. * lib/propername.c (proper_name_utf8): Likewise. * lib/spawn.in.h: Likewise. * lib/striconv.c (mem_cd_iconv, str_cd_iconv, str_iconv): Likewise. * lib/striconveh.c (iconveh_open, iconv_carefully, iconv_carefully_1, mem_cd_iconveh_internal): Likewise. * lib/striconveha.c (mem_iconveha, str_iconveha): Likewise. * lib/string.in.h (memchr, memrchr, rawmemchr, strchrnul, strpbrk, strstr, strcasestr): Likewise. * lib/unicodeio.c (unicode_to_mb): Likewise. * m4/getdelim.m4 (gl_FUNC_GETDELIM): Likewise. * m4/getline.m4 (gl_FUNC_GETLINE): Likewise. * m4/glibc2.m4 (gt_GLIBC2): Likewise. * m4/iconv_open.m4 (gl_FUNC_ICONV_OPEN): Likewise. * m4/memmem.m4 (gl_FUNC_MEMMEM_SIMPLE, gl_FUNC_MEMMEM): Likewise. * m4/printf.m4 (gl_PRINTF_DIRECTIVE_A): Likewise. * m4/strcasestr.m4 (gl_FUNC_STRCASESTR_SIMPLE, gl_FUNC_STRCASESTR): Likewise. * m4/strstr.m4 (gl_FUNC_STRSTR_SIMPLE, gl_FUNC_STRSTR): Likewise. * m4/strtod.m4 (gl_FUNC_STRTOD): Likewise. * m4/sys_ioctl_h.m4 (gl_SYS_IOCTL_H): Likewise. * m4/sys_select_h.m4 (gl_HEADER_SYS_SELECT): Likewise. * m4/sys_socket_h.m4 (gl_HEADER_SYS_SOCKET): Likewise. * m4/sys_times_h.m4 (gl_SYS_TIMES_H): Likewise. * m4/unistd_h.m4 (gl_UNISTD_H): Likewise. * m4/wchar_h.m4 (gl_WCHAR_H): Likewise. * tests/test-getopt.h (OPTIND_MIN): Likewise. * tests/test-striconveha.c (main): Likewise. * doc/posix-functions/getdelim.texi: Mention an uClibc bug. * doc/posix-functions/getline.texi: Likewise. Reported by Mike Frysinger <vapier@gentoo.org>.
Bruno Haible 18384947 2010-11-11T13:15:28 New module 'strerror_r-posix'. * lib/string.in.h (strerror_r): New declaration. * lib/strerror_r.c: New file. * m4/strerror_r.m4: New file. * m4/string_h.m4 (gl_HEADER_STRING_H_BODY): Check for the declaration of strerror_r. (gl_HEADER_STRING_H_DEFAULTS): Initialize GNULIB_STRERROR_R, HAVE_DECL_STRERROR_R, REPLACE_STRERROR_R. * modules/strerror_r-posix: New file. * modules/string (Makefile.am): Substitute GNULIB_STRERROR_R, HAVE_DECL_STRERROR_R, REPLACE_STRERROR_R. * doc/posix-functions/strerror_r.texi: Mention the new module and the portability problems.