string_h.m4 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. # Configure a GNU-like replacement for <string.h>.
  2. # Copyright (C) 2007-2023 Free Software Foundation, Inc.
  3. # This file is free software; the Free Software Foundation
  4. # gives unlimited permission to copy and/or distribute it,
  5. # with or without modifications, as long as this notice is preserved.
  6. # serial 35
  7. # Written by Paul Eggert.
  8. AC_DEFUN_ONCE([gl_STRING_H],
  9. [
  10. dnl Ensure to expand the default settings once only, before all statements
  11. dnl that occur in other macros.
  12. AC_REQUIRE([gl_STRING_H_DEFAULTS])
  13. gl_NEXT_HEADERS([string.h])
  14. dnl Check for declarations of anything we want to poison if the
  15. dnl corresponding gnulib module is not in use, and which is not
  16. dnl guaranteed by C89.
  17. gl_WARN_ON_USE_PREPARE([[#include <string.h>
  18. ]],
  19. [explicit_bzero ffsl ffsll memmem mempcpy memrchr memset_explicit
  20. rawmemchr stpcpy stpncpy strchrnul
  21. strdup strncat strndup strnlen strpbrk strsep strcasestr strtok_r
  22. strerror_r strerrorname_np sigabbrev_np sigdescr_np strsignal strverscmp])
  23. AC_REQUIRE([AC_C_RESTRICT])
  24. ])
  25. # gl_STRING_MODULE_INDICATOR([modulename])
  26. # sets the shell variable that indicates the presence of the given module
  27. # to a C preprocessor expression that will evaluate to 1.
  28. # This macro invocation must not occur in macros that are AC_REQUIREd.
  29. AC_DEFUN([gl_STRING_MODULE_INDICATOR],
  30. [
  31. dnl Ensure to expand the default settings once only.
  32. gl_STRING_H_REQUIRE_DEFAULTS
  33. gl_MODULE_INDICATOR_SET_VARIABLE([$1])
  34. dnl Define it also as a C macro, for the benefit of the unit tests.
  35. gl_MODULE_INDICATOR_FOR_TESTS([$1])
  36. ])
  37. # Initializes the default values for AC_SUBSTed shell variables.
  38. # This macro must not be AC_REQUIREd. It must only be invoked, and only
  39. # outside of macros or in macros that are not AC_REQUIREd.
  40. AC_DEFUN([gl_STRING_H_REQUIRE_DEFAULTS],
  41. [
  42. m4_defun(GL_MODULE_INDICATOR_PREFIX[_STRING_H_MODULE_INDICATOR_DEFAULTS], [
  43. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXPLICIT_BZERO])
  44. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FFSL])
  45. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FFSLL])
  46. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MEMCHR])
  47. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MEMMEM])
  48. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MEMPCPY])
  49. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MEMRCHR])
  50. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MEMSET_EXPLICIT])
  51. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RAWMEMCHR])
  52. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STPCPY])
  53. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STPNCPY])
  54. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRCHRNUL])
  55. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRDUP])
  56. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRNCAT])
  57. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRNDUP])
  58. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRNLEN])
  59. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRPBRK])
  60. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRSEP])
  61. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRSTR])
  62. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRCASESTR])
  63. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRTOK_R])
  64. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSLEN])
  65. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSNLEN])
  66. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSCHR])
  67. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSRCHR])
  68. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSSTR])
  69. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSCASECMP])
  70. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSNCASECMP])
  71. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSPCASECMP])
  72. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSCASESTR])
  73. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSCSPN])
  74. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSPBRK])
  75. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSSPN])
  76. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSSEP])
  77. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSTOK_R])
  78. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRERROR])
  79. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRERROR_R])
  80. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRERRORNAME_NP])
  81. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SIGABBREV_NP])
  82. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SIGDESCR_NP])
  83. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRSIGNAL])
  84. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRVERSCMP])
  85. dnl Support Microsoft deprecated alias function names by default.
  86. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_MEMCCPY], [1])
  87. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_STRDUP], [1])
  88. ])
  89. m4_require(GL_MODULE_INDICATOR_PREFIX[_STRING_H_MODULE_INDICATOR_DEFAULTS])
  90. dnl Make sure the shell variable for GNULIB_FREE_POSIX is initialized.
  91. gl_STDLIB_H_REQUIRE_DEFAULTS
  92. AC_REQUIRE([gl_STRING_H_DEFAULTS])
  93. ])
  94. AC_DEFUN([gl_STRING_H_DEFAULTS],
  95. [
  96. HAVE_MBSLEN=0; AC_SUBST([HAVE_MBSLEN])
  97. dnl Assume proper GNU behavior unless another module says otherwise.
  98. HAVE_EXPLICIT_BZERO=1; AC_SUBST([HAVE_EXPLICIT_BZERO])
  99. HAVE_FFSL=1; AC_SUBST([HAVE_FFSL])
  100. HAVE_FFSLL=1; AC_SUBST([HAVE_FFSLL])
  101. HAVE_DECL_MEMMEM=1; AC_SUBST([HAVE_DECL_MEMMEM])
  102. HAVE_MEMPCPY=1; AC_SUBST([HAVE_MEMPCPY])
  103. HAVE_MEMSET_EXPLICIT=1; AC_SUBST([HAVE_MEMSET_EXPLICIT])
  104. HAVE_DECL_MEMRCHR=1; AC_SUBST([HAVE_DECL_MEMRCHR])
  105. HAVE_RAWMEMCHR=1; AC_SUBST([HAVE_RAWMEMCHR])
  106. HAVE_STPCPY=1; AC_SUBST([HAVE_STPCPY])
  107. HAVE_STPNCPY=1; AC_SUBST([HAVE_STPNCPY])
  108. HAVE_STRCHRNUL=1; AC_SUBST([HAVE_STRCHRNUL])
  109. HAVE_DECL_STRDUP=1; AC_SUBST([HAVE_DECL_STRDUP])
  110. HAVE_DECL_STRNDUP=1; AC_SUBST([HAVE_DECL_STRNDUP])
  111. HAVE_DECL_STRNLEN=1; AC_SUBST([HAVE_DECL_STRNLEN])
  112. HAVE_STRPBRK=1; AC_SUBST([HAVE_STRPBRK])
  113. HAVE_STRSEP=1; AC_SUBST([HAVE_STRSEP])
  114. HAVE_STRCASESTR=1; AC_SUBST([HAVE_STRCASESTR])
  115. HAVE_DECL_STRTOK_R=1; AC_SUBST([HAVE_DECL_STRTOK_R])
  116. HAVE_DECL_STRERROR_R=1; AC_SUBST([HAVE_DECL_STRERROR_R])
  117. HAVE_STRERRORNAME_NP=1; AC_SUBST([HAVE_STRERRORNAME_NP])
  118. HAVE_SIGABBREV_NP=1; AC_SUBST([HAVE_SIGABBREV_NP])
  119. HAVE_SIGDESCR_NP=1; AC_SUBST([HAVE_SIGDESCR_NP])
  120. HAVE_DECL_STRSIGNAL=1; AC_SUBST([HAVE_DECL_STRSIGNAL])
  121. HAVE_STRVERSCMP=1; AC_SUBST([HAVE_STRVERSCMP])
  122. REPLACE_FFSLL=0; AC_SUBST([REPLACE_FFSLL])
  123. REPLACE_MEMCHR=0; AC_SUBST([REPLACE_MEMCHR])
  124. REPLACE_MEMMEM=0; AC_SUBST([REPLACE_MEMMEM])
  125. REPLACE_STPNCPY=0; AC_SUBST([REPLACE_STPNCPY])
  126. REPLACE_STRCHRNUL=0; AC_SUBST([REPLACE_STRCHRNUL])
  127. REPLACE_STRDUP=0; AC_SUBST([REPLACE_STRDUP])
  128. REPLACE_STRNCAT=0; AC_SUBST([REPLACE_STRNCAT])
  129. REPLACE_STRNDUP=0; AC_SUBST([REPLACE_STRNDUP])
  130. REPLACE_STRNLEN=0; AC_SUBST([REPLACE_STRNLEN])
  131. REPLACE_STRSTR=0; AC_SUBST([REPLACE_STRSTR])
  132. REPLACE_STRCASESTR=0; AC_SUBST([REPLACE_STRCASESTR])
  133. REPLACE_STRTOK_R=0; AC_SUBST([REPLACE_STRTOK_R])
  134. REPLACE_STRERROR=0; AC_SUBST([REPLACE_STRERROR])
  135. REPLACE_STRERROR_R=0; AC_SUBST([REPLACE_STRERROR_R])
  136. REPLACE_STRERRORNAME_NP=0; AC_SUBST([REPLACE_STRERRORNAME_NP])
  137. REPLACE_STRSIGNAL=0; AC_SUBST([REPLACE_STRSIGNAL])
  138. UNDEFINE_STRTOK_R=0; AC_SUBST([UNDEFINE_STRTOK_R])
  139. ])