eilseq.m4 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #serial 1
  2. AC_PREREQ(2.50)
  3. # The EILSEQ errno value ought to be defined in <errno.h>, according to
  4. # ISO C 99 and POSIX. But some systems (like SunOS 4) don't define it,
  5. # and some systems (like BSD/OS) define it in <wchar.h> not <errno.h>.
  6. # Define EILSEQ as a C macro and as a substituted macro in such a way that
  7. # 1. on all systems, after inclusion of <errno.h>, EILSEQ is usable,
  8. # 2. on systems where EILSEQ is defined elsewhere, we use the same numeric
  9. # value.
  10. AC_DEFUN([AC_EILSEQ],
  11. [
  12. AC_REQUIRE([AC_PROG_CC])dnl
  13. dnl Check for any extra headers that could define EILSEQ.
  14. AC_CHECK_HEADERS(wchar.h)
  15. AC_CACHE_CHECK([for EILSEQ], ac_cv_decl_EILSEQ, [
  16. AC_EGREP_CPP(yes,[
  17. #include <errno.h>
  18. #ifdef EILSEQ
  19. yes
  20. #endif
  21. ], have_eilseq=1)
  22. if test -n "$have_eilseq"; then
  23. dnl EILSEQ exists in <errno.h>. Don't need to define EILSEQ ourselves.
  24. ac_cv_decl_EILSEQ=yes
  25. else
  26. AC_EGREP_CPP(yes,[
  27. #include <errno.h>
  28. #if HAVE_WCHAR_H
  29. #include <wchar.h>
  30. #endif
  31. #ifdef EILSEQ
  32. yes
  33. #endif
  34. ], have_eilseq=1)
  35. if test -n "$have_eilseq"; then
  36. dnl EILSEQ exists in some other system header.
  37. dnl Define it to the same value.
  38. _AC_COMPUTE_INT([EILSEQ], ac_cv_decl_EILSEQ, [
  39. #include <errno.h>
  40. #if HAVE_WCHAR_H
  41. #include <wchar.h>
  42. #endif
  43. /* The following two lines are a workaround against an autoconf-2.52 bug. */
  44. #include <stdio.h>
  45. #include <stdlib.h>
  46. ])
  47. else
  48. dnl EILSEQ isn't defined by the system. Define EILSEQ ourselves, but
  49. dnl don't define it as EINVAL, because iconv() callers want to
  50. dnl distinguish EINVAL and EILSEQ.
  51. ac_cv_decl_EILSEQ=ENOENT
  52. fi
  53. fi
  54. ])
  55. if test "$ac_cv_decl_EILSEQ" != yes; then
  56. AC_DEFINE_UNQUOTED([EILSEQ], [$ac_cv_decl_EILSEQ],
  57. [Define as good substitute value for EILSEQ.])
  58. EILSEQ="$ac_cv_decl_EILSEQ"
  59. AC_SUBST(EILSEQ)
  60. fi
  61. ])