Annotation of embedaddon/libiconv/srcm4/strerror.m4, revision 1.1.1.2
1.1.1.2 ! misho 1: # strerror.m4 serial 16
! 2: dnl Copyright (C) 2002, 2007-2011 Free Software Foundation, Inc.
1.1 misho 3: dnl This file is free software; the Free Software Foundation
4: dnl gives unlimited permission to copy and/or distribute it,
5: dnl with or without modifications, as long as this notice is preserved.
6:
7: AC_DEFUN([gl_FUNC_STRERROR],
8: [
9: AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
10: AC_REQUIRE([gl_HEADER_ERRNO_H])
1.1.1.2 ! misho 11: AC_REQUIRE([gl_FUNC_STRERROR_0])
! 12: m4_ifdef([gl_FUNC_STRERROR_R_WORKS], [
! 13: AC_REQUIRE([gl_FUNC_STRERROR_R_WORKS])
! 14: ])
! 15: if test "$ERRNO_H:$REPLACE_STRERROR_0" = :0; then
1.1 misho 16: AC_CACHE_CHECK([for working strerror function],
17: [gl_cv_func_working_strerror],
18: [AC_RUN_IFELSE(
19: [AC_LANG_PROGRAM(
20: [[#include <string.h>
21: ]],
1.1.1.2 ! misho 22: [[if (!*strerror (-2)) return 1;]])],
1.1 misho 23: [gl_cv_func_working_strerror=yes],
24: [gl_cv_func_working_strerror=no],
1.1.1.2 ! misho 25: [dnl Be pessimistic on cross-compiles for now.
! 26: gl_cv_func_working_strerror="guessing no"])
1.1 misho 27: ])
1.1.1.2 ! misho 28: if test "$gl_cv_func_working_strerror" != yes; then
1.1 misho 29: dnl The system's strerror() fails to return a string for out-of-range
30: dnl integers. Replace it.
31: REPLACE_STRERROR=1
32: fi
1.1.1.2 ! misho 33: m4_ifdef([gl_FUNC_STRERROR_R_WORKS], [
! 34: dnl If the system's strerror_r or __xpg_strerror_r clobbers strerror's
! 35: dnl buffer, we must replace strerror.
! 36: case "$gl_cv_func_strerror_r_works" in
! 37: *no) REPLACE_STRERROR=1 ;;
! 38: esac
! 39: ])
1.1 misho 40: else
41: dnl The system's strerror() cannot know about the new errno values we add
1.1.1.2 ! misho 42: dnl to <errno.h>, or any fix for strerror(0). Replace it.
1.1 misho 43: REPLACE_STRERROR=1
44: fi
45: ])
46:
1.1.1.2 ! misho 47: dnl Detect if strerror(0) passes (that is, does not set errno, and does not
! 48: dnl return a string that matches strerror(-1)).
! 49: AC_DEFUN([gl_FUNC_STRERROR_0],
! 50: [
! 51: REPLACE_STRERROR_0=0
! 52: AC_CACHE_CHECK([whether strerror(0) succeeds],
! 53: [gl_cv_func_strerror_0_works],
! 54: [AC_RUN_IFELSE(
! 55: [AC_LANG_PROGRAM(
! 56: [[#include <string.h>
! 57: #include <errno.h>
! 58: ]],
! 59: [[int result = 0;
! 60: char *str;
! 61: errno = 0;
! 62: str = strerror (0);
! 63: if (!*str) result |= 1;
! 64: if (errno) result |= 2;
! 65: if (strstr (str, "nknown") || strstr (str, "ndefined"))
! 66: result |= 4;
! 67: return result;]])],
! 68: [gl_cv_func_strerror_0_works=yes],
! 69: [gl_cv_func_strerror_0_works=no],
! 70: [dnl Be pessimistic on cross-compiles for now.
! 71: gl_cv_func_strerror_0_works="guessing no"])
! 72: ])
! 73: if test "$gl_cv_func_strerror_0_works" != yes; then
! 74: REPLACE_STRERROR_0=1
! 75: AC_DEFINE([REPLACE_STRERROR_0], [1], [Define to 1 if strerror(0)
! 76: does not return a message implying success.])
1.1 misho 77: fi
78: ])
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>