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