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