aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorPaul Eggert2021-12-18 16:12:38 -0800
committerPaul Eggert2021-12-18 16:15:49 -0800
commitf05a93e8232e6f56458ac16d733b03e96a63e930 (patch)
treeb6b95198cf4b5e0b2969b7a427db1c5146a7d856 /lib
parent35da3ed05212e0222841becf614c109011f9ad80 (diff)
downloademacs-f05a93e8232e6f56458ac16d733b03e96a63e930.tar.gz
emacs-f05a93e8232e6f56458ac16d733b03e96a63e930.zip
Update from gnulib
Make the following changes by hand, and run ‘admin/merge-gnulib’. * configure.ac (AM_CONDITIONAL): Adjust to new Gnulib convention.
Diffstat (limited to 'lib')
-rw-r--r--lib/cdefs.h67
-rw-r--r--lib/gettext.h13
-rw-r--r--lib/gnulib.mk.in223
-rw-r--r--lib/intprops.h15
-rw-r--r--lib/nproc.c5
-rw-r--r--lib/nstrftime.c9
-rw-r--r--lib/regcomp.c813
-rw-r--r--lib/regex_internal.c40
-rw-r--r--lib/regex_internal.h49
-rw-r--r--lib/regexec.c84
-rw-r--r--lib/string.in.h29
-rw-r--r--lib/sys_random.in.h6
12 files changed, 636 insertions, 717 deletions
diff --git a/lib/cdefs.h b/lib/cdefs.h
index 4dac9d264d2..a05b538579b 100644
--- a/lib/cdefs.h
+++ b/lib/cdefs.h
@@ -1,4 +1,5 @@
1/* Copyright (C) 1992-2021 Free Software Foundation, Inc. 1/* Copyright (C) 1992-2021 Free Software Foundation, Inc.
2 Copyright The GNU Toolchain Authors.
2 This file is part of the GNU C Library. 3 This file is part of the GNU C Library.
3 4
4 The GNU C Library is free software; you can redistribute it and/or 5 The GNU C Library is free software; you can redistribute it and/or
@@ -150,6 +151,53 @@
150# define __glibc_objsize(__o) __bos (__o) 151# define __glibc_objsize(__o) __bos (__o)
151#endif 152#endif
152 153
154/* Compile time conditions to choose between the regular, _chk and _chk_warn
155 variants. These conditions should get evaluated to constant and optimized
156 away. */
157
158#define __glibc_safe_len_cond(__l, __s, __osz) ((__l) <= (__osz) / (__s))
159#define __glibc_unsigned_or_positive(__l) \
160 ((__typeof (__l)) 0 < (__typeof (__l)) -1 \
161 || (__builtin_constant_p (__l) && (__l) > 0))
162
163/* Length is known to be safe at compile time if the __L * __S <= __OBJSZ
164 condition can be folded to a constant and if it is true. The -1 check is
165 redundant because since it implies that __glibc_safe_len_cond is true. */
166#define __glibc_safe_or_unknown_len(__l, __s, __osz) \
167 (__glibc_unsigned_or_positive (__l) \
168 && __builtin_constant_p (__glibc_safe_len_cond ((__SIZE_TYPE__) (__l), \
169 __s, __osz)) \
170 && __glibc_safe_len_cond ((__SIZE_TYPE__) (__l), __s, __osz))
171
172/* Conversely, we know at compile time that the length is unsafe if the
173 __L * __S <= __OBJSZ condition can be folded to a constant and if it is
174 false. */
175#define __glibc_unsafe_len(__l, __s, __osz) \
176 (__glibc_unsigned_or_positive (__l) \
177 && __builtin_constant_p (__glibc_safe_len_cond ((__SIZE_TYPE__) (__l), \
178 __s, __osz)) \
179 && !__glibc_safe_len_cond ((__SIZE_TYPE__) (__l), __s, __osz))
180
181/* Fortify function f. __f_alias, __f_chk and __f_chk_warn must be
182 declared. */
183
184#define __glibc_fortify(f, __l, __s, __osz, ...) \
185 (__glibc_safe_or_unknown_len (__l, __s, __osz) \
186 ? __ ## f ## _alias (__VA_ARGS__) \
187 : (__glibc_unsafe_len (__l, __s, __osz) \
188 ? __ ## f ## _chk_warn (__VA_ARGS__, __osz) \
189 : __ ## f ## _chk (__VA_ARGS__, __osz))) \
190
191/* Fortify function f, where object size argument passed to f is the number of
192 elements and not total size. */
193
194#define __glibc_fortify_n(f, __l, __s, __osz, ...) \
195 (__glibc_safe_or_unknown_len (__l, __s, __osz) \
196 ? __ ## f ## _alias (__VA_ARGS__) \
197 : (__glibc_unsafe_len (__l, __s, __osz) \
198 ? __ ## f ## _chk_warn (__VA_ARGS__, (__osz) / (__s)) \
199 : __ ## f ## _chk (__VA_ARGS__, (__osz) / (__s)))) \
200
153#if __GNUC_PREREQ (4,3) 201#if __GNUC_PREREQ (4,3)
154# define __warnattr(msg) __attribute__((__warning__ (msg))) 202# define __warnattr(msg) __attribute__((__warning__ (msg)))
155# define __errordecl(name, msg) \ 203# define __errordecl(name, msg) \
@@ -243,6 +291,15 @@
243# define __attribute_alloc_size__(params) /* Ignore. */ 291# define __attribute_alloc_size__(params) /* Ignore. */
244#endif 292#endif
245 293
294/* Tell the compiler which argument to an allocation function
295 indicates the alignment of the allocation. */
296#if __GNUC_PREREQ (4, 9) || __glibc_has_attribute (__alloc_align__)
297# define __attribute_alloc_align__(param) \
298 __attribute__ ((__alloc_align__ param))
299#else
300# define __attribute_alloc_align__(param) /* Ignore. */
301#endif
302
246/* At some point during the gcc 2.96 development the `pure' attribute 303/* At some point during the gcc 2.96 development the `pure' attribute
247 for functions was introduced. We don't want to use it unconditionally 304 for functions was introduced. We don't want to use it unconditionally
248 (although this would be possible) since it generates warnings. */ 305 (although this would be possible) since it generates warnings. */
@@ -605,12 +662,22 @@ _Static_assert (0, "IEEE 128-bits long double requires redirection on this platf
605 size-index is not provided: 662 size-index is not provided:
606 access (access-mode, <ref-index> [, <size-index>]) */ 663 access (access-mode, <ref-index> [, <size-index>]) */
607# define __attr_access(x) __attribute__ ((__access__ x)) 664# define __attr_access(x) __attribute__ ((__access__ x))
665/* For _FORTIFY_SOURCE == 3 we use __builtin_dynamic_object_size, which may
666 use the access attribute to get object sizes from function definition
667 arguments, so we can't use them on functions we fortify. Drop the object
668 size hints for such functions. */
669# if __USE_FORTIFY_LEVEL == 3
670# define __fortified_attr_access(a, o, s) __attribute__ ((__access__ (a, o)))
671# else
672# define __fortified_attr_access(a, o, s) __attr_access ((a, o, s))
673# endif
608# if __GNUC_PREREQ (11, 0) 674# if __GNUC_PREREQ (11, 0)
609# define __attr_access_none(argno) __attribute__ ((__access__ (__none__, argno))) 675# define __attr_access_none(argno) __attribute__ ((__access__ (__none__, argno)))
610# else 676# else
611# define __attr_access_none(argno) 677# define __attr_access_none(argno)
612# endif 678# endif
613#else 679#else
680# define __fortified_attr_access(a, o, s)
614# define __attr_access(x) 681# define __attr_access(x)
615# define __attr_access_none(argno) 682# define __attr_access_none(argno)
616#endif 683#endif
diff --git a/lib/gettext.h b/lib/gettext.h
index f1c7a240757..a573da35460 100644
--- a/lib/gettext.h
+++ b/lib/gettext.h
@@ -138,7 +138,7 @@
138#define dcnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N, Category) \ 138#define dcnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N, Category) \
139 npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, Category) 139 npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, Category)
140 140
141#ifdef __GNUC__ 141#if defined __GNUC__ || defined __clang__
142__inline 142__inline
143#else 143#else
144#ifdef __cplusplus 144#ifdef __cplusplus
@@ -157,7 +157,7 @@ pgettext_aux (const char *domain,
157 return translation; 157 return translation;
158} 158}
159 159
160#ifdef __GNUC__ 160#if defined __GNUC__ || defined __clang__
161__inline 161__inline
162#else 162#else
163#ifdef __cplusplus 163#ifdef __cplusplus
@@ -191,9 +191,8 @@ npgettext_aux (const char *domain,
191 or may have security implications due to non-deterministic stack usage. */ 191 or may have security implications due to non-deterministic stack usage. */
192 192
193#if (!defined GNULIB_NO_VLA \ 193#if (!defined GNULIB_NO_VLA \
194 && (((__GNUC__ >= 3 || __GNUG__ >= 2) && !defined __STRICT_ANSI__) \ 194 && defined __STDC_VERSION__ && 199901L <= __STDC_VERSION__ \
195 /* || (__STDC_VERSION__ == 199901L && !defined __HP_cc) 195 && !defined __STDC_NO_VLA__)
196 || (__STDC_VERSION__ >= 201112L && !defined __STDC_NO_VLA__) */ ))
197# define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 1 196# define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 1
198#else 197#else
199# define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 0 198# define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 0
@@ -208,7 +207,7 @@ npgettext_aux (const char *domain,
208#define dpgettext_expr(Domainname, Msgctxt, Msgid) \ 207#define dpgettext_expr(Domainname, Msgctxt, Msgid) \
209 dcpgettext_expr (Domainname, Msgctxt, Msgid, LC_MESSAGES) 208 dcpgettext_expr (Domainname, Msgctxt, Msgid, LC_MESSAGES)
210 209
211#ifdef __GNUC__ 210#if defined __GNUC__ || defined __clang__
212__inline 211__inline
213#else 212#else
214#ifdef __cplusplus 213#ifdef __cplusplus
@@ -255,7 +254,7 @@ dcpgettext_expr (const char *domain,
255#define dnpgettext_expr(Domainname, Msgctxt, Msgid, MsgidPlural, N) \ 254#define dnpgettext_expr(Domainname, Msgctxt, Msgid, MsgidPlural, N) \
256 dcnpgettext_expr (Domainname, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES) 255 dcnpgettext_expr (Domainname, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
257 256
258#ifdef __GNUC__ 257#if defined __GNUC__ || defined __clang__
259__inline 258__inline
260#else 259#else
261#ifdef __cplusplus 260#ifdef __cplusplus
diff --git a/lib/gnulib.mk.in b/lib/gnulib.mk.in
index c7c7eb455be..fbec70c135c 100644
--- a/lib/gnulib.mk.in
+++ b/lib/gnulib.mk.in
@@ -202,6 +202,9 @@ COM_ERRLIB = @COM_ERRLIB@
202CPP = @CPP@ 202CPP = @CPP@
203CPPFLAGS = @CPPFLAGS@ 203CPPFLAGS = @CPPFLAGS@
204CRYPTOLIB = @CRYPTOLIB@ 204CRYPTOLIB = @CRYPTOLIB@
205CXX = @CXX@
206CXXCPP = @CXXCPP@
207CXXFLAGS = @CXXFLAGS@
205CYGWIN_OBJ = @CYGWIN_OBJ@ 208CYGWIN_OBJ = @CYGWIN_OBJ@
206C_SWITCH_MACHINE = @C_SWITCH_MACHINE@ 209C_SWITCH_MACHINE = @C_SWITCH_MACHINE@
207C_SWITCH_SYSTEM = @C_SWITCH_SYSTEM@ 210C_SWITCH_SYSTEM = @C_SWITCH_SYSTEM@
@@ -244,18 +247,22 @@ GETOPT_CDEFS_H = @GETOPT_CDEFS_H@
244GETOPT_H = @GETOPT_H@ 247GETOPT_H = @GETOPT_H@
245GFILENOTIFY_CFLAGS = @GFILENOTIFY_CFLAGS@ 248GFILENOTIFY_CFLAGS = @GFILENOTIFY_CFLAGS@
246GFILENOTIFY_LIBS = @GFILENOTIFY_LIBS@ 249GFILENOTIFY_LIBS = @GFILENOTIFY_LIBS@
247GL_COND_LIBTOOL = @GL_COND_LIBTOOL@ 250GLIB_COMPILE_SCHEMAS = @GLIB_COMPILE_SCHEMAS@
248GL_GENERATE_ALLOCA_H = @GL_GENERATE_ALLOCA_H@ 251GL_COND_LIBTOOL_CONDITION = @GL_COND_LIBTOOL_CONDITION@
249GL_GENERATE_BYTESWAP_H = @GL_GENERATE_BYTESWAP_H@ 252GL_GENERATE_ALLOCA_H_CONDITION = @GL_GENERATE_ALLOCA_H_CONDITION@
250GL_GENERATE_ERRNO_H = @GL_GENERATE_ERRNO_H@ 253GL_GENERATE_BYTESWAP_H_CONDITION = @GL_GENERATE_BYTESWAP_H_CONDITION@
251GL_GENERATE_EXECINFO_H = @GL_GENERATE_EXECINFO_H@ 254GL_GENERATE_ERRNO_H_CONDITION = @GL_GENERATE_ERRNO_H_CONDITION@
252GL_GENERATE_GMP_GMP_H = @GL_GENERATE_GMP_GMP_H@ 255GL_GENERATE_EXECINFO_H_CONDITION = @GL_GENERATE_EXECINFO_H_CONDITION@
253GL_GENERATE_IEEE754_H = @GL_GENERATE_IEEE754_H@ 256GL_GENERATE_GETOPT_CDEFS_H_CONDITION = @GL_GENERATE_GETOPT_CDEFS_H_CONDITION@
254GL_GENERATE_LIMITS_H = @GL_GENERATE_LIMITS_H@ 257GL_GENERATE_GETOPT_H_CONDITION = @GL_GENERATE_GETOPT_H_CONDITION@
255GL_GENERATE_MINI_GMP_H = @GL_GENERATE_MINI_GMP_H@ 258GL_GENERATE_GMP_GMP_H_CONDITION = @GL_GENERATE_GMP_GMP_H_CONDITION@
256GL_GENERATE_STDALIGN_H = @GL_GENERATE_STDALIGN_H@ 259GL_GENERATE_GMP_H_CONDITION = @GL_GENERATE_GMP_H_CONDITION@
257GL_GENERATE_STDDEF_H = @GL_GENERATE_STDDEF_H@ 260GL_GENERATE_IEEE754_H_CONDITION = @GL_GENERATE_IEEE754_H_CONDITION@
258GL_GENERATE_STDINT_H = @GL_GENERATE_STDINT_H@ 261GL_GENERATE_LIMITS_H_CONDITION = @GL_GENERATE_LIMITS_H_CONDITION@
262GL_GENERATE_MINI_GMP_H_CONDITION = @GL_GENERATE_MINI_GMP_H_CONDITION@
263GL_GENERATE_STDALIGN_H_CONDITION = @GL_GENERATE_STDALIGN_H_CONDITION@
264GL_GENERATE_STDDEF_H_CONDITION = @GL_GENERATE_STDDEF_H_CONDITION@
265GL_GENERATE_STDINT_H_CONDITION = @GL_GENERATE_STDINT_H_CONDITION@
259GL_GNULIB_ACCESS = @GL_GNULIB_ACCESS@ 266GL_GNULIB_ACCESS = @GL_GNULIB_ACCESS@
260GL_GNULIB_ALIGNED_ALLOC = @GL_GNULIB_ALIGNED_ALLOC@ 267GL_GNULIB_ALIGNED_ALLOC = @GL_GNULIB_ALIGNED_ALLOC@
261GL_GNULIB_ALPHASORT = @GL_GNULIB_ALPHASORT@ 268GL_GNULIB_ALPHASORT = @GL_GNULIB_ALPHASORT@
@@ -556,17 +563,24 @@ GOBJECT_CFLAGS = @GOBJECT_CFLAGS@
556GOBJECT_LIBS = @GOBJECT_LIBS@ 563GOBJECT_LIBS = @GOBJECT_LIBS@
557GREP = @GREP@ 564GREP = @GREP@
558GSETTINGS_CFLAGS = @GSETTINGS_CFLAGS@ 565GSETTINGS_CFLAGS = @GSETTINGS_CFLAGS@
566GSETTINGS_DISABLE_SCHEMAS_COMPILE = @GSETTINGS_DISABLE_SCHEMAS_COMPILE@
559GSETTINGS_LIBS = @GSETTINGS_LIBS@ 567GSETTINGS_LIBS = @GSETTINGS_LIBS@
568GSETTINGS_RULES = @GSETTINGS_RULES@
560GTK_CFLAGS = @GTK_CFLAGS@ 569GTK_CFLAGS = @GTK_CFLAGS@
561GTK_LIBS = @GTK_LIBS@ 570GTK_LIBS = @GTK_LIBS@
562GTK_OBJ = @GTK_OBJ@ 571GTK_OBJ = @GTK_OBJ@
563GZIP_PROG = @GZIP_PROG@ 572GZIP_PROG = @GZIP_PROG@
573HAIKU_CFLAGS = @HAIKU_CFLAGS@
574HAIKU_CXX_OBJ = @HAIKU_CXX_OBJ@
575HAIKU_LIBS = @HAIKU_LIBS@
576HAIKU_OBJ = @HAIKU_OBJ@
564HARFBUZZ_CFLAGS = @HARFBUZZ_CFLAGS@ 577HARFBUZZ_CFLAGS = @HARFBUZZ_CFLAGS@
565HARFBUZZ_LIBS = @HARFBUZZ_LIBS@ 578HARFBUZZ_LIBS = @HARFBUZZ_LIBS@
566HAVE_ALIGNED_ALLOC = @HAVE_ALIGNED_ALLOC@ 579HAVE_ALIGNED_ALLOC = @HAVE_ALIGNED_ALLOC@
567HAVE_ALLOCA_H = @HAVE_ALLOCA_H@ 580HAVE_ALLOCA_H = @HAVE_ALLOCA_H@
568HAVE_ALPHASORT = @HAVE_ALPHASORT@ 581HAVE_ALPHASORT = @HAVE_ALPHASORT@
569HAVE_ATOLL = @HAVE_ATOLL@ 582HAVE_ATOLL = @HAVE_ATOLL@
583HAVE_BE_APP = @HAVE_BE_APP@
570HAVE_C99_STDINT_H = @HAVE_C99_STDINT_H@ 584HAVE_C99_STDINT_H = @HAVE_C99_STDINT_H@
571HAVE_CANONICALIZE_FILE_NAME = @HAVE_CANONICALIZE_FILE_NAME@ 585HAVE_CANONICALIZE_FILE_NAME = @HAVE_CANONICALIZE_FILE_NAME@
572HAVE_CHOWN = @HAVE_CHOWN@ 586HAVE_CHOWN = @HAVE_CHOWN@
@@ -600,6 +614,7 @@ HAVE_DECL_LOCALTIME_R = @HAVE_DECL_LOCALTIME_R@
600HAVE_DECL_MEMMEM = @HAVE_DECL_MEMMEM@ 614HAVE_DECL_MEMMEM = @HAVE_DECL_MEMMEM@
601HAVE_DECL_MEMRCHR = @HAVE_DECL_MEMRCHR@ 615HAVE_DECL_MEMRCHR = @HAVE_DECL_MEMRCHR@
602HAVE_DECL_OBSTACK_PRINTF = @HAVE_DECL_OBSTACK_PRINTF@ 616HAVE_DECL_OBSTACK_PRINTF = @HAVE_DECL_OBSTACK_PRINTF@
617HAVE_DECL_POSIX_SPAWN_SETSID = @HAVE_DECL_POSIX_SPAWN_SETSID@
603HAVE_DECL_SETENV = @HAVE_DECL_SETENV@ 618HAVE_DECL_SETENV = @HAVE_DECL_SETENV@
604HAVE_DECL_SETHOSTNAME = @HAVE_DECL_SETHOSTNAME@ 619HAVE_DECL_SETHOSTNAME = @HAVE_DECL_SETHOSTNAME@
605HAVE_DECL_SETSTATE = @HAVE_DECL_SETSTATE@ 620HAVE_DECL_SETSTATE = @HAVE_DECL_SETSTATE@
@@ -690,6 +705,10 @@ HAVE_POPEN = @HAVE_POPEN@
690HAVE_POSIX_MEMALIGN = @HAVE_POSIX_MEMALIGN@ 705HAVE_POSIX_MEMALIGN = @HAVE_POSIX_MEMALIGN@
691HAVE_POSIX_OPENPT = @HAVE_POSIX_OPENPT@ 706HAVE_POSIX_OPENPT = @HAVE_POSIX_OPENPT@
692HAVE_POSIX_SIGNALBLOCKING = @HAVE_POSIX_SIGNALBLOCKING@ 707HAVE_POSIX_SIGNALBLOCKING = @HAVE_POSIX_SIGNALBLOCKING@
708HAVE_POSIX_SPAWN = @HAVE_POSIX_SPAWN@
709HAVE_POSIX_SPAWNATTR_SETFLAGS = @HAVE_POSIX_SPAWNATTR_SETFLAGS@
710HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR = @HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR@
711HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR_NP = @HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR_NP@
693HAVE_PREAD = @HAVE_PREAD@ 712HAVE_PREAD = @HAVE_PREAD@
694HAVE_PSELECT = @HAVE_PSELECT@ 713HAVE_PSELECT = @HAVE_PSELECT@
695HAVE_PTHREAD_SIGMASK = @HAVE_PTHREAD_SIGMASK@ 714HAVE_PTHREAD_SIGMASK = @HAVE_PTHREAD_SIGMASK@
@@ -726,6 +745,7 @@ HAVE_SIGNED_WCHAR_T = @HAVE_SIGNED_WCHAR_T@
726HAVE_SIGNED_WINT_T = @HAVE_SIGNED_WINT_T@ 745HAVE_SIGNED_WINT_T = @HAVE_SIGNED_WINT_T@
727HAVE_SIGSET_T = @HAVE_SIGSET_T@ 746HAVE_SIGSET_T = @HAVE_SIGSET_T@
728HAVE_SLEEP = @HAVE_SLEEP@ 747HAVE_SLEEP = @HAVE_SLEEP@
748HAVE_SPAWN_H = @HAVE_SPAWN_H@
729HAVE_STDINT_H = @HAVE_STDINT_H@ 749HAVE_STDINT_H = @HAVE_STDINT_H@
730HAVE_STPCPY = @HAVE_STPCPY@ 750HAVE_STPCPY = @HAVE_STPCPY@
731HAVE_STPNCPY = @HAVE_STPNCPY@ 751HAVE_STPNCPY = @HAVE_STPNCPY@
@@ -923,6 +943,8 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
923PAXCTL = @PAXCTL@ 943PAXCTL = @PAXCTL@
924PAXCTL_dumped = @PAXCTL_dumped@ 944PAXCTL_dumped = @PAXCTL_dumped@
925PAXCTL_notdumped = @PAXCTL_notdumped@ 945PAXCTL_notdumped = @PAXCTL_notdumped@
946PGTK_LIBS = @PGTK_LIBS@
947PGTK_OBJ = @PGTK_OBJ@
926PKG_CONFIG = @PKG_CONFIG@ 948PKG_CONFIG = @PKG_CONFIG@
927PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ 949PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
928PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ 950PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
@@ -1104,6 +1126,7 @@ SETTINGS_LIBS = @SETTINGS_LIBS@
1104SHELL = @SHELL@ 1126SHELL = @SHELL@
1105SIG_ATOMIC_T_SUFFIX = @SIG_ATOMIC_T_SUFFIX@ 1127SIG_ATOMIC_T_SUFFIX = @SIG_ATOMIC_T_SUFFIX@
1106SIZE_T_SUFFIX = @SIZE_T_SUFFIX@ 1128SIZE_T_SUFFIX = @SIZE_T_SUFFIX@
1129SQLITE3_LIBS = @SQLITE3_LIBS@
1107STDALIGN_H = @STDALIGN_H@ 1130STDALIGN_H = @STDALIGN_H@
1108STDDEF_H = @STDDEF_H@ 1131STDDEF_H = @STDDEF_H@
1109STDINT_H = @STDINT_H@ 1132STDINT_H = @STDINT_H@
@@ -1132,6 +1155,8 @@ WARN_CFLAGS = @WARN_CFLAGS@
1132WCHAR_T_SUFFIX = @WCHAR_T_SUFFIX@ 1155WCHAR_T_SUFFIX = @WCHAR_T_SUFFIX@
1133WEBKIT_CFLAGS = @WEBKIT_CFLAGS@ 1156WEBKIT_CFLAGS = @WEBKIT_CFLAGS@
1134WEBKIT_LIBS = @WEBKIT_LIBS@ 1157WEBKIT_LIBS = @WEBKIT_LIBS@
1158WEBP_CFLAGS = @WEBP_CFLAGS@
1159WEBP_LIBS = @WEBP_LIBS@
1135WERROR_CFLAGS = @WERROR_CFLAGS@ 1160WERROR_CFLAGS = @WERROR_CFLAGS@
1136WIDGET_OBJ = @WIDGET_OBJ@ 1161WIDGET_OBJ = @WIDGET_OBJ@
1137WINDOWS_64_BIT_OFF_T = @WINDOWS_64_BIT_OFF_T@ 1162WINDOWS_64_BIT_OFF_T = @WINDOWS_64_BIT_OFF_T@
@@ -1153,6 +1178,8 @@ XFT_LIBS = @XFT_LIBS@
1153XGSELOBJ = @XGSELOBJ@ 1178XGSELOBJ = @XGSELOBJ@
1154XINERAMA_CFLAGS = @XINERAMA_CFLAGS@ 1179XINERAMA_CFLAGS = @XINERAMA_CFLAGS@
1155XINERAMA_LIBS = @XINERAMA_LIBS@ 1180XINERAMA_LIBS = @XINERAMA_LIBS@
1181XINPUT_CFLAGS = @XINPUT_CFLAGS@
1182XINPUT_LIBS = @XINPUT_LIBS@
1156XMENU_OBJ = @XMENU_OBJ@ 1183XMENU_OBJ = @XMENU_OBJ@
1157XMKMF = @XMKMF@ 1184XMKMF = @XMKMF@
1158XOBJ = @XOBJ@ 1185XOBJ = @XOBJ@
@@ -1162,6 +1189,7 @@ XRENDER_LIBS = @XRENDER_LIBS@
1162XWIDGETS_OBJ = @XWIDGETS_OBJ@ 1189XWIDGETS_OBJ = @XWIDGETS_OBJ@
1163X_TOOLKIT_TYPE = @X_TOOLKIT_TYPE@ 1190X_TOOLKIT_TYPE = @X_TOOLKIT_TYPE@
1164ac_ct_CC = @ac_ct_CC@ 1191ac_ct_CC = @ac_ct_CC@
1192ac_ct_CXX = @ac_ct_CXX@
1165ac_ct_OBJC = @ac_ct_OBJC@ 1193ac_ct_OBJC = @ac_ct_OBJC@
1166archlibdir = @archlibdir@ 1194archlibdir = @archlibdir@
1167bindir = @bindir@ 1195bindir = @bindir@
@@ -1188,34 +1216,35 @@ exec_prefix = @exec_prefix@
1188gamedir = @gamedir@ 1216gamedir = @gamedir@
1189gamegroup = @gamegroup@ 1217gamegroup = @gamegroup@
1190gameuser = @gameuser@ 1218gameuser = @gameuser@
1191gl_GNULIB_ENABLED_03e0aaad4cb89ca757653bd367a6ccb7 = @gl_GNULIB_ENABLED_03e0aaad4cb89ca757653bd367a6ccb7@ 1219gl_GNULIB_ENABLED_03e0aaad4cb89ca757653bd367a6ccb7_CONDITION = @gl_GNULIB_ENABLED_03e0aaad4cb89ca757653bd367a6ccb7_CONDITION@
1192gl_GNULIB_ENABLED_260941c0e5dc67ec9e87d1fb321c300b = @gl_GNULIB_ENABLED_260941c0e5dc67ec9e87d1fb321c300b@ 1220gl_GNULIB_ENABLED_260941c0e5dc67ec9e87d1fb321c300b_CONDITION = @gl_GNULIB_ENABLED_260941c0e5dc67ec9e87d1fb321c300b_CONDITION@
1193gl_GNULIB_ENABLED_5264294aa0a5557541b53c8c741f7f31 = @gl_GNULIB_ENABLED_5264294aa0a5557541b53c8c741f7f31@ 1221gl_GNULIB_ENABLED_5264294aa0a5557541b53c8c741f7f31_CONDITION = @gl_GNULIB_ENABLED_5264294aa0a5557541b53c8c741f7f31_CONDITION@
1194gl_GNULIB_ENABLED_6099e9737f757db36c47fa9d9f02e88c = @gl_GNULIB_ENABLED_6099e9737f757db36c47fa9d9f02e88c@ 1222gl_GNULIB_ENABLED_6099e9737f757db36c47fa9d9f02e88c_CONDITION = @gl_GNULIB_ENABLED_6099e9737f757db36c47fa9d9f02e88c_CONDITION@
1195gl_GNULIB_ENABLED_61bcaca76b3e6f9ae55d57a1c3193bc4 = @gl_GNULIB_ENABLED_61bcaca76b3e6f9ae55d57a1c3193bc4@ 1223gl_GNULIB_ENABLED_61bcaca76b3e6f9ae55d57a1c3193bc4_CONDITION = @gl_GNULIB_ENABLED_61bcaca76b3e6f9ae55d57a1c3193bc4_CONDITION@
1196gl_GNULIB_ENABLED_682e609604ccaac6be382e4ee3a4eaec = @gl_GNULIB_ENABLED_682e609604ccaac6be382e4ee3a4eaec@ 1224gl_GNULIB_ENABLED_682e609604ccaac6be382e4ee3a4eaec_CONDITION = @gl_GNULIB_ENABLED_682e609604ccaac6be382e4ee3a4eaec_CONDITION@
1197gl_GNULIB_ENABLED_925677f0343de64b89a9f0c790b4104c = @gl_GNULIB_ENABLED_925677f0343de64b89a9f0c790b4104c@ 1225gl_GNULIB_ENABLED_925677f0343de64b89a9f0c790b4104c_CONDITION = @gl_GNULIB_ENABLED_925677f0343de64b89a9f0c790b4104c_CONDITION@
1198gl_GNULIB_ENABLED_a9786850e999ae65a836a6041e8e5ed1 = @gl_GNULIB_ENABLED_a9786850e999ae65a836a6041e8e5ed1@ 1226gl_GNULIB_ENABLED_a9786850e999ae65a836a6041e8e5ed1_CONDITION = @gl_GNULIB_ENABLED_a9786850e999ae65a836a6041e8e5ed1_CONDITION@
1199gl_GNULIB_ENABLED_be453cec5eecf5731a274f2de7f2db36 = @gl_GNULIB_ENABLED_be453cec5eecf5731a274f2de7f2db36@ 1227gl_GNULIB_ENABLED_be453cec5eecf5731a274f2de7f2db36_CONDITION = @gl_GNULIB_ENABLED_be453cec5eecf5731a274f2de7f2db36_CONDITION@
1200gl_GNULIB_ENABLED_cloexec = @gl_GNULIB_ENABLED_cloexec@ 1228gl_GNULIB_ENABLED_cloexec_CONDITION = @gl_GNULIB_ENABLED_cloexec_CONDITION@
1201gl_GNULIB_ENABLED_d3b2383720ee0e541357aa2aac598e2b = @gl_GNULIB_ENABLED_d3b2383720ee0e541357aa2aac598e2b@ 1229gl_GNULIB_ENABLED_d3b2383720ee0e541357aa2aac598e2b_CONDITION = @gl_GNULIB_ENABLED_d3b2383720ee0e541357aa2aac598e2b_CONDITION@
1202gl_GNULIB_ENABLED_dirfd = @gl_GNULIB_ENABLED_dirfd@ 1230gl_GNULIB_ENABLED_dirfd_CONDITION = @gl_GNULIB_ENABLED_dirfd_CONDITION@
1203gl_GNULIB_ENABLED_dynarray = @gl_GNULIB_ENABLED_dynarray@ 1231gl_GNULIB_ENABLED_dynarray_CONDITION = @gl_GNULIB_ENABLED_dynarray_CONDITION@
1204gl_GNULIB_ENABLED_ef455225c00f5049c808c2eda3e76866 = @gl_GNULIB_ENABLED_ef455225c00f5049c808c2eda3e76866@ 1232gl_GNULIB_ENABLED_ef455225c00f5049c808c2eda3e76866_CONDITION = @gl_GNULIB_ENABLED_ef455225c00f5049c808c2eda3e76866_CONDITION@
1205gl_GNULIB_ENABLED_euidaccess = @gl_GNULIB_ENABLED_euidaccess@ 1233gl_GNULIB_ENABLED_euidaccess_CONDITION = @gl_GNULIB_ENABLED_euidaccess_CONDITION@
1206gl_GNULIB_ENABLED_getdtablesize = @gl_GNULIB_ENABLED_getdtablesize@ 1234gl_GNULIB_ENABLED_getdtablesize_CONDITION = @gl_GNULIB_ENABLED_getdtablesize_CONDITION@
1207gl_GNULIB_ENABLED_getgroups = @gl_GNULIB_ENABLED_getgroups@ 1235gl_GNULIB_ENABLED_getgroups_CONDITION = @gl_GNULIB_ENABLED_getgroups_CONDITION@
1208gl_GNULIB_ENABLED_lchmod = @gl_GNULIB_ENABLED_lchmod@ 1236gl_GNULIB_ENABLED_lchmod_CONDITION = @gl_GNULIB_ENABLED_lchmod_CONDITION@
1209gl_GNULIB_ENABLED_open = @gl_GNULIB_ENABLED_open@ 1237gl_GNULIB_ENABLED_open_CONDITION = @gl_GNULIB_ENABLED_open_CONDITION@
1210gl_GNULIB_ENABLED_rawmemchr = @gl_GNULIB_ENABLED_rawmemchr@ 1238gl_GNULIB_ENABLED_rawmemchr_CONDITION = @gl_GNULIB_ENABLED_rawmemchr_CONDITION@
1211gl_GNULIB_ENABLED_scratch_buffer = @gl_GNULIB_ENABLED_scratch_buffer@ 1239gl_GNULIB_ENABLED_scratch_buffer_CONDITION = @gl_GNULIB_ENABLED_scratch_buffer_CONDITION@
1212gl_GNULIB_ENABLED_strtoll = @gl_GNULIB_ENABLED_strtoll@ 1240gl_GNULIB_ENABLED_strtoll_CONDITION = @gl_GNULIB_ENABLED_strtoll_CONDITION@
1213gl_GNULIB_ENABLED_utimens = @gl_GNULIB_ENABLED_utimens@ 1241gl_GNULIB_ENABLED_utimens_CONDITION = @gl_GNULIB_ENABLED_utimens_CONDITION@
1214gl_LIBOBJS = @gl_LIBOBJS@ 1242gl_LIBOBJS = @gl_LIBOBJS@
1215gl_LTLIBOBJS = @gl_LTLIBOBJS@ 1243gl_LTLIBOBJS = @gl_LTLIBOBJS@
1216gltests_LIBOBJS = @gltests_LIBOBJS@ 1244gltests_LIBOBJS = @gltests_LIBOBJS@
1217gltests_LTLIBOBJS = @gltests_LTLIBOBJS@ 1245gltests_LTLIBOBJS = @gltests_LTLIBOBJS@
1218gltests_WITNESS = @gltests_WITNESS@ 1246gltests_WITNESS = @gltests_WITNESS@
1247gsettingsschemadir = @gsettingsschemadir@
1219host = @host@ 1248host = @host@
1220host_alias = @host_alias@ 1249host_alias = @host_alias@
1221host_cpu = @host_cpu@ 1250host_cpu = @host_cpu@
@@ -1296,9 +1325,10 @@ BUILT_SOURCES += $(ALLOCA_H)
1296 1325
1297# We need the following in order to create <alloca.h> when the system 1326# We need the following in order to create <alloca.h> when the system
1298# doesn't have one that works with the given compiler. 1327# doesn't have one that works with the given compiler.
1299ifneq (,$(GL_GENERATE_ALLOCA_H)) 1328ifneq (,$(GL_GENERATE_ALLOCA_H_CONDITION))
1300alloca.h: alloca.in.h $(top_builddir)/config.status 1329alloca.h: alloca.in.h $(top_builddir)/config.status
1301 $(AM_V_GEN)rm -f $@-t $@ && \ 1330 $(AM_V_GEN)rm -f $@-t $@ && \
1331 $(MKDIR_P) '.' && \
1302 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ 1332 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
1303 sed -e 's|@''HAVE_ALLOCA_H''@|$(HAVE_ALLOCA_H)|g' < $(srcdir)/alloca.in.h; \ 1333 sed -e 's|@''HAVE_ALLOCA_H''@|$(HAVE_ALLOCA_H)|g' < $(srcdir)/alloca.in.h; \
1304 } > $@-t && \ 1334 } > $@-t && \
@@ -1327,7 +1357,7 @@ endif
1327## begin gnulib module at-internal 1357## begin gnulib module at-internal
1328ifeq (,$(OMIT_GNULIB_MODULE_at-internal)) 1358ifeq (,$(OMIT_GNULIB_MODULE_at-internal))
1329 1359
1330ifneq (,$(gl_GNULIB_ENABLED_260941c0e5dc67ec9e87d1fb321c300b)) 1360ifneq (,$(gl_GNULIB_ENABLED_260941c0e5dc67ec9e87d1fb321c300b_CONDITION))
1331libgnu_a_SOURCES += openat-priv.h openat-proc.c 1361libgnu_a_SOURCES += openat-priv.h openat-proc.c
1332 1362
1333endif 1363endif
@@ -1358,9 +1388,10 @@ BUILT_SOURCES += $(BYTESWAP_H)
1358 1388
1359# We need the following in order to create <byteswap.h> when the system 1389# We need the following in order to create <byteswap.h> when the system
1360# doesn't have one. 1390# doesn't have one.
1361ifneq (,$(GL_GENERATE_BYTESWAP_H)) 1391ifneq (,$(GL_GENERATE_BYTESWAP_H_CONDITION))
1362byteswap.h: byteswap.in.h $(top_builddir)/config.status 1392byteswap.h: byteswap.in.h $(top_builddir)/config.status
1363 $(AM_V_GEN)rm -f $@-t $@ && \ 1393 $(AM_V_GEN)rm -f $@-t $@ && \
1394 $(MKDIR_P) '.' && \
1364 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ 1395 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
1365 cat $(srcdir)/byteswap.in.h; \ 1396 cat $(srcdir)/byteswap.in.h; \
1366 } > $@-t && \ 1397 } > $@-t && \
@@ -1416,7 +1447,7 @@ endif
1416## begin gnulib module cloexec 1447## begin gnulib module cloexec
1417ifeq (,$(OMIT_GNULIB_MODULE_cloexec)) 1448ifeq (,$(OMIT_GNULIB_MODULE_cloexec))
1418 1449
1419ifneq (,$(gl_GNULIB_ENABLED_cloexec)) 1450ifneq (,$(gl_GNULIB_ENABLED_cloexec_CONDITION))
1420libgnu_a_SOURCES += cloexec.c 1451libgnu_a_SOURCES += cloexec.c
1421 1452
1422endif 1453endif
@@ -1541,6 +1572,7 @@ BUILT_SOURCES += dirent.h
1541# doesn't have one that works with the given compiler. 1572# doesn't have one that works with the given compiler.
1542dirent.h: dirent.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) 1573dirent.h: dirent.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
1543 $(AM_V_GEN)rm -f $@-t $@ && \ 1574 $(AM_V_GEN)rm -f $@-t $@ && \
1575 $(MKDIR_P) '.' && \
1544 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ 1576 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
1545 sed -e 's|@''GUARD_PREFIX''@|GL|g' \ 1577 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
1546 -e 's|@''HAVE_DIRENT_H''@|$(HAVE_DIRENT_H)|g' \ 1578 -e 's|@''HAVE_DIRENT_H''@|$(HAVE_DIRENT_H)|g' \
@@ -1585,7 +1617,7 @@ endif
1585## begin gnulib module dirfd 1617## begin gnulib module dirfd
1586ifeq (,$(OMIT_GNULIB_MODULE_dirfd)) 1618ifeq (,$(OMIT_GNULIB_MODULE_dirfd))
1587 1619
1588ifneq (,$(gl_GNULIB_ENABLED_dirfd)) 1620ifneq (,$(gl_GNULIB_ENABLED_dirfd_CONDITION))
1589 1621
1590endif 1622endif
1591EXTRA_DIST += dirfd.c 1623EXTRA_DIST += dirfd.c
@@ -1629,11 +1661,11 @@ endif
1629## begin gnulib module dynarray 1661## begin gnulib module dynarray
1630ifeq (,$(OMIT_GNULIB_MODULE_dynarray)) 1662ifeq (,$(OMIT_GNULIB_MODULE_dynarray))
1631 1663
1632ifneq (,$(gl_GNULIB_ENABLED_dynarray)) 1664ifneq (,$(gl_GNULIB_ENABLED_dynarray_CONDITION))
1633BUILT_SOURCES += malloc/dynarray.gl.h malloc/dynarray-skeleton.gl.h 1665BUILT_SOURCES += malloc/dynarray.gl.h malloc/dynarray-skeleton.gl.h
1634 1666
1635malloc/dynarray.gl.h: malloc/dynarray.h 1667malloc/dynarray.gl.h: malloc/dynarray.h
1636 $(AM_V_at)$(MKDIR_P) malloc 1668 $(AM_V_at)$(MKDIR_P) 'malloc'
1637 $(AM_V_GEN)rm -f $@-t $@ && \ 1669 $(AM_V_GEN)rm -f $@-t $@ && \
1638 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ 1670 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
1639 sed -e '/libc_hidden_proto/d' < $(srcdir)/malloc/dynarray.h; \ 1671 sed -e '/libc_hidden_proto/d' < $(srcdir)/malloc/dynarray.h; \
@@ -1642,7 +1674,7 @@ malloc/dynarray.gl.h: malloc/dynarray.h
1642MOSTLYCLEANFILES += malloc/dynarray.gl.h malloc/dynarray.gl.h-t 1674MOSTLYCLEANFILES += malloc/dynarray.gl.h malloc/dynarray.gl.h-t
1643 1675
1644malloc/dynarray-skeleton.gl.h: malloc/dynarray-skeleton.c 1676malloc/dynarray-skeleton.gl.h: malloc/dynarray-skeleton.c
1645 $(AM_V_at)$(MKDIR_P) malloc 1677 $(AM_V_at)$(MKDIR_P) 'malloc'
1646 $(AM_V_GEN)rm -f $@-t $@ && \ 1678 $(AM_V_GEN)rm -f $@-t $@ && \
1647 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ 1679 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
1648 sed -e 's|<malloc/dynarray\.h>|<malloc/dynarray.gl.h>|g' \ 1680 sed -e 's|<malloc/dynarray\.h>|<malloc/dynarray.gl.h>|g' \
@@ -1669,7 +1701,7 @@ endif
1669## begin gnulib module eloop-threshold 1701## begin gnulib module eloop-threshold
1670ifeq (,$(OMIT_GNULIB_MODULE_eloop-threshold)) 1702ifeq (,$(OMIT_GNULIB_MODULE_eloop-threshold))
1671 1703
1672ifneq (,$(gl_GNULIB_ENABLED_925677f0343de64b89a9f0c790b4104c)) 1704ifneq (,$(gl_GNULIB_ENABLED_925677f0343de64b89a9f0c790b4104c_CONDITION))
1673 1705
1674endif 1706endif
1675EXTRA_DIST += eloop-threshold.h 1707EXTRA_DIST += eloop-threshold.h
@@ -1684,9 +1716,10 @@ BUILT_SOURCES += $(ERRNO_H)
1684 1716
1685# We need the following in order to create <errno.h> when the system 1717# We need the following in order to create <errno.h> when the system
1686# doesn't have one that is POSIX compliant. 1718# doesn't have one that is POSIX compliant.
1687ifneq (,$(GL_GENERATE_ERRNO_H)) 1719ifneq (,$(GL_GENERATE_ERRNO_H_CONDITION))
1688errno.h: errno.in.h $(top_builddir)/config.status 1720errno.h: errno.in.h $(top_builddir)/config.status
1689 $(AM_V_GEN)rm -f $@-t $@ && \ 1721 $(AM_V_GEN)rm -f $@-t $@ && \
1722 $(MKDIR_P) '.' && \
1690 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ 1723 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
1691 sed -e 's|@''GUARD_PREFIX''@|GL|g' \ 1724 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
1692 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ 1725 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
@@ -1716,7 +1749,7 @@ endif
1716## begin gnulib module euidaccess 1749## begin gnulib module euidaccess
1717ifeq (,$(OMIT_GNULIB_MODULE_euidaccess)) 1750ifeq (,$(OMIT_GNULIB_MODULE_euidaccess))
1718 1751
1719ifneq (,$(gl_GNULIB_ENABLED_euidaccess)) 1752ifneq (,$(gl_GNULIB_ENABLED_euidaccess_CONDITION))
1720 1753
1721endif 1754endif
1722EXTRA_DIST += euidaccess.c 1755EXTRA_DIST += euidaccess.c
@@ -1733,9 +1766,10 @@ BUILT_SOURCES += $(EXECINFO_H)
1733 1766
1734# We need the following in order to create <execinfo.h> when the system 1767# We need the following in order to create <execinfo.h> when the system
1735# doesn't have one that works. 1768# doesn't have one that works.
1736ifneq (,$(GL_GENERATE_EXECINFO_H)) 1769ifneq (,$(GL_GENERATE_EXECINFO_H_CONDITION))
1737execinfo.h: execinfo.in.h $(top_builddir)/config.status 1770execinfo.h: execinfo.in.h $(top_builddir)/config.status
1738 $(AM_V_GEN)rm -f $@-t $@ && \ 1771 $(AM_V_GEN)rm -f $@-t $@ && \
1772 $(MKDIR_P) '.' && \
1739 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ 1773 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
1740 cat $(srcdir)/execinfo.in.h; \ 1774 cat $(srcdir)/execinfo.in.h; \
1741 } > $@-t && \ 1775 } > $@-t && \
@@ -1806,6 +1840,7 @@ BUILT_SOURCES += fcntl.h
1806# doesn't have one that works with the given compiler. 1840# doesn't have one that works with the given compiler.
1807fcntl.h: fcntl.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) 1841fcntl.h: fcntl.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
1808 $(AM_V_GEN)rm -f $@-t $@ && \ 1842 $(AM_V_GEN)rm -f $@-t $@ && \
1843 $(MKDIR_P) '.' && \
1809 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ 1844 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
1810 sed -e 's|@''GUARD_PREFIX''@|GL|g' \ 1845 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
1811 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ 1846 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
@@ -1966,7 +2001,7 @@ endif
1966## begin gnulib module getdtablesize 2001## begin gnulib module getdtablesize
1967ifeq (,$(OMIT_GNULIB_MODULE_getdtablesize)) 2002ifeq (,$(OMIT_GNULIB_MODULE_getdtablesize))
1968 2003
1969ifneq (,$(gl_GNULIB_ENABLED_getdtablesize)) 2004ifneq (,$(gl_GNULIB_ENABLED_getdtablesize_CONDITION))
1970 2005
1971endif 2006endif
1972EXTRA_DIST += getdtablesize.c 2007EXTRA_DIST += getdtablesize.c
@@ -1979,7 +2014,7 @@ endif
1979## begin gnulib module getgroups 2014## begin gnulib module getgroups
1980ifeq (,$(OMIT_GNULIB_MODULE_getgroups)) 2015ifeq (,$(OMIT_GNULIB_MODULE_getgroups))
1981 2016
1982ifneq (,$(gl_GNULIB_ENABLED_getgroups)) 2017ifneq (,$(gl_GNULIB_ENABLED_getgroups_CONDITION))
1983 2018
1984endif 2019endif
1985EXTRA_DIST += getgroups.c 2020EXTRA_DIST += getgroups.c
@@ -2007,8 +2042,10 @@ BUILT_SOURCES += $(GETOPT_H) $(GETOPT_CDEFS_H)
2007 2042
2008# We need the following in order to create <getopt.h> when the system 2043# We need the following in order to create <getopt.h> when the system
2009# doesn't have one that works with the given compiler. 2044# doesn't have one that works with the given compiler.
2045ifneq (,$(GL_GENERATE_GETOPT_H_CONDITION))
2010getopt.h: getopt.in.h $(top_builddir)/config.status $(ARG_NONNULL_H) 2046getopt.h: getopt.in.h $(top_builddir)/config.status $(ARG_NONNULL_H)
2011 $(AM_V_GEN)rm -f $@-t $@ && \ 2047 $(AM_V_GEN)rm -f $@-t $@ && \
2048 $(MKDIR_P) '.' && \
2012 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ 2049 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
2013 sed -e 's|@''GUARD_PREFIX''@|GL|g' \ 2050 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
2014 -e 's|@''HAVE_GETOPT_H''@|$(HAVE_GETOPT_H)|g' \ 2051 -e 's|@''HAVE_GETOPT_H''@|$(HAVE_GETOPT_H)|g' \
@@ -2020,7 +2057,12 @@ getopt.h: getopt.in.h $(top_builddir)/config.status $(ARG_NONNULL_H)
2020 < $(srcdir)/getopt.in.h; \ 2057 < $(srcdir)/getopt.in.h; \
2021 } > $@-t && \ 2058 } > $@-t && \
2022 mv -f $@-t $@ 2059 mv -f $@-t $@
2060else
2061getopt.h: $(top_builddir)/config.status
2062 rm -f $@
2063endif
2023 2064
2065ifneq (,$(GL_GENERATE_GETOPT_CDEFS_H_CONDITION))
2024getopt-cdefs.h: getopt-cdefs.in.h $(top_builddir)/config.status 2066getopt-cdefs.h: getopt-cdefs.in.h $(top_builddir)/config.status
2025 $(AM_V_GEN)rm -f $@-t $@ && \ 2067 $(AM_V_GEN)rm -f $@-t $@ && \
2026 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ 2068 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
@@ -2028,6 +2070,10 @@ getopt-cdefs.h: getopt-cdefs.in.h $(top_builddir)/config.status
2028 < $(srcdir)/getopt-cdefs.in.h; \ 2070 < $(srcdir)/getopt-cdefs.in.h; \
2029 } > $@-t && \ 2071 } > $@-t && \
2030 mv -f $@-t $@ 2072 mv -f $@-t $@
2073else
2074getopt-cdefs.h: $(top_builddir)/config.status
2075 rm -f $@
2076endif
2031 2077
2032MOSTLYCLEANFILES += getopt.h getopt.h-t getopt-cdefs.h getopt-cdefs.h-t 2078MOSTLYCLEANFILES += getopt.h getopt.h-t getopt-cdefs.h getopt-cdefs.h-t
2033 2079
@@ -2052,7 +2098,7 @@ endif
2052## begin gnulib module gettext-h 2098## begin gnulib module gettext-h
2053ifeq (,$(OMIT_GNULIB_MODULE_gettext-h)) 2099ifeq (,$(OMIT_GNULIB_MODULE_gettext-h))
2054 2100
2055ifneq (,$(gl_GNULIB_ENABLED_be453cec5eecf5731a274f2de7f2db36)) 2101ifneq (,$(gl_GNULIB_ENABLED_be453cec5eecf5731a274f2de7f2db36_CONDITION))
2056libgnu_a_SOURCES += gettext.h 2102libgnu_a_SOURCES += gettext.h
2057 2103
2058endif 2104endif
@@ -2090,7 +2136,7 @@ endif
2090## begin gnulib module group-member 2136## begin gnulib module group-member
2091ifeq (,$(OMIT_GNULIB_MODULE_group-member)) 2137ifeq (,$(OMIT_GNULIB_MODULE_group-member))
2092 2138
2093ifneq (,$(gl_GNULIB_ENABLED_a9786850e999ae65a836a6041e8e5ed1)) 2139ifneq (,$(gl_GNULIB_ENABLED_a9786850e999ae65a836a6041e8e5ed1_CONDITION))
2094 2140
2095endif 2141endif
2096EXTRA_DIST += group-member.c 2142EXTRA_DIST += group-member.c
@@ -2115,9 +2161,10 @@ BUILT_SOURCES += $(IEEE754_H)
2115 2161
2116# We need the following in order to create <ieee754.h> when the system 2162# We need the following in order to create <ieee754.h> when the system
2117# doesn't have one that works with the given compiler. 2163# doesn't have one that works with the given compiler.
2118ifneq (,$(GL_GENERATE_IEEE754_H)) 2164ifneq (,$(GL_GENERATE_IEEE754_H_CONDITION))
2119ieee754.h: ieee754.in.h $(top_builddir)/config.status 2165ieee754.h: ieee754.in.h $(top_builddir)/config.status
2120 $(AM_V_GEN)rm -f $@-t && \ 2166 $(AM_V_GEN)rm -f $@-t && \
2167 $(MKDIR_P) '.' && \
2121 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ 2168 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
2122 sed -e 's/ifndef _GL_GNULIB_HEADER/if 0/g' \ 2169 sed -e 's/ifndef _GL_GNULIB_HEADER/if 0/g' \
2123 $(srcdir)/ieee754.in.h; \ 2170 $(srcdir)/ieee754.in.h; \
@@ -2161,6 +2208,7 @@ BUILT_SOURCES += inttypes.h
2161# doesn't have one that works with the given compiler. 2208# doesn't have one that works with the given compiler.
2162inttypes.h: inttypes.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H) $(ARG_NONNULL_H) 2209inttypes.h: inttypes.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H) $(ARG_NONNULL_H)
2163 $(AM_V_GEN)rm -f $@-t $@ && \ 2210 $(AM_V_GEN)rm -f $@-t $@ && \
2211 $(MKDIR_P) '.' && \
2164 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ 2212 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
2165 sed -e 's/@''HAVE_INTTYPES_H''@/$(HAVE_INTTYPES_H)/g' \ 2213 sed -e 's/@''HAVE_INTTYPES_H''@/$(HAVE_INTTYPES_H)/g' \
2166 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ 2214 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
@@ -2200,7 +2248,7 @@ endif
2200## begin gnulib module lchmod 2248## begin gnulib module lchmod
2201ifeq (,$(OMIT_GNULIB_MODULE_lchmod)) 2249ifeq (,$(OMIT_GNULIB_MODULE_lchmod))
2202 2250
2203ifneq (,$(gl_GNULIB_ENABLED_lchmod)) 2251ifneq (,$(gl_GNULIB_ENABLED_lchmod_CONDITION))
2204 2252
2205endif 2253endif
2206EXTRA_DIST += lchmod.c 2254EXTRA_DIST += lchmod.c
@@ -2224,22 +2272,25 @@ ifeq (,$(OMIT_GNULIB_MODULE_libgmp))
2224 2272
2225BUILT_SOURCES += $(GMP_H) 2273BUILT_SOURCES += $(GMP_H)
2226 2274
2227ifneq (,$(GL_GENERATE_MINI_GMP_H)) 2275ifneq (,$(GL_GENERATE_GMP_H_CONDITION))
2276ifneq (,$(GL_GENERATE_MINI_GMP_H_CONDITION))
2228# Build gmp.h as a wrapper for mini-gmp.h when using mini-gmp. 2277# Build gmp.h as a wrapper for mini-gmp.h when using mini-gmp.
2229gmp.h: $(top_builddir)/config.status 2278gmp.h: $(top_builddir)/config.status
2230 echo '#include "mini-gmp.h"' >$@-t 2279 $(MKDIR_P) '.'
2280 echo '#include "mini-gmp.h"' > $@-t
2231 mv $@-t $@ 2281 mv $@-t $@
2232else 2282endif
2233ifneq (,$(GL_GENERATE_GMP_GMP_H)) 2283ifneq (,$(GL_GENERATE_GMP_GMP_H_CONDITION))
2234# Build gmp.h as a wrapper for gmp/gmp.h. 2284# Build gmp.h as a wrapper for gmp/gmp.h.
2235gmp.h: $(top_builddir)/config.status 2285gmp.h: $(top_builddir)/config.status
2236 echo '#include <gmp/gmp.h>' >$@-t 2286 $(MKDIR_P) '.'
2287 echo '#include <gmp/gmp.h>' > $@-t
2237 mv $@-t $@ 2288 mv $@-t $@
2289endif
2238else 2290else
2239gmp.h: $(top_builddir)/config.status 2291gmp.h: $(top_builddir)/config.status
2240 rm -f $@ 2292 rm -f $@
2241endif 2293endif
2242endif
2243MOSTLYCLEANFILES += gmp.h gmp.h-t 2294MOSTLYCLEANFILES += gmp.h gmp.h-t
2244 2295
2245EXTRA_DIST += mini-gmp-gnulib.c mini-gmp.c mini-gmp.h 2296EXTRA_DIST += mini-gmp-gnulib.c mini-gmp.c mini-gmp.h
@@ -2256,9 +2307,10 @@ BUILT_SOURCES += $(LIMITS_H)
2256 2307
2257# We need the following in order to create <limits.h> when the system 2308# We need the following in order to create <limits.h> when the system
2258# doesn't have one that is compatible with GNU. 2309# doesn't have one that is compatible with GNU.
2259ifneq (,$(GL_GENERATE_LIMITS_H)) 2310ifneq (,$(GL_GENERATE_LIMITS_H_CONDITION))
2260limits.h: limits.in.h $(top_builddir)/config.status 2311limits.h: limits.in.h $(top_builddir)/config.status
2261 $(AM_V_GEN)rm -f $@-t $@ && \ 2312 $(AM_V_GEN)rm -f $@-t $@ && \
2313 $(MKDIR_P) '.' && \
2262 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ 2314 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
2263 sed -e 's|@''GUARD_PREFIX''@|GL|g' \ 2315 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
2264 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ 2316 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
@@ -2293,7 +2345,7 @@ endif
2293## begin gnulib module malloc-posix 2345## begin gnulib module malloc-posix
2294ifeq (,$(OMIT_GNULIB_MODULE_malloc-posix)) 2346ifeq (,$(OMIT_GNULIB_MODULE_malloc-posix))
2295 2347
2296ifneq (,$(gl_GNULIB_ENABLED_ef455225c00f5049c808c2eda3e76866)) 2348ifneq (,$(gl_GNULIB_ENABLED_ef455225c00f5049c808c2eda3e76866_CONDITION))
2297 2349
2298endif 2350endif
2299EXTRA_DIST += malloc.c 2351EXTRA_DIST += malloc.c
@@ -2369,7 +2421,7 @@ endif
2369## begin gnulib module mktime-internal 2421## begin gnulib module mktime-internal
2370ifeq (,$(OMIT_GNULIB_MODULE_mktime-internal)) 2422ifeq (,$(OMIT_GNULIB_MODULE_mktime-internal))
2371 2423
2372ifneq (,$(gl_GNULIB_ENABLED_5264294aa0a5557541b53c8c741f7f31)) 2424ifneq (,$(gl_GNULIB_ENABLED_5264294aa0a5557541b53c8c741f7f31_CONDITION))
2373 2425
2374endif 2426endif
2375EXTRA_DIST += mktime-internal.h mktime.c 2427EXTRA_DIST += mktime-internal.h mktime.c
@@ -2402,7 +2454,7 @@ endif
2402## begin gnulib module open 2454## begin gnulib module open
2403ifeq (,$(OMIT_GNULIB_MODULE_open)) 2455ifeq (,$(OMIT_GNULIB_MODULE_open))
2404 2456
2405ifneq (,$(gl_GNULIB_ENABLED_open)) 2457ifneq (,$(gl_GNULIB_ENABLED_open_CONDITION))
2406 2458
2407endif 2459endif
2408EXTRA_DIST += open.c 2460EXTRA_DIST += open.c
@@ -2415,7 +2467,7 @@ endif
2415## begin gnulib module openat-h 2467## begin gnulib module openat-h
2416ifeq (,$(OMIT_GNULIB_MODULE_openat-h)) 2468ifeq (,$(OMIT_GNULIB_MODULE_openat-h))
2417 2469
2418ifneq (,$(gl_GNULIB_ENABLED_03e0aaad4cb89ca757653bd367a6ccb7)) 2470ifneq (,$(gl_GNULIB_ENABLED_03e0aaad4cb89ca757653bd367a6ccb7_CONDITION))
2419 2471
2420endif 2472endif
2421EXTRA_DIST += openat.h 2473EXTRA_DIST += openat.h
@@ -2473,7 +2525,7 @@ endif
2473## begin gnulib module rawmemchr 2525## begin gnulib module rawmemchr
2474ifeq (,$(OMIT_GNULIB_MODULE_rawmemchr)) 2526ifeq (,$(OMIT_GNULIB_MODULE_rawmemchr))
2475 2527
2476ifneq (,$(gl_GNULIB_ENABLED_rawmemchr)) 2528ifneq (,$(gl_GNULIB_ENABLED_rawmemchr_CONDITION))
2477 2529
2478endif 2530endif
2479EXTRA_DIST += rawmemchr.c rawmemchr.valgrind 2531EXTRA_DIST += rawmemchr.c rawmemchr.valgrind
@@ -2508,7 +2560,7 @@ endif
2508## begin gnulib module realloc-gnu 2560## begin gnulib module realloc-gnu
2509ifeq (,$(OMIT_GNULIB_MODULE_realloc-gnu)) 2561ifeq (,$(OMIT_GNULIB_MODULE_realloc-gnu))
2510 2562
2511ifneq (,$(gl_GNULIB_ENABLED_d3b2383720ee0e541357aa2aac598e2b)) 2563ifneq (,$(gl_GNULIB_ENABLED_d3b2383720ee0e541357aa2aac598e2b_CONDITION))
2512 2564
2513endif 2565endif
2514EXTRA_DIST += realloc.c 2566EXTRA_DIST += realloc.c
@@ -2521,7 +2573,7 @@ endif
2521## begin gnulib module realloc-posix 2573## begin gnulib module realloc-posix
2522ifeq (,$(OMIT_GNULIB_MODULE_realloc-posix)) 2574ifeq (,$(OMIT_GNULIB_MODULE_realloc-posix))
2523 2575
2524ifneq (,$(gl_GNULIB_ENABLED_61bcaca76b3e6f9ae55d57a1c3193bc4)) 2576ifneq (,$(gl_GNULIB_ENABLED_61bcaca76b3e6f9ae55d57a1c3193bc4_CONDITION))
2525 2577
2526endif 2578endif
2527EXTRA_DIST += realloc.c 2579EXTRA_DIST += realloc.c
@@ -2545,7 +2597,7 @@ endif
2545## begin gnulib module root-uid 2597## begin gnulib module root-uid
2546ifeq (,$(OMIT_GNULIB_MODULE_root-uid)) 2598ifeq (,$(OMIT_GNULIB_MODULE_root-uid))
2547 2599
2548ifneq (,$(gl_GNULIB_ENABLED_6099e9737f757db36c47fa9d9f02e88c)) 2600ifneq (,$(gl_GNULIB_ENABLED_6099e9737f757db36c47fa9d9f02e88c_CONDITION))
2549 2601
2550endif 2602endif
2551EXTRA_DIST += root-uid.h 2603EXTRA_DIST += root-uid.h
@@ -2556,11 +2608,11 @@ endif
2556## begin gnulib module scratch_buffer 2608## begin gnulib module scratch_buffer
2557ifeq (,$(OMIT_GNULIB_MODULE_scratch_buffer)) 2609ifeq (,$(OMIT_GNULIB_MODULE_scratch_buffer))
2558 2610
2559ifneq (,$(gl_GNULIB_ENABLED_scratch_buffer)) 2611ifneq (,$(gl_GNULIB_ENABLED_scratch_buffer_CONDITION))
2560BUILT_SOURCES += malloc/scratch_buffer.gl.h 2612BUILT_SOURCES += malloc/scratch_buffer.gl.h
2561 2613
2562malloc/scratch_buffer.gl.h: malloc/scratch_buffer.h 2614malloc/scratch_buffer.gl.h: malloc/scratch_buffer.h
2563 $(AM_V_at)$(MKDIR_P) malloc 2615 $(AM_V_at)$(MKDIR_P) 'malloc'
2564 $(AM_V_GEN)rm -f $@-t $@ && \ 2616 $(AM_V_GEN)rm -f $@-t $@ && \
2565 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ 2617 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
2566 sed -e 's|__always_inline|inline _GL_ATTRIBUTE_ALWAYS_INLINE|g' \ 2618 sed -e 's|__always_inline|inline _GL_ATTRIBUTE_ALWAYS_INLINE|g' \
@@ -2611,6 +2663,7 @@ BUILT_SOURCES += signal.h
2611# doesn't have a complete one. 2663# doesn't have a complete one.
2612signal.h: signal.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) 2664signal.h: signal.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
2613 $(AM_V_GEN)rm -f $@-t $@ && \ 2665 $(AM_V_GEN)rm -f $@-t $@ && \
2666 $(MKDIR_P) '.' && \
2614 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ 2667 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
2615 sed -e 's|@''GUARD_PREFIX''@|GL|g' \ 2668 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
2616 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ 2669 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
@@ -2719,9 +2772,10 @@ BUILT_SOURCES += $(STDALIGN_H)
2719 2772
2720# We need the following in order to create <stdalign.h> when the system 2773# We need the following in order to create <stdalign.h> when the system
2721# doesn't have one that works. 2774# doesn't have one that works.
2722ifneq (,$(GL_GENERATE_STDALIGN_H)) 2775ifneq (,$(GL_GENERATE_STDALIGN_H_CONDITION))
2723stdalign.h: stdalign.in.h $(top_builddir)/config.status 2776stdalign.h: stdalign.in.h $(top_builddir)/config.status
2724 $(AM_V_GEN)rm -f $@-t $@ && \ 2777 $(AM_V_GEN)rm -f $@-t $@ && \
2778 $(MKDIR_P) '.' && \
2725 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ 2779 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
2726 cat $(srcdir)/stdalign.in.h; \ 2780 cat $(srcdir)/stdalign.in.h; \
2727 } > $@-t && \ 2781 } > $@-t && \
@@ -2744,9 +2798,10 @@ BUILT_SOURCES += $(STDDEF_H)
2744 2798
2745# We need the following in order to create <stddef.h> when the system 2799# We need the following in order to create <stddef.h> when the system
2746# doesn't have one that works with the given compiler. 2800# doesn't have one that works with the given compiler.
2747ifneq (,$(GL_GENERATE_STDDEF_H)) 2801ifneq (,$(GL_GENERATE_STDDEF_H_CONDITION))
2748stddef.h: stddef.in.h $(top_builddir)/config.status 2802stddef.h: stddef.in.h $(top_builddir)/config.status
2749 $(AM_V_GEN)rm -f $@-t $@ && \ 2803 $(AM_V_GEN)rm -f $@-t $@ && \
2804 $(MKDIR_P) '.' && \
2750 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ 2805 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
2751 sed -e 's|@''GUARD_PREFIX''@|GL|g' \ 2806 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
2752 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ 2807 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
@@ -2777,9 +2832,10 @@ BUILT_SOURCES += $(STDINT_H)
2777 2832
2778# We need the following in order to create <stdint.h> when the system 2833# We need the following in order to create <stdint.h> when the system
2779# doesn't have one that works with the given compiler. 2834# doesn't have one that works with the given compiler.
2780ifneq (,$(GL_GENERATE_STDINT_H)) 2835ifneq (,$(GL_GENERATE_STDINT_H_CONDITION))
2781stdint.h: stdint.in.h $(top_builddir)/config.status 2836stdint.h: stdint.in.h $(top_builddir)/config.status
2782 $(AM_V_GEN)rm -f $@-t $@ && \ 2837 $(AM_V_GEN)rm -f $@-t $@ && \
2838 $(MKDIR_P) '.' && \
2783 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ 2839 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
2784 sed -e 's|@''GUARD_PREFIX''@|GL|g' \ 2840 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
2785 -e 's/@''HAVE_STDINT_H''@/$(HAVE_STDINT_H)/g' \ 2841 -e 's/@''HAVE_STDINT_H''@/$(HAVE_STDINT_H)/g' \
@@ -2831,6 +2887,7 @@ BUILT_SOURCES += stdio.h
2831# doesn't have one that works with the given compiler. 2887# doesn't have one that works with the given compiler.
2832stdio.h: stdio.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) 2888stdio.h: stdio.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
2833 $(AM_V_GEN)rm -f $@-t $@ && \ 2889 $(AM_V_GEN)rm -f $@-t $@ && \
2890 $(MKDIR_P) '.' && \
2834 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ 2891 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
2835 sed -e 's|@''GUARD_PREFIX''@|GL|g' \ 2892 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
2836 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ 2893 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
@@ -2969,6 +3026,7 @@ BUILT_SOURCES += stdlib.h
2969stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \ 3026stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \
2970 $(_NORETURN_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) 3027 $(_NORETURN_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
2971 $(AM_V_GEN)rm -f $@-t $@ && \ 3028 $(AM_V_GEN)rm -f $@-t $@ && \
3029 $(MKDIR_P) '.' && \
2972 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ 3030 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
2973 sed -e 's|@''GUARD_PREFIX''@|GL|g' \ 3031 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
2974 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ 3032 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
@@ -3125,6 +3183,7 @@ BUILT_SOURCES += string.h
3125# doesn't have one that works with the given compiler. 3183# doesn't have one that works with the given compiler.
3126string.h: string.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) 3184string.h: string.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
3127 $(AM_V_GEN)rm -f $@-t $@ && \ 3185 $(AM_V_GEN)rm -f $@-t $@ && \
3186 $(MKDIR_P) '.' && \
3128 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ 3187 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
3129 sed -e 's|@''GUARD_PREFIX''@|GL|g' \ 3188 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
3130 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ 3189 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
@@ -3256,7 +3315,7 @@ endif
3256## begin gnulib module strtoll 3315## begin gnulib module strtoll
3257ifeq (,$(OMIT_GNULIB_MODULE_strtoll)) 3316ifeq (,$(OMIT_GNULIB_MODULE_strtoll))
3258 3317
3259ifneq (,$(gl_GNULIB_ENABLED_strtoll)) 3318ifneq (,$(gl_GNULIB_ENABLED_strtoll_CONDITION))
3260 3319
3261endif 3320endif
3262EXTRA_DIST += strtol.c strtoll.c 3321EXTRA_DIST += strtol.c strtoll.c
@@ -3285,7 +3344,7 @@ BUILT_SOURCES += sys/random.h
3285# We need the following in order to create <sys/random.h> when the system 3344# We need the following in order to create <sys/random.h> when the system
3286# doesn't have one. 3345# doesn't have one.
3287sys/random.h: sys_random.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) 3346sys/random.h: sys_random.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
3288 $(AM_V_at)$(MKDIR_P) sys 3347 $(AM_V_at)$(MKDIR_P) 'sys'
3289 $(AM_V_GEN)rm -f $@-t $@ && \ 3348 $(AM_V_GEN)rm -f $@-t $@ && \
3290 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ 3349 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
3291 sed -e 's|@''GUARD_PREFIX''@|GL|g' \ 3350 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
@@ -3319,7 +3378,7 @@ BUILT_SOURCES += sys/select.h
3319# We need the following in order to create <sys/select.h> when the system 3378# We need the following in order to create <sys/select.h> when the system
3320# doesn't have one that works with the given compiler. 3379# doesn't have one that works with the given compiler.
3321sys/select.h: sys_select.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H) 3380sys/select.h: sys_select.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H)
3322 $(AM_V_at)$(MKDIR_P) sys 3381 $(AM_V_at)$(MKDIR_P) 'sys'
3323 $(AM_V_GEN)rm -f $@-t $@ && \ 3382 $(AM_V_GEN)rm -f $@-t $@ && \
3324 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ 3383 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
3325 sed -e 's|@''GUARD_PREFIX''@|GL|g' \ 3384 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
@@ -3355,7 +3414,7 @@ BUILT_SOURCES += sys/stat.h
3355# We need the following in order to create <sys/stat.h> when the system 3414# We need the following in order to create <sys/stat.h> when the system
3356# has one that is incomplete. 3415# has one that is incomplete.
3357sys/stat.h: sys_stat.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) 3416sys/stat.h: sys_stat.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
3358 $(AM_V_at)$(MKDIR_P) sys 3417 $(AM_V_at)$(MKDIR_P) 'sys'
3359 $(AM_V_GEN)rm -f $@-t $@ && \ 3418 $(AM_V_GEN)rm -f $@-t $@ && \
3360 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ 3419 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
3361 sed -e 's|@''GUARD_PREFIX''@|GL|g' \ 3420 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
@@ -3430,7 +3489,7 @@ BUILT_SOURCES += sys/time.h
3430# We need the following in order to create <sys/time.h> when the system 3489# We need the following in order to create <sys/time.h> when the system
3431# doesn't have one that works with the given compiler. 3490# doesn't have one that works with the given compiler.
3432sys/time.h: sys_time.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) 3491sys/time.h: sys_time.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
3433 $(AM_V_at)$(MKDIR_P) sys 3492 $(AM_V_at)$(MKDIR_P) 'sys'
3434 $(AM_V_GEN)rm -f $@-t $@ && \ 3493 $(AM_V_GEN)rm -f $@-t $@ && \
3435 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ 3494 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
3436 sed -e 's|@''GUARD_PREFIX''@|GL|g' \ 3495 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
@@ -3466,7 +3525,7 @@ BUILT_SOURCES += sys/types.h
3466# We need the following in order to create <sys/types.h> when the system 3525# We need the following in order to create <sys/types.h> when the system
3467# doesn't have one that works with the given compiler. 3526# doesn't have one that works with the given compiler.
3468sys/types.h: sys_types.in.h $(top_builddir)/config.status 3527sys/types.h: sys_types.in.h $(top_builddir)/config.status
3469 $(AM_V_at)$(MKDIR_P) sys 3528 $(AM_V_at)$(MKDIR_P) 'sys'
3470 $(AM_V_GEN)rm -f $@-t $@ && \ 3529 $(AM_V_GEN)rm -f $@-t $@ && \
3471 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ 3530 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
3472 sed -e 's|@''GUARD_PREFIX''@|GL|g' \ 3531 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
@@ -3505,6 +3564,7 @@ BUILT_SOURCES += time.h
3505# doesn't have one that works with the given compiler. 3564# doesn't have one that works with the given compiler.
3506time.h: time.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) 3565time.h: time.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
3507 $(AM_V_GEN)rm -f $@-t $@ && \ 3566 $(AM_V_GEN)rm -f $@-t $@ && \
3567 $(MKDIR_P) '.' && \
3508 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ 3568 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
3509 sed -e 's|@''GUARD_PREFIX''@|GL|g' \ 3569 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
3510 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ 3570 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
@@ -3635,6 +3695,7 @@ libgnu_a_SOURCES += unistd.c
3635# <unistd.h> when the system doesn't have one. 3695# <unistd.h> when the system doesn't have one.
3636unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) 3696unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
3637 $(AM_V_GEN)rm -f $@-t $@ && \ 3697 $(AM_V_GEN)rm -f $@-t $@ && \
3698 $(MKDIR_P) '.' && \
3638 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ 3699 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
3639 sed -e 's|@''GUARD_PREFIX''@|GL|g' \ 3700 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
3640 -e 's|@''HAVE_UNISTD_H''@|$(HAVE_UNISTD_H)|g' \ 3701 -e 's|@''HAVE_UNISTD_H''@|$(HAVE_UNISTD_H)|g' \
@@ -3853,7 +3914,7 @@ endif
3853## begin gnulib module utimens 3914## begin gnulib module utimens
3854ifeq (,$(OMIT_GNULIB_MODULE_utimens)) 3915ifeq (,$(OMIT_GNULIB_MODULE_utimens))
3855 3916
3856ifneq (,$(gl_GNULIB_ENABLED_utimens)) 3917ifneq (,$(gl_GNULIB_ENABLED_utimens_CONDITION))
3857libgnu_a_SOURCES += utimens.c 3918libgnu_a_SOURCES += utimens.c
3858 3919
3859endif 3920endif
@@ -3894,7 +3955,7 @@ endif
3894## begin gnulib module xalloc-oversized 3955## begin gnulib module xalloc-oversized
3895ifeq (,$(OMIT_GNULIB_MODULE_xalloc-oversized)) 3956ifeq (,$(OMIT_GNULIB_MODULE_xalloc-oversized))
3896 3957
3897ifneq (,$(gl_GNULIB_ENABLED_682e609604ccaac6be382e4ee3a4eaec)) 3958ifneq (,$(gl_GNULIB_ENABLED_682e609604ccaac6be382e4ee3a4eaec_CONDITION))
3898 3959
3899endif 3960endif
3900EXTRA_DIST += xalloc-oversized.h 3961EXTRA_DIST += xalloc-oversized.h
diff --git a/lib/intprops.h b/lib/intprops.h
index 3fe64e82e9f..7f20f09fa06 100644
--- a/lib/intprops.h
+++ b/lib/intprops.h
@@ -229,18 +229,18 @@
229 229
230/* True if __builtin_add_overflow (A, B, P) and __builtin_sub_overflow 230/* True if __builtin_add_overflow (A, B, P) and __builtin_sub_overflow
231 (A, B, P) work when P is non-null. */ 231 (A, B, P) work when P is non-null. */
232#if defined __has_builtin
233# define _GL_HAS_BUILTIN_ADD_OVERFLOW __has_builtin (__builtin_add_overflow)
232/* __builtin_{add,sub}_overflow exists but is not reliable in GCC 5.x and 6.x, 234/* __builtin_{add,sub}_overflow exists but is not reliable in GCC 5.x and 6.x,
233 see <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98269>. */ 235 see <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98269>. */
234#if 7 <= __GNUC__ && !defined __ICC 236#elif 7 <= __GNUC__ && !defined __EDG__
235# define _GL_HAS_BUILTIN_ADD_OVERFLOW 1 237# define _GL_HAS_BUILTIN_ADD_OVERFLOW 1
236#elif defined __has_builtin
237# define _GL_HAS_BUILTIN_ADD_OVERFLOW __has_builtin (__builtin_add_overflow)
238#else 238#else
239# define _GL_HAS_BUILTIN_ADD_OVERFLOW 0 239# define _GL_HAS_BUILTIN_ADD_OVERFLOW 0
240#endif 240#endif
241 241
242/* True if __builtin_mul_overflow (A, B, P) works when P is non-null. */ 242/* True if __builtin_mul_overflow (A, B, P) works when P is non-null. */
243#ifdef __clang__ 243#if defined __clang_major_ && __clang_major__ < 14
244/* Work around Clang bug <https://bugs.llvm.org/show_bug.cgi?id=16404>. */ 244/* Work around Clang bug <https://bugs.llvm.org/show_bug.cgi?id=16404>. */
245# define _GL_HAS_BUILTIN_MUL_OVERFLOW 0 245# define _GL_HAS_BUILTIN_MUL_OVERFLOW 0
246#else 246#else
@@ -249,9 +249,8 @@
249 249
250/* True if __builtin_add_overflow_p (A, B, C) works, and similarly for 250/* True if __builtin_add_overflow_p (A, B, C) works, and similarly for
251 __builtin_sub_overflow_p and __builtin_mul_overflow_p. */ 251 __builtin_sub_overflow_p and __builtin_mul_overflow_p. */
252#if defined __clang__ || defined __ICC 252#ifdef __EDG__
253/* Clang 11 lacks __builtin_mul_overflow_p, and even if it did it 253/* In EDG-based compilers like ICC 2021.3 and earlier,
254 would presumably run afoul of Clang bug 16404. ICC 2021.1's
255 __builtin_add_overflow_p etc. are not treated as integral constant 254 __builtin_add_overflow_p etc. are not treated as integral constant
256 expressions even when all arguments are. */ 255 expressions even when all arguments are. */
257# define _GL_HAS_BUILTIN_OVERFLOW_P 0 256# define _GL_HAS_BUILTIN_OVERFLOW_P 0
@@ -400,7 +399,7 @@
400#if _GL_HAS_BUILTIN_MUL_OVERFLOW 399#if _GL_HAS_BUILTIN_MUL_OVERFLOW
401# if ((9 < __GNUC__ + (3 <= __GNUC_MINOR__) \ 400# if ((9 < __GNUC__ + (3 <= __GNUC_MINOR__) \
402 || (__GNUC__ == 8 && 4 <= __GNUC_MINOR__)) \ 401 || (__GNUC__ == 8 && 4 <= __GNUC_MINOR__)) \
403 && !defined __ICC) 402 && !defined __EDG__)
404# define INT_MULTIPLY_WRAPV(a, b, r) __builtin_mul_overflow (a, b, r) 403# define INT_MULTIPLY_WRAPV(a, b, r) __builtin_mul_overflow (a, b, r)
405# else 404# else
406 /* Work around GCC bug 91450. */ 405 /* Work around GCC bug 91450. */
diff --git a/lib/nproc.c b/lib/nproc.c
index a9e369dd3f7..1af989d6dd0 100644
--- a/lib/nproc.c
+++ b/lib/nproc.c
@@ -307,10 +307,11 @@ num_processors_ignoring_omp (enum nproc_query query)
307 NPROC_CURRENT and NPROC_ALL. */ 307 NPROC_CURRENT and NPROC_ALL. */
308 308
309#if HAVE_SYSCTL && ! defined __GLIBC__ && defined HW_NCPU 309#if HAVE_SYSCTL && ! defined __GLIBC__ && defined HW_NCPU
310 { /* This works on Mac OS X, FreeBSD, NetBSD, OpenBSD. */ 310 { /* This works on macOS, FreeBSD, NetBSD, OpenBSD.
311 macOS 10.14 does not allow mib to be const. */
311 int nprocs; 312 int nprocs;
312 size_t len = sizeof (nprocs); 313 size_t len = sizeof (nprocs);
313 static int const mib[][2] = { 314 static int mib[][2] = {
314# ifdef HW_NCPUONLINE 315# ifdef HW_NCPUONLINE
315 { CTL_HW, HW_NCPUONLINE }, 316 { CTL_HW, HW_NCPUONLINE },
316# endif 317# endif
diff --git a/lib/nstrftime.c b/lib/nstrftime.c
index 7f258e8727f..25baf76c60f 100644
--- a/lib/nstrftime.c
+++ b/lib/nstrftime.c
@@ -22,7 +22,7 @@
22# define HAVE_TZNAME 1 22# define HAVE_TZNAME 1
23# include "../locale/localeinfo.h" 23# include "../locale/localeinfo.h"
24#else 24#else
25# include <config.h> 25# include <libc-config.h>
26# if FPRINTFTIME 26# if FPRINTFTIME
27# include "fprintftime.h" 27# include "fprintftime.h"
28# else 28# else
@@ -367,10 +367,7 @@ tm_diff (const struct tm *a, const struct tm *b)
367#define ISO_WEEK1_WDAY 4 /* Thursday */ 367#define ISO_WEEK1_WDAY 4 /* Thursday */
368#define YDAY_MINIMUM (-366) 368#define YDAY_MINIMUM (-366)
369static int iso_week_days (int, int); 369static int iso_week_days (int, int);
370#if defined __GNUC__ || defined __clang__ 370static __inline int
371__inline__
372#endif
373static int
374iso_week_days (int yday, int wday) 371iso_week_days (int yday, int wday)
375{ 372{
376 /* Add enough to the first operand of % to make it nonnegative. */ 373 /* Add enough to the first operand of % to make it nonnegative. */
@@ -428,9 +425,7 @@ my_strftime (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize)
428 return __strftime_internal (s, STRFTIME_ARG (maxsize) format, tp, false, 425 return __strftime_internal (s, STRFTIME_ARG (maxsize) format, tp, false,
429 0, -1, &tzset_called extra_args LOCALE_ARG); 426 0, -1, &tzset_called extra_args LOCALE_ARG);
430} 427}
431#if defined _LIBC && ! FPRINTFTIME
432libc_hidden_def (my_strftime) 428libc_hidden_def (my_strftime)
433#endif
434 429
435/* Just like my_strftime, above, but with more parameters. 430/* Just like my_strftime, above, but with more parameters.
436 UPCASE indicates that the result should be converted to upper case. 431 UPCASE indicates that the result should be converted to upper case.
diff --git a/lib/regcomp.c b/lib/regcomp.c
index 887e5b50684..6a97fdee478 100644
--- a/lib/regcomp.c
+++ b/lib/regcomp.c
@@ -27,14 +27,10 @@ static void re_compile_fastmap_iter (regex_t *bufp,
27 const re_dfastate_t *init_state, 27 const re_dfastate_t *init_state,
28 char *fastmap); 28 char *fastmap);
29static reg_errcode_t init_dfa (re_dfa_t *dfa, size_t pat_len); 29static reg_errcode_t init_dfa (re_dfa_t *dfa, size_t pat_len);
30#ifdef RE_ENABLE_I18N
31static void free_charset (re_charset_t *cset); 30static void free_charset (re_charset_t *cset);
32#endif /* RE_ENABLE_I18N */
33static void free_workarea_compile (regex_t *preg); 31static void free_workarea_compile (regex_t *preg);
34static reg_errcode_t create_initial_state (re_dfa_t *dfa); 32static reg_errcode_t create_initial_state (re_dfa_t *dfa);
35#ifdef RE_ENABLE_I18N
36static void optimize_utf8 (re_dfa_t *dfa); 33static void optimize_utf8 (re_dfa_t *dfa);
37#endif
38static reg_errcode_t analyze (regex_t *preg); 34static reg_errcode_t analyze (regex_t *preg);
39static reg_errcode_t preorder (bin_tree_t *root, 35static reg_errcode_t preorder (bin_tree_t *root,
40 reg_errcode_t (fn (void *, bin_tree_t *)), 36 reg_errcode_t (fn (void *, bin_tree_t *)),
@@ -89,7 +85,6 @@ static reg_errcode_t parse_bracket_element (bracket_elem_t *elem,
89static reg_errcode_t parse_bracket_symbol (bracket_elem_t *elem, 85static reg_errcode_t parse_bracket_symbol (bracket_elem_t *elem,
90 re_string_t *regexp, 86 re_string_t *regexp,
91 re_token_t *token); 87 re_token_t *token);
92#ifdef RE_ENABLE_I18N
93static reg_errcode_t build_equiv_class (bitset_t sbcset, 88static reg_errcode_t build_equiv_class (bitset_t sbcset,
94 re_charset_t *mbcset, 89 re_charset_t *mbcset,
95 Idx *equiv_class_alloc, 90 Idx *equiv_class_alloc,
@@ -100,14 +95,6 @@ static reg_errcode_t build_charclass (RE_TRANSLATE_TYPE trans,
100 Idx *char_class_alloc, 95 Idx *char_class_alloc,
101 const char *class_name, 96 const char *class_name,
102 reg_syntax_t syntax); 97 reg_syntax_t syntax);
103#else /* not RE_ENABLE_I18N */
104static reg_errcode_t build_equiv_class (bitset_t sbcset,
105 const unsigned char *name);
106static reg_errcode_t build_charclass (RE_TRANSLATE_TYPE trans,
107 bitset_t sbcset,
108 const char *class_name,
109 reg_syntax_t syntax);
110#endif /* not RE_ENABLE_I18N */
111static bin_tree_t *build_charclass_op (re_dfa_t *dfa, 98static bin_tree_t *build_charclass_op (re_dfa_t *dfa,
112 RE_TRANSLATE_TYPE trans, 99 RE_TRANSLATE_TYPE trans,
113 const char *class_name, 100 const char *class_name,
@@ -279,8 +266,7 @@ re_compile_fastmap (struct re_pattern_buffer *bufp)
279} 266}
280weak_alias (__re_compile_fastmap, re_compile_fastmap) 267weak_alias (__re_compile_fastmap, re_compile_fastmap)
281 268
282static inline void 269static __always_inline void
283__attribute__ ((always_inline))
284re_set_fastmap (char *fastmap, bool icase, int ch) 270re_set_fastmap (char *fastmap, bool icase, int ch)
285{ 271{
286 fastmap[ch] = 1; 272 fastmap[ch] = 1;
@@ -306,7 +292,6 @@ re_compile_fastmap_iter (regex_t *bufp, const re_dfastate_t *init_state,
306 if (type == CHARACTER) 292 if (type == CHARACTER)
307 { 293 {
308 re_set_fastmap (fastmap, icase, dfa->nodes[node].opr.c); 294 re_set_fastmap (fastmap, icase, dfa->nodes[node].opr.c);
309#ifdef RE_ENABLE_I18N
310 if ((bufp->syntax & RE_ICASE) && dfa->mb_cur_max > 1) 295 if ((bufp->syntax & RE_ICASE) && dfa->mb_cur_max > 1)
311 { 296 {
312 unsigned char buf[MB_LEN_MAX]; 297 unsigned char buf[MB_LEN_MAX];
@@ -327,7 +312,6 @@ re_compile_fastmap_iter (regex_t *bufp, const re_dfastate_t *init_state,
327 != (size_t) -1)) 312 != (size_t) -1))
328 re_set_fastmap (fastmap, false, buf[0]); 313 re_set_fastmap (fastmap, false, buf[0]);
329 } 314 }
330#endif
331 } 315 }
332 else if (type == SIMPLE_BRACKET) 316 else if (type == SIMPLE_BRACKET)
333 { 317 {
@@ -341,13 +325,12 @@ re_compile_fastmap_iter (regex_t *bufp, const re_dfastate_t *init_state,
341 re_set_fastmap (fastmap, icase, ch); 325 re_set_fastmap (fastmap, icase, ch);
342 } 326 }
343 } 327 }
344#ifdef RE_ENABLE_I18N
345 else if (type == COMPLEX_BRACKET) 328 else if (type == COMPLEX_BRACKET)
346 { 329 {
347 re_charset_t *cset = dfa->nodes[node].opr.mbcset; 330 re_charset_t *cset = dfa->nodes[node].opr.mbcset;
348 Idx i; 331 Idx i;
349 332
350# ifdef _LIBC 333#ifdef _LIBC
351 /* See if we have to try all bytes which start multiple collation 334 /* See if we have to try all bytes which start multiple collation
352 elements. 335 elements.
353 e.g. In da_DK, we want to catch 'a' since "aa" is a valid 336 e.g. In da_DK, we want to catch 'a' since "aa" is a valid
@@ -363,7 +346,7 @@ re_compile_fastmap_iter (regex_t *bufp, const re_dfastate_t *init_state,
363 if (table[i] < 0) 346 if (table[i] < 0)
364 re_set_fastmap (fastmap, icase, i); 347 re_set_fastmap (fastmap, icase, i);
365 } 348 }
366# endif /* _LIBC */ 349#endif /* _LIBC */
367 350
368 /* See if we have to start the match at all multibyte characters, 351 /* See if we have to start the match at all multibyte characters,
369 i.e. where we would not find an invalid sequence. This only 352 i.e. where we would not find an invalid sequence. This only
@@ -371,9 +354,9 @@ re_compile_fastmap_iter (regex_t *bufp, const re_dfastate_t *init_state,
371 sets, the SIMPLE_BRACKET again suffices. */ 354 sets, the SIMPLE_BRACKET again suffices. */
372 if (dfa->mb_cur_max > 1 355 if (dfa->mb_cur_max > 1
373 && (cset->nchar_classes || cset->non_match || cset->nranges 356 && (cset->nchar_classes || cset->non_match || cset->nranges
374# ifdef _LIBC 357#ifdef _LIBC
375 || cset->nequiv_classes 358 || cset->nequiv_classes
376# endif /* _LIBC */ 359#endif /* _LIBC */
377 )) 360 ))
378 { 361 {
379 unsigned char c = 0; 362 unsigned char c = 0;
@@ -406,12 +389,7 @@ re_compile_fastmap_iter (regex_t *bufp, const re_dfastate_t *init_state,
406 } 389 }
407 } 390 }
408 } 391 }
409#endif /* RE_ENABLE_I18N */ 392 else if (type == OP_PERIOD || type == OP_UTF8_PERIOD || type == END_OF_RE)
410 else if (type == OP_PERIOD
411#ifdef RE_ENABLE_I18N
412 || type == OP_UTF8_PERIOD
413#endif /* RE_ENABLE_I18N */
414 || type == END_OF_RE)
415 { 393 {
416 memset (fastmap, '\1', sizeof (char) * SBC_MAX); 394 memset (fastmap, '\1', sizeof (char) * SBC_MAX);
417 if (type == END_OF_RE) 395 if (type == END_OF_RE)
@@ -550,7 +528,6 @@ regerror (int errcode, const regex_t *__restrict preg, char *__restrict errbuf,
550weak_alias (__regerror, regerror) 528weak_alias (__regerror, regerror)
551 529
552 530
553#ifdef RE_ENABLE_I18N
554/* This static array is used for the map to single-byte characters when 531/* This static array is used for the map to single-byte characters when
555 UTF-8 is used. Otherwise we would allocate memory just to initialize 532 UTF-8 is used. Otherwise we would allocate memory just to initialize
556 it the same all the time. UTF-8 is the preferred encoding so this is 533 it the same all the time. UTF-8 is the preferred encoding so this is
@@ -558,25 +535,24 @@ weak_alias (__regerror, regerror)
558static const bitset_t utf8_sb_map = 535static const bitset_t utf8_sb_map =
559{ 536{
560 /* Set the first 128 bits. */ 537 /* Set the first 128 bits. */
561# if (defined __GNUC__ || __clang_major__ >= 4) && !defined __STRICT_ANSI__ 538#if (defined __GNUC__ || __clang_major__ >= 4) && !defined __STRICT_ANSI__
562 [0 ... 0x80 / BITSET_WORD_BITS - 1] = BITSET_WORD_MAX 539 [0 ... 0x80 / BITSET_WORD_BITS - 1] = BITSET_WORD_MAX
563# else 540#else
564# if 4 * BITSET_WORD_BITS < ASCII_CHARS 541# if 4 * BITSET_WORD_BITS < ASCII_CHARS
565# error "bitset_word_t is narrower than 32 bits" 542# error "bitset_word_t is narrower than 32 bits"
566# elif 3 * BITSET_WORD_BITS < ASCII_CHARS 543# elif 3 * BITSET_WORD_BITS < ASCII_CHARS
567 BITSET_WORD_MAX, BITSET_WORD_MAX, BITSET_WORD_MAX, 544 BITSET_WORD_MAX, BITSET_WORD_MAX, BITSET_WORD_MAX,
568# elif 2 * BITSET_WORD_BITS < ASCII_CHARS 545# elif 2 * BITSET_WORD_BITS < ASCII_CHARS
569 BITSET_WORD_MAX, BITSET_WORD_MAX, 546 BITSET_WORD_MAX, BITSET_WORD_MAX,
570# elif 1 * BITSET_WORD_BITS < ASCII_CHARS 547# elif 1 * BITSET_WORD_BITS < ASCII_CHARS
571 BITSET_WORD_MAX, 548 BITSET_WORD_MAX,
572# endif 549# endif
573 (BITSET_WORD_MAX 550 (BITSET_WORD_MAX
574 >> (SBC_MAX % BITSET_WORD_BITS == 0 551 >> (SBC_MAX % BITSET_WORD_BITS == 0
575 ? 0 552 ? 0
576 : BITSET_WORD_BITS - SBC_MAX % BITSET_WORD_BITS)) 553 : BITSET_WORD_BITS - SBC_MAX % BITSET_WORD_BITS))
577# endif
578};
579#endif 554#endif
555};
580 556
581 557
582static void 558static void
@@ -614,10 +590,8 @@ free_dfa_content (re_dfa_t *dfa)
614 re_free (entry->array); 590 re_free (entry->array);
615 } 591 }
616 re_free (dfa->state_table); 592 re_free (dfa->state_table);
617#ifdef RE_ENABLE_I18N
618 if (dfa->sb_char != utf8_sb_map) 593 if (dfa->sb_char != utf8_sb_map)
619 re_free (dfa->sb_char); 594 re_free (dfa->sb_char);
620#endif
621 re_free (dfa->subexp_map); 595 re_free (dfa->subexp_map);
622#ifdef DEBUG 596#ifdef DEBUG
623 re_free (dfa->re_str); 597 re_free (dfa->re_str);
@@ -796,11 +770,9 @@ re_compile_internal (regex_t *preg, const char * pattern, size_t length,
796 if (__glibc_unlikely (err != REG_NOERROR)) 770 if (__glibc_unlikely (err != REG_NOERROR))
797 goto re_compile_internal_free_return; 771 goto re_compile_internal_free_return;
798 772
799#ifdef RE_ENABLE_I18N
800 /* If possible, do searching in single byte encoding to speed things up. */ 773 /* If possible, do searching in single byte encoding to speed things up. */
801 if (dfa->is_utf8 && !(syntax & RE_ICASE) && preg->translate == NULL) 774 if (dfa->is_utf8 && !(syntax & RE_ICASE) && preg->translate == NULL)
802 optimize_utf8 (dfa); 775 optimize_utf8 (dfa);
803#endif
804 776
805 /* Then create the initial state of the dfa. */ 777 /* Then create the initial state of the dfa. */
806 err = create_initial_state (dfa); 778 err = create_initial_state (dfa);
@@ -830,11 +802,7 @@ init_dfa (re_dfa_t *dfa, size_t pat_len)
830#ifndef _LIBC 802#ifndef _LIBC
831 const char *codeset_name; 803 const char *codeset_name;
832#endif 804#endif
833#ifdef RE_ENABLE_I18N
834 size_t max_i18n_object_size = MAX (sizeof (wchar_t), sizeof (wctype_t)); 805 size_t max_i18n_object_size = MAX (sizeof (wchar_t), sizeof (wctype_t));
835#else
836 size_t max_i18n_object_size = 0;
837#endif
838 size_t max_object_size = 806 size_t max_object_size =
839 MAX (sizeof (struct re_state_table_entry), 807 MAX (sizeof (struct re_state_table_entry),
840 MAX (sizeof (re_token_t), 808 MAX (sizeof (re_token_t),
@@ -886,7 +854,6 @@ init_dfa (re_dfa_t *dfa, size_t pat_len)
886 dfa->map_notascii = 0; 854 dfa->map_notascii = 0;
887#endif 855#endif
888 856
889#ifdef RE_ENABLE_I18N
890 if (dfa->mb_cur_max > 1) 857 if (dfa->mb_cur_max > 1)
891 { 858 {
892 if (dfa->is_utf8) 859 if (dfa->is_utf8)
@@ -906,14 +873,13 @@ init_dfa (re_dfa_t *dfa, size_t pat_len)
906 wint_t wch = __btowc (ch); 873 wint_t wch = __btowc (ch);
907 if (wch != WEOF) 874 if (wch != WEOF)
908 dfa->sb_char[i] |= (bitset_word_t) 1 << j; 875 dfa->sb_char[i] |= (bitset_word_t) 1 << j;
909# ifndef _LIBC 876#ifndef _LIBC
910 if (isascii (ch) && wch != ch) 877 if (isascii (ch) && wch != ch)
911 dfa->map_notascii = 1; 878 dfa->map_notascii = 1;
912# endif 879#endif
913 } 880 }
914 } 881 }
915 } 882 }
916#endif
917 883
918 if (__glibc_unlikely (dfa->nodes == NULL || dfa->state_table == NULL)) 884 if (__glibc_unlikely (dfa->nodes == NULL || dfa->state_table == NULL))
919 return REG_ESPACE; 885 return REG_ESPACE;
@@ -933,8 +899,6 @@ init_word_char (re_dfa_t *dfa)
933 dfa->word_ops_used = 1; 899 dfa->word_ops_used = 1;
934 if (__glibc_likely (dfa->map_notascii == 0)) 900 if (__glibc_likely (dfa->map_notascii == 0))
935 { 901 {
936 /* Avoid uint32_t and uint64_t as some non-GCC platforms lack
937 them, an issue when this code is used in Gnulib. */
938 bitset_word_t bits0 = 0x00000000; 902 bitset_word_t bits0 = 0x00000000;
939 bitset_word_t bits1 = 0x03ff0000; 903 bitset_word_t bits1 = 0x03ff0000;
940 bitset_word_t bits2 = 0x87fffffe; 904 bitset_word_t bits2 = 0x87fffffe;
@@ -1074,7 +1038,6 @@ create_initial_state (re_dfa_t *dfa)
1074 return REG_NOERROR; 1038 return REG_NOERROR;
1075} 1039}
1076 1040
1077#ifdef RE_ENABLE_I18N
1078/* If it is possible to do searching in single byte encoding instead of UTF-8 1041/* If it is possible to do searching in single byte encoding instead of UTF-8
1079 to speed things up, set dfa->mb_cur_max to 1, clear is_utf8 and change 1042 to speed things up, set dfa->mb_cur_max to 1, clear is_utf8 and change
1080 DFA nodes where needed. */ 1043 DFA nodes where needed. */
@@ -1154,7 +1117,6 @@ optimize_utf8 (re_dfa_t *dfa)
1154 dfa->is_utf8 = 0; 1117 dfa->is_utf8 = 0;
1155 dfa->has_mb_node = dfa->nbackref > 0 || has_period; 1118 dfa->has_mb_node = dfa->nbackref > 0 || has_period;
1156} 1119}
1157#endif
1158 1120
1159/* Analyze the structure tree, and calculate "first", "next", "edest", 1121/* Analyze the structure tree, and calculate "first", "next", "edest",
1160 "eclosure", and "inveclosure". */ 1122 "eclosure", and "inveclosure". */
@@ -1792,7 +1754,6 @@ peek_token (re_token_t *token, re_string_t *input, reg_syntax_t syntax)
1792 token->opr.c = c; 1754 token->opr.c = c;
1793 1755
1794 token->word_char = 0; 1756 token->word_char = 0;
1795#ifdef RE_ENABLE_I18N
1796 token->mb_partial = 0; 1757 token->mb_partial = 0;
1797 if (input->mb_cur_max > 1 1758 if (input->mb_cur_max > 1
1798 && !re_string_first_byte (input, re_string_cur_idx (input))) 1759 && !re_string_first_byte (input, re_string_cur_idx (input)))
@@ -1801,7 +1762,6 @@ peek_token (re_token_t *token, re_string_t *input, reg_syntax_t syntax)
1801 token->mb_partial = 1; 1762 token->mb_partial = 1;
1802 return 1; 1763 return 1;
1803 } 1764 }
1804#endif
1805 if (c == '\\') 1765 if (c == '\\')
1806 { 1766 {
1807 unsigned char c2; 1767 unsigned char c2;
@@ -1814,7 +1774,6 @@ peek_token (re_token_t *token, re_string_t *input, reg_syntax_t syntax)
1814 c2 = re_string_peek_byte_case (input, 1); 1774 c2 = re_string_peek_byte_case (input, 1);
1815 token->opr.c = c2; 1775 token->opr.c = c2;
1816 token->type = CHARACTER; 1776 token->type = CHARACTER;
1817#ifdef RE_ENABLE_I18N
1818 if (input->mb_cur_max > 1) 1777 if (input->mb_cur_max > 1)
1819 { 1778 {
1820 wint_t wc = re_string_wchar_at (input, 1779 wint_t wc = re_string_wchar_at (input,
@@ -1822,7 +1781,6 @@ peek_token (re_token_t *token, re_string_t *input, reg_syntax_t syntax)
1822 token->word_char = IS_WIDE_WORD_CHAR (wc) != 0; 1781 token->word_char = IS_WIDE_WORD_CHAR (wc) != 0;
1823 } 1782 }
1824 else 1783 else
1825#endif
1826 token->word_char = IS_WORD_CHAR (c2) != 0; 1784 token->word_char = IS_WORD_CHAR (c2) != 0;
1827 1785
1828 switch (c2) 1786 switch (c2)
@@ -1928,14 +1886,12 @@ peek_token (re_token_t *token, re_string_t *input, reg_syntax_t syntax)
1928 } 1886 }
1929 1887
1930 token->type = CHARACTER; 1888 token->type = CHARACTER;
1931#ifdef RE_ENABLE_I18N
1932 if (input->mb_cur_max > 1) 1889 if (input->mb_cur_max > 1)
1933 { 1890 {
1934 wint_t wc = re_string_wchar_at (input, re_string_cur_idx (input)); 1891 wint_t wc = re_string_wchar_at (input, re_string_cur_idx (input));
1935 token->word_char = IS_WIDE_WORD_CHAR (wc) != 0; 1892 token->word_char = IS_WIDE_WORD_CHAR (wc) != 0;
1936 } 1893 }
1937 else 1894 else
1938#endif
1939 token->word_char = IS_WORD_CHAR (token->opr.c); 1895 token->word_char = IS_WORD_CHAR (token->opr.c);
1940 1896
1941 switch (c) 1897 switch (c)
@@ -2027,14 +1983,12 @@ peek_token_bracket (re_token_t *token, re_string_t *input, reg_syntax_t syntax)
2027 c = re_string_peek_byte (input, 0); 1983 c = re_string_peek_byte (input, 0);
2028 token->opr.c = c; 1984 token->opr.c = c;
2029 1985
2030#ifdef RE_ENABLE_I18N
2031 if (input->mb_cur_max > 1 1986 if (input->mb_cur_max > 1
2032 && !re_string_first_byte (input, re_string_cur_idx (input))) 1987 && !re_string_first_byte (input, re_string_cur_idx (input)))
2033 { 1988 {
2034 token->type = CHARACTER; 1989 token->type = CHARACTER;
2035 return 1; 1990 return 1;
2036 } 1991 }
2037#endif /* RE_ENABLE_I18N */
2038 1992
2039 if (c == '\\' && (syntax & RE_BACKSLASH_ESCAPE_IN_LISTS) 1993 if (c == '\\' && (syntax & RE_BACKSLASH_ESCAPE_IN_LISTS)
2040 && re_string_cur_idx (input) + 1 < re_string_length (input)) 1994 && re_string_cur_idx (input) + 1 < re_string_length (input))
@@ -2256,7 +2210,6 @@ parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token,
2256 *err = REG_ESPACE; 2210 *err = REG_ESPACE;
2257 return NULL; 2211 return NULL;
2258 } 2212 }
2259#ifdef RE_ENABLE_I18N
2260 if (dfa->mb_cur_max > 1) 2213 if (dfa->mb_cur_max > 1)
2261 { 2214 {
2262 while (!re_string_eoi (regexp) 2215 while (!re_string_eoi (regexp)
@@ -2273,7 +2226,6 @@ parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token,
2273 } 2226 }
2274 } 2227 }
2275 } 2228 }
2276#endif
2277 break; 2229 break;
2278 2230
2279 case OP_OPEN_SUBEXP: 2231 case OP_OPEN_SUBEXP:
@@ -2666,40 +2618,30 @@ parse_dup_op (bin_tree_t *elem, re_string_t *regexp, re_dfa_t *dfa,
2666 2618
2667#ifndef _LIBC 2619#ifndef _LIBC
2668 2620
2669# ifdef RE_ENABLE_I18N
2670/* Convert the byte B to the corresponding wide character. In a 2621/* Convert the byte B to the corresponding wide character. In a
2671 unibyte locale, treat B as itself. In a multibyte locale, return 2622 unibyte locale, treat B as itself. In a multibyte locale, return
2672 WEOF if B is an encoding error. */ 2623 WEOF if B is an encoding error. */
2673static wint_t 2624static wint_t
2674parse_byte (unsigned char b, re_charset_t *mbcset) 2625parse_byte (unsigned char b, re_dfa_t const *dfa)
2675{ 2626{
2676 return mbcset == NULL ? b : __btowc (b); 2627 return dfa->mb_cur_max > 1 ? __btowc (b) : b;
2677} 2628}
2678# endif
2679 2629
2680 /* Local function for parse_bracket_exp only used in case of NOT _LIBC. 2630/* Local function for parse_bracket_exp used in _LIBC environment.
2681 Build the range expression which starts from START_ELEM, and ends 2631 Build the range expression which starts from START_ELEM, and ends
2682 at END_ELEM. The result are written to MBCSET and SBCSET. 2632 at END_ELEM. The result are written to MBCSET and SBCSET.
2683 RANGE_ALLOC is the allocated size of mbcset->range_starts, and 2633 RANGE_ALLOC is the allocated size of mbcset->range_starts, and
2684 mbcset->range_ends, is a pointer argument since we may 2634 mbcset->range_ends, is a pointer argument since we may
2685 update it. */ 2635 update it. */
2686 2636
2687static reg_errcode_t 2637static reg_errcode_t
2688# ifdef RE_ENABLE_I18N 2638build_range_exp (bitset_t sbcset, re_charset_t *mbcset, Idx *range_alloc,
2689build_range_exp (const reg_syntax_t syntax, 2639 bracket_elem_t *start_elem, bracket_elem_t *end_elem,
2690 bitset_t sbcset, 2640 re_dfa_t *dfa, reg_syntax_t syntax, uint_fast32_t nrules,
2691 re_charset_t *mbcset, 2641 const unsigned char *collseqmb, const char *collseqwc,
2692 Idx *range_alloc, 2642 int_fast32_t table_size, const void *symb_table,
2693 const bracket_elem_t *start_elem, 2643 const unsigned char *extra)
2694 const bracket_elem_t *end_elem)
2695# else /* not RE_ENABLE_I18N */
2696build_range_exp (const reg_syntax_t syntax,
2697 bitset_t sbcset,
2698 const bracket_elem_t *start_elem,
2699 const bracket_elem_t *end_elem)
2700# endif /* not RE_ENABLE_I18N */
2701{ 2644{
2702 unsigned int start_ch, end_ch;
2703 /* Equivalence Classes and Character Classes can't be a range start/end. */ 2645 /* Equivalence Classes and Character Classes can't be a range start/end. */
2704 if (__glibc_unlikely (start_elem->type == EQUIV_CLASS 2646 if (__glibc_unlikely (start_elem->type == EQUIV_CLASS
2705 || start_elem->type == CHAR_CLASS 2647 || start_elem->type == CHAR_CLASS
@@ -2715,110 +2657,88 @@ build_range_exp (const reg_syntax_t syntax,
2715 && strlen ((char *) end_elem->opr.name) > 1))) 2657 && strlen ((char *) end_elem->opr.name) > 1)))
2716 return REG_ECOLLATE; 2658 return REG_ECOLLATE;
2717 2659
2718# ifdef RE_ENABLE_I18N 2660 unsigned int
2719 {
2720 wchar_t wc;
2721 wint_t start_wc;
2722 wint_t end_wc;
2723
2724 start_ch = ((start_elem->type == SB_CHAR) ? start_elem->opr.ch 2661 start_ch = ((start_elem->type == SB_CHAR) ? start_elem->opr.ch
2725 : ((start_elem->type == COLL_SYM) ? start_elem->opr.name[0] 2662 : ((start_elem->type == COLL_SYM) ? start_elem->opr.name[0]
2726 : 0)); 2663 : 0)),
2727 end_ch = ((end_elem->type == SB_CHAR) ? end_elem->opr.ch 2664 end_ch = ((end_elem->type == SB_CHAR) ? end_elem->opr.ch
2728 : ((end_elem->type == COLL_SYM) ? end_elem->opr.name[0] 2665 : ((end_elem->type == COLL_SYM) ? end_elem->opr.name[0]
2729 : 0)); 2666 : 0));
2667 wint_t
2730 start_wc = ((start_elem->type == SB_CHAR || start_elem->type == COLL_SYM) 2668 start_wc = ((start_elem->type == SB_CHAR || start_elem->type == COLL_SYM)
2731 ? parse_byte (start_ch, mbcset) : start_elem->opr.wch); 2669 ? parse_byte (start_ch, dfa) : start_elem->opr.wch),
2732 end_wc = ((end_elem->type == SB_CHAR || end_elem->type == COLL_SYM) 2670 end_wc = ((end_elem->type == SB_CHAR || end_elem->type == COLL_SYM)
2733 ? parse_byte (end_ch, mbcset) : end_elem->opr.wch); 2671 ? parse_byte (end_ch, dfa) : end_elem->opr.wch);
2734 if (start_wc == WEOF || end_wc == WEOF)
2735 return REG_ECOLLATE;
2736 else if (__glibc_unlikely ((syntax & RE_NO_EMPTY_RANGES)
2737 && start_wc > end_wc))
2738 return REG_ERANGE;
2739
2740 /* Got valid collation sequence values, add them as a new entry.
2741 However, for !_LIBC we have no collation elements: if the
2742 character set is single byte, the single byte character set
2743 that we build below suffices. parse_bracket_exp passes
2744 no MBCSET if dfa->mb_cur_max == 1. */
2745 if (mbcset)
2746 {
2747 /* Check the space of the arrays. */
2748 if (__glibc_unlikely (*range_alloc == mbcset->nranges))
2749 {
2750 /* There is not enough space, need realloc. */
2751 wchar_t *new_array_start, *new_array_end;
2752 Idx new_nranges;
2753
2754 /* +1 in case of mbcset->nranges is 0. */
2755 new_nranges = 2 * mbcset->nranges + 1;
2756 /* Use realloc since mbcset->range_starts and mbcset->range_ends
2757 are NULL if *range_alloc == 0. */
2758 new_array_start = re_realloc (mbcset->range_starts, wchar_t,
2759 new_nranges);
2760 new_array_end = re_realloc (mbcset->range_ends, wchar_t,
2761 new_nranges);
2762 2672
2763 if (__glibc_unlikely (new_array_start == NULL 2673 if (start_wc == WEOF || end_wc == WEOF)
2764 || new_array_end == NULL)) 2674 return REG_ECOLLATE;
2765 { 2675 else if (__glibc_unlikely ((syntax & RE_NO_EMPTY_RANGES)
2766 re_free (new_array_start); 2676 && start_wc > end_wc))
2767 re_free (new_array_end); 2677 return REG_ERANGE;
2768 return REG_ESPACE;
2769 }
2770 2678
2771 mbcset->range_starts = new_array_start; 2679 /* Got valid collation sequence values, add them as a new entry.
2772 mbcset->range_ends = new_array_end; 2680 However, for !_LIBC we have no collation elements: if the
2773 *range_alloc = new_nranges; 2681 character set is single byte, the single byte character set
2774 } 2682 that we build below suffices. parse_bracket_exp passes
2683 no MBCSET if dfa->mb_cur_max == 1. */
2684 if (dfa->mb_cur_max > 1)
2685 {
2686 /* Check the space of the arrays. */
2687 if (__glibc_unlikely (*range_alloc == mbcset->nranges))
2688 {
2689 /* There is not enough space, need realloc. */
2690 wchar_t *new_array_start, *new_array_end;
2691 Idx new_nranges;
2775 2692
2776 mbcset->range_starts[mbcset->nranges] = start_wc; 2693 /* +1 in case of mbcset->nranges is 0. */
2777 mbcset->range_ends[mbcset->nranges++] = end_wc; 2694 new_nranges = 2 * mbcset->nranges + 1;
2778 } 2695 /* Use realloc since mbcset->range_starts and mbcset->range_ends
2696 are NULL if *range_alloc == 0. */
2697 new_array_start = re_realloc (mbcset->range_starts, wchar_t,
2698 new_nranges);
2699 new_array_end = re_realloc (mbcset->range_ends, wchar_t,
2700 new_nranges);
2701
2702 if (__glibc_unlikely (new_array_start == NULL
2703 || new_array_end == NULL))
2704 {
2705 re_free (new_array_start);
2706 re_free (new_array_end);
2707 return REG_ESPACE;
2708 }
2709
2710 mbcset->range_starts = new_array_start;
2711 mbcset->range_ends = new_array_end;
2712 *range_alloc = new_nranges;
2713 }
2714
2715 mbcset->range_starts[mbcset->nranges] = start_wc;
2716 mbcset->range_ends[mbcset->nranges++] = end_wc;
2717 }
2718
2719 /* Build the table for single byte characters. */
2720 for (wchar_t wc = 0; wc < SBC_MAX; ++wc)
2721 {
2722 if (start_wc <= wc && wc <= end_wc)
2723 bitset_set (sbcset, wc);
2724 }
2779 2725
2780 /* Build the table for single byte characters. */
2781 for (wc = 0; wc < SBC_MAX; ++wc)
2782 {
2783 if (start_wc <= wc && wc <= end_wc)
2784 bitset_set (sbcset, wc);
2785 }
2786 }
2787# else /* not RE_ENABLE_I18N */
2788 {
2789 unsigned int ch;
2790 start_ch = ((start_elem->type == SB_CHAR ) ? start_elem->opr.ch
2791 : ((start_elem->type == COLL_SYM) ? start_elem->opr.name[0]
2792 : 0));
2793 end_ch = ((end_elem->type == SB_CHAR ) ? end_elem->opr.ch
2794 : ((end_elem->type == COLL_SYM) ? end_elem->opr.name[0]
2795 : 0));
2796 if (start_ch > end_ch)
2797 return REG_ERANGE;
2798 /* Build the table for single byte characters. */
2799 for (ch = 0; ch < SBC_MAX; ++ch)
2800 if (start_ch <= ch && ch <= end_ch)
2801 bitset_set (sbcset, ch);
2802 }
2803# endif /* not RE_ENABLE_I18N */
2804 return REG_NOERROR; 2726 return REG_NOERROR;
2805} 2727}
2806#endif /* not _LIBC */ 2728#endif /* not _LIBC */
2807 2729
2808#ifndef _LIBC 2730#ifndef _LIBC
2809/* Helper function for parse_bracket_exp only used in case of NOT _LIBC.. 2731/* Helper function for parse_bracket_exp only used in case of NOT _LIBC.
2810 Build the collating element which is represented by NAME. 2732 Build the collating element which is represented by NAME.
2811 The result are written to MBCSET and SBCSET. 2733 The result are written to MBCSET and SBCSET.
2812 COLL_SYM_ALLOC is the allocated size of mbcset->coll_sym, is a 2734 COLL_SYM_ALLOC is the allocated size of mbcset->coll_sym, is a
2813 pointer argument since we may update it. */ 2735 pointer argument since we may update it. */
2814 2736
2815static reg_errcode_t 2737static reg_errcode_t
2816# ifdef RE_ENABLE_I18N
2817build_collating_symbol (bitset_t sbcset, re_charset_t *mbcset, 2738build_collating_symbol (bitset_t sbcset, re_charset_t *mbcset,
2818 Idx *coll_sym_alloc, const unsigned char *name) 2739 Idx *coll_sym_alloc, const unsigned char *name,
2819# else /* not RE_ENABLE_I18N */ 2740 uint_fast32_t nrules, int_fast32_t table_size,
2820build_collating_symbol (bitset_t sbcset, const unsigned char *name) 2741 const void *symb_table, const unsigned char *extra)
2821# endif /* not RE_ENABLE_I18N */
2822{ 2742{
2823 size_t name_len = strlen ((const char *) name); 2743 size_t name_len = strlen ((const char *) name);
2824 if (__glibc_unlikely (name_len != 1)) 2744 if (__glibc_unlikely (name_len != 1))
@@ -2831,271 +2751,280 @@ build_collating_symbol (bitset_t sbcset, const unsigned char *name)
2831} 2751}
2832#endif /* not _LIBC */ 2752#endif /* not _LIBC */
2833 2753
2834/* This function parse bracket expression like "[abc]", "[a-c]",
2835 "[[.a-a.]]" etc. */
2836
2837static bin_tree_t *
2838parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
2839 reg_syntax_t syntax, reg_errcode_t *err)
2840{
2841#ifdef _LIBC 2754#ifdef _LIBC
2842 const unsigned char *collseqmb; 2755/* Local function for parse_bracket_exp used in _LIBC environment.
2843 const char *collseqwc; 2756 Seek the collating symbol entry corresponding to NAME.
2844 uint32_t nrules; 2757 Return the index of the symbol in the SYMB_TABLE,
2845 int32_t table_size; 2758 or -1 if not found. */
2846 const int32_t *symb_table; 2759
2847 const unsigned char *extra; 2760static __always_inline int32_t
2848 2761seek_collating_symbol_entry (const unsigned char *name, size_t name_len,
2849 /* Local function for parse_bracket_exp used in _LIBC environment. 2762 const int32_t *symb_table,
2850 Seek the collating symbol entry corresponding to NAME. 2763 int_fast32_t table_size,
2851 Return the index of the symbol in the SYMB_TABLE, 2764 const unsigned char *extra)
2852 or -1 if not found. */ 2765{
2853 2766 int_fast32_t elem;
2854 auto inline int32_t
2855 __attribute__ ((always_inline))
2856 seek_collating_symbol_entry (const unsigned char *name, size_t name_len)
2857 {
2858 int32_t elem;
2859
2860 for (elem = 0; elem < table_size; elem++)
2861 if (symb_table[2 * elem] != 0)
2862 {
2863 int32_t idx = symb_table[2 * elem + 1];
2864 /* Skip the name of collating element name. */
2865 idx += 1 + extra[idx];
2866 if (/* Compare the length of the name. */
2867 name_len == extra[idx]
2868 /* Compare the name. */
2869 && memcmp (name, &extra[idx + 1], name_len) == 0)
2870 /* Yep, this is the entry. */
2871 return elem;
2872 }
2873 return -1;
2874 }
2875 2767
2876 /* Local function for parse_bracket_exp used in _LIBC environment. 2768 for (elem = 0; elem < table_size; elem++)
2877 Look up the collation sequence value of BR_ELEM. 2769 if (symb_table[2 * elem] != 0)
2878 Return the value if succeeded, UINT_MAX otherwise. */ 2770 {
2771 int32_t idx = symb_table[2 * elem + 1];
2772 /* Skip the name of collating element name. */
2773 idx += 1 + extra[idx];
2774 if (/* Compare the length of the name. */
2775 name_len == extra[idx]
2776 /* Compare the name. */
2777 && memcmp (name, &extra[idx + 1], name_len) == 0)
2778 /* Yep, this is the entry. */
2779 return elem;
2780 }
2781 return -1;
2782}
2879 2783
2880 auto inline unsigned int 2784/* Local function for parse_bracket_exp used in _LIBC environment.
2881 __attribute__ ((always_inline)) 2785 Look up the collation sequence value of BR_ELEM.
2882 lookup_collation_sequence_value (bracket_elem_t *br_elem) 2786 Return the value if succeeded, UINT_MAX otherwise. */
2787
2788static __always_inline unsigned int
2789lookup_collation_sequence_value (bracket_elem_t *br_elem, uint32_t nrules,
2790 const unsigned char *collseqmb,
2791 const char *collseqwc,
2792 int_fast32_t table_size,
2793 const int32_t *symb_table,
2794 const unsigned char *extra)
2795{
2796 if (br_elem->type == SB_CHAR)
2883 { 2797 {
2884 if (br_elem->type == SB_CHAR) 2798 /* if (MB_CUR_MAX == 1) */
2885 { 2799 if (nrules == 0)
2886 /* 2800 return collseqmb[br_elem->opr.ch];
2887 if (MB_CUR_MAX == 1) 2801 else
2888 */
2889 if (nrules == 0)
2890 return collseqmb[br_elem->opr.ch];
2891 else
2892 {
2893 wint_t wc = __btowc (br_elem->opr.ch);
2894 return __collseq_table_lookup (collseqwc, wc);
2895 }
2896 }
2897 else if (br_elem->type == MB_CHAR)
2898 { 2802 {
2899 if (nrules != 0) 2803 wint_t wc = __btowc (br_elem->opr.ch);
2900 return __collseq_table_lookup (collseqwc, br_elem->opr.wch); 2804 return __collseq_table_lookup (collseqwc, wc);
2901 } 2805 }
2902 else if (br_elem->type == COLL_SYM) 2806 }
2807 else if (br_elem->type == MB_CHAR)
2808 {
2809 if (nrules != 0)
2810 return __collseq_table_lookup (collseqwc, br_elem->opr.wch);
2811 }
2812 else if (br_elem->type == COLL_SYM)
2813 {
2814 size_t sym_name_len = strlen ((char *) br_elem->opr.name);
2815 if (nrules != 0)
2903 { 2816 {
2904 size_t sym_name_len = strlen ((char *) br_elem->opr.name); 2817 int32_t elem, idx;
2905 if (nrules != 0) 2818 elem = seek_collating_symbol_entry (br_elem->opr.name,
2819 sym_name_len,
2820 symb_table, table_size,
2821 extra);
2822 if (elem != -1)
2906 { 2823 {
2907 int32_t elem, idx; 2824 /* We found the entry. */
2908 elem = seek_collating_symbol_entry (br_elem->opr.name, 2825 idx = symb_table[2 * elem + 1];
2909 sym_name_len); 2826 /* Skip the name of collating element name. */
2910 if (elem != -1) 2827 idx += 1 + extra[idx];
2911 { 2828 /* Skip the byte sequence of the collating element. */
2912 /* We found the entry. */ 2829 idx += 1 + extra[idx];
2913 idx = symb_table[2 * elem + 1]; 2830 /* Adjust for the alignment. */
2914 /* Skip the name of collating element name. */ 2831 idx = (idx + 3) & ~3;
2915 idx += 1 + extra[idx]; 2832 /* Skip the multibyte collation sequence value. */
2916 /* Skip the byte sequence of the collating element. */ 2833 idx += sizeof (unsigned int);
2917 idx += 1 + extra[idx]; 2834 /* Skip the wide char sequence of the collating element. */
2918 /* Adjust for the alignment. */ 2835 idx += sizeof (unsigned int) *
2919 idx = (idx + 3) & ~3; 2836 (1 + *(unsigned int *) (extra + idx));
2920 /* Skip the multibyte collation sequence value. */ 2837 /* Return the collation sequence value. */
2921 idx += sizeof (unsigned int); 2838 return *(unsigned int *) (extra + idx);
2922 /* Skip the wide char sequence of the collating element. */
2923 idx += sizeof (unsigned int) *
2924 (1 + *(unsigned int *) (extra + idx));
2925 /* Return the collation sequence value. */
2926 return *(unsigned int *) (extra + idx);
2927 }
2928 else if (sym_name_len == 1)
2929 {
2930 /* No valid character. Match it as a single byte
2931 character. */
2932 return collseqmb[br_elem->opr.name[0]];
2933 }
2934 } 2839 }
2935 else if (sym_name_len == 1) 2840 else if (sym_name_len == 1)
2936 return collseqmb[br_elem->opr.name[0]]; 2841 {
2842 /* No valid character. Match it as a single byte
2843 character. */
2844 return collseqmb[br_elem->opr.name[0]];
2845 }
2937 } 2846 }
2938 return UINT_MAX; 2847 else if (sym_name_len == 1)
2848 return collseqmb[br_elem->opr.name[0]];
2939 } 2849 }
2850 return UINT_MAX;
2851}
2940 2852
2941 /* Local function for parse_bracket_exp used in _LIBC environment. 2853/* Local function for parse_bracket_exp used in _LIBC environment.
2942 Build the range expression which starts from START_ELEM, and ends 2854 Build the range expression which starts from START_ELEM, and ends
2943 at END_ELEM. The result are written to MBCSET and SBCSET. 2855 at END_ELEM. The result are written to MBCSET and SBCSET.
2944 RANGE_ALLOC is the allocated size of mbcset->range_starts, and 2856 RANGE_ALLOC is the allocated size of mbcset->range_starts, and
2945 mbcset->range_ends, is a pointer argument since we may 2857 mbcset->range_ends, is a pointer argument since we may
2946 update it. */ 2858 update it. */
2859
2860static __always_inline reg_errcode_t
2861build_range_exp (bitset_t sbcset, re_charset_t *mbcset, Idx *range_alloc,
2862 bracket_elem_t *start_elem, bracket_elem_t *end_elem,
2863 re_dfa_t *dfa, reg_syntax_t syntax, uint32_t nrules,
2864 const unsigned char *collseqmb, const char *collseqwc,
2865 int_fast32_t table_size, const int32_t *symb_table,
2866 const unsigned char *extra)
2867{
2868 unsigned int ch;
2869 uint32_t start_collseq;
2870 uint32_t end_collseq;
2947 2871
2948 auto inline reg_errcode_t 2872 /* Equivalence Classes and Character Classes can't be a range
2949 __attribute__ ((always_inline)) 2873 start/end. */
2950 build_range_exp (bitset_t sbcset, re_charset_t *mbcset, int *range_alloc, 2874 if (__glibc_unlikely (start_elem->type == EQUIV_CLASS
2951 bracket_elem_t *start_elem, bracket_elem_t *end_elem) 2875 || start_elem->type == CHAR_CLASS
2952 { 2876 || end_elem->type == EQUIV_CLASS
2953 unsigned int ch; 2877 || end_elem->type == CHAR_CLASS))
2954 uint32_t start_collseq; 2878 return REG_ERANGE;
2955 uint32_t end_collseq;
2956
2957 /* Equivalence Classes and Character Classes can't be a range
2958 start/end. */
2959 if (__glibc_unlikely (start_elem->type == EQUIV_CLASS
2960 || start_elem->type == CHAR_CLASS
2961 || end_elem->type == EQUIV_CLASS
2962 || end_elem->type == CHAR_CLASS))
2963 return REG_ERANGE;
2964 2879
2965 /* FIXME: Implement rational ranges here, too. */ 2880 /* FIXME: Implement rational ranges here, too. */
2966 start_collseq = lookup_collation_sequence_value (start_elem); 2881 start_collseq = lookup_collation_sequence_value (start_elem, nrules, collseqmb, collseqwc,
2967 end_collseq = lookup_collation_sequence_value (end_elem); 2882 table_size, symb_table, extra);
2968 /* Check start/end collation sequence values. */ 2883 end_collseq = lookup_collation_sequence_value (end_elem, nrules, collseqmb, collseqwc,
2969 if (__glibc_unlikely (start_collseq == UINT_MAX 2884 table_size, symb_table, extra);
2970 || end_collseq == UINT_MAX)) 2885 /* Check start/end collation sequence values. */
2971 return REG_ECOLLATE; 2886 if (__glibc_unlikely (start_collseq == UINT_MAX
2972 if (__glibc_unlikely ((syntax & RE_NO_EMPTY_RANGES) 2887 || end_collseq == UINT_MAX))
2973 && start_collseq > end_collseq)) 2888 return REG_ECOLLATE;
2974 return REG_ERANGE; 2889 if (__glibc_unlikely ((syntax & RE_NO_EMPTY_RANGES)
2890 && start_collseq > end_collseq))
2891 return REG_ERANGE;
2975 2892
2976 /* Got valid collation sequence values, add them as a new entry. 2893 /* Got valid collation sequence values, add them as a new entry.
2977 However, if we have no collation elements, and the character set 2894 However, if we have no collation elements, and the character set
2978 is single byte, the single byte character set that we 2895 is single byte, the single byte character set that we
2979 build below suffices. */ 2896 build below suffices. */
2980 if (nrules > 0 || dfa->mb_cur_max > 1) 2897 if (nrules > 0 || dfa->mb_cur_max > 1)
2898 {
2899 /* Check the space of the arrays. */
2900 if (__glibc_unlikely (*range_alloc == mbcset->nranges))
2981 { 2901 {
2982 /* Check the space of the arrays. */ 2902 /* There is not enough space, need realloc. */
2983 if (__glibc_unlikely (*range_alloc == mbcset->nranges)) 2903 uint32_t *new_array_start;
2984 { 2904 uint32_t *new_array_end;
2985 /* There is not enough space, need realloc. */ 2905 int new_nranges;
2986 uint32_t *new_array_start;
2987 uint32_t *new_array_end;
2988 Idx new_nranges;
2989
2990 /* +1 in case of mbcset->nranges is 0. */
2991 new_nranges = 2 * mbcset->nranges + 1;
2992 new_array_start = re_realloc (mbcset->range_starts, uint32_t,
2993 new_nranges);
2994 new_array_end = re_realloc (mbcset->range_ends, uint32_t,
2995 new_nranges);
2996
2997 if (__glibc_unlikely (new_array_start == NULL
2998 || new_array_end == NULL))
2999 return REG_ESPACE;
3000 2906
3001 mbcset->range_starts = new_array_start; 2907 /* +1 in case of mbcset->nranges is 0. */
3002 mbcset->range_ends = new_array_end; 2908 new_nranges = 2 * mbcset->nranges + 1;
3003 *range_alloc = new_nranges; 2909 new_array_start = re_realloc (mbcset->range_starts, uint32_t,
3004 } 2910 new_nranges);
2911 new_array_end = re_realloc (mbcset->range_ends, uint32_t,
2912 new_nranges);
3005 2913
3006 mbcset->range_starts[mbcset->nranges] = start_collseq; 2914 if (__glibc_unlikely (new_array_start == NULL
3007 mbcset->range_ends[mbcset->nranges++] = end_collseq; 2915 || new_array_end == NULL))
3008 } 2916 return REG_ESPACE;
3009 2917
3010 /* Build the table for single byte characters. */ 2918 mbcset->range_starts = new_array_start;
3011 for (ch = 0; ch < SBC_MAX; ch++) 2919 mbcset->range_ends = new_array_end;
3012 { 2920 *range_alloc = new_nranges;
3013 uint32_t ch_collseq;
3014 /*
3015 if (MB_CUR_MAX == 1)
3016 */
3017 if (nrules == 0)
3018 ch_collseq = collseqmb[ch];
3019 else
3020 ch_collseq = __collseq_table_lookup (collseqwc, __btowc (ch));
3021 if (start_collseq <= ch_collseq && ch_collseq <= end_collseq)
3022 bitset_set (sbcset, ch);
3023 } 2921 }
3024 return REG_NOERROR; 2922
2923 mbcset->range_starts[mbcset->nranges] = start_collseq;
2924 mbcset->range_ends[mbcset->nranges++] = end_collseq;
3025 } 2925 }
3026 2926
3027 /* Local function for parse_bracket_exp used in _LIBC environment. 2927 /* Build the table for single byte characters. */
3028 Build the collating element which is represented by NAME. 2928 for (ch = 0; ch < SBC_MAX; ch++)
3029 The result are written to MBCSET and SBCSET. 2929 {
3030 COLL_SYM_ALLOC is the allocated size of mbcset->coll_sym, is a 2930 uint32_t ch_collseq;
3031 pointer argument since we may update it. */ 2931 /* if (MB_CUR_MAX == 1) */
2932 if (nrules == 0)
2933 ch_collseq = collseqmb[ch];
2934 else
2935 ch_collseq = __collseq_table_lookup (collseqwc, __btowc (ch));
2936 if (start_collseq <= ch_collseq && ch_collseq <= end_collseq)
2937 bitset_set (sbcset, ch);
2938 }
2939 return REG_NOERROR;
2940}
3032 2941
3033 auto inline reg_errcode_t 2942/* Local function for parse_bracket_exp used in _LIBC environment.
3034 __attribute__ ((always_inline)) 2943 Build the collating element which is represented by NAME.
3035 build_collating_symbol (bitset_t sbcset, re_charset_t *mbcset, 2944 The result are written to MBCSET and SBCSET.
3036 Idx *coll_sym_alloc, const unsigned char *name) 2945 COLL_SYM_ALLOC is the allocated size of mbcset->coll_sym, is a
2946 pointer argument since we may update it. */
2947
2948static __always_inline reg_errcode_t
2949build_collating_symbol (bitset_t sbcset, re_charset_t *mbcset,
2950 Idx *coll_sym_alloc, const unsigned char *name,
2951 uint_fast32_t nrules, int_fast32_t table_size,
2952 const int32_t *symb_table, const unsigned char *extra)
2953{
2954 int32_t elem, idx;
2955 size_t name_len = strlen ((const char *) name);
2956 if (nrules != 0)
3037 { 2957 {
3038 int32_t elem, idx; 2958 elem = seek_collating_symbol_entry (name, name_len, symb_table,
3039 size_t name_len = strlen ((const char *) name); 2959 table_size, extra);
3040 if (nrules != 0) 2960 if (elem != -1)
3041 { 2961 {
3042 elem = seek_collating_symbol_entry (name, name_len); 2962 /* We found the entry. */
3043 if (elem != -1) 2963 idx = symb_table[2 * elem + 1];
3044 { 2964 /* Skip the name of collating element name. */
3045 /* We found the entry. */ 2965 idx += 1 + extra[idx];
3046 idx = symb_table[2 * elem + 1]; 2966 }
3047 /* Skip the name of collating element name. */ 2967 else if (name_len == 1)
3048 idx += 1 + extra[idx]; 2968 {
3049 } 2969 /* No valid character, treat it as a normal
3050 else if (name_len == 1) 2970 character. */
3051 { 2971 bitset_set (sbcset, name[0]);
3052 /* No valid character, treat it as a normal
3053 character. */
3054 bitset_set (sbcset, name[0]);
3055 return REG_NOERROR;
3056 }
3057 else
3058 return REG_ECOLLATE;
3059
3060 /* Got valid collation sequence, add it as a new entry. */
3061 /* Check the space of the arrays. */
3062 if (__glibc_unlikely (*coll_sym_alloc == mbcset->ncoll_syms))
3063 {
3064 /* Not enough, realloc it. */
3065 /* +1 in case of mbcset->ncoll_syms is 0. */
3066 Idx new_coll_sym_alloc = 2 * mbcset->ncoll_syms + 1;
3067 /* Use realloc since mbcset->coll_syms is NULL
3068 if *alloc == 0. */
3069 int32_t *new_coll_syms = re_realloc (mbcset->coll_syms, int32_t,
3070 new_coll_sym_alloc);
3071 if (__glibc_unlikely (new_coll_syms == NULL))
3072 return REG_ESPACE;
3073 mbcset->coll_syms = new_coll_syms;
3074 *coll_sym_alloc = new_coll_sym_alloc;
3075 }
3076 mbcset->coll_syms[mbcset->ncoll_syms++] = idx;
3077 return REG_NOERROR; 2972 return REG_NOERROR;
3078 } 2973 }
3079 else 2974 else
2975 return REG_ECOLLATE;
2976
2977 /* Got valid collation sequence, add it as a new entry. */
2978 /* Check the space of the arrays. */
2979 if (__glibc_unlikely (*coll_sym_alloc == mbcset->ncoll_syms))
3080 { 2980 {
3081 if (__glibc_unlikely (name_len != 1)) 2981 /* Not enough, realloc it. */
3082 return REG_ECOLLATE; 2982 /* +1 in case of mbcset->ncoll_syms is 0. */
3083 else 2983 int new_coll_sym_alloc = 2 * mbcset->ncoll_syms + 1;
3084 { 2984 /* Use realloc since mbcset->coll_syms is NULL
3085 bitset_set (sbcset, name[0]); 2985 if *alloc == 0. */
3086 return REG_NOERROR; 2986 int32_t *new_coll_syms = re_realloc (mbcset->coll_syms, int32_t,
3087 } 2987 new_coll_sym_alloc);
2988 if (__glibc_unlikely (new_coll_syms == NULL))
2989 return REG_ESPACE;
2990 mbcset->coll_syms = new_coll_syms;
2991 *coll_sym_alloc = new_coll_sym_alloc;
3088 } 2992 }
2993 mbcset->coll_syms[mbcset->ncoll_syms++] = idx;
2994 return REG_NOERROR;
3089 } 2995 }
3090#endif 2996 else
2997 {
2998 if (__glibc_unlikely (name_len != 1))
2999 return REG_ECOLLATE;
3000 else
3001 {
3002 bitset_set (sbcset, name[0]);
3003 return REG_NOERROR;
3004 }
3005 }
3006}
3007#endif /* _LIBC */
3008
3009/* This function parse bracket expression like "[abc]", "[a-c]",
3010 "[[.a-a.]]" etc. */
3011
3012static bin_tree_t *
3013parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
3014 reg_syntax_t syntax, reg_errcode_t *err)
3015{
3016 const unsigned char *collseqmb = NULL;
3017 const char *collseqwc = NULL;
3018 uint_fast32_t nrules = 0;
3019 int_fast32_t table_size = 0;
3020 const void *symb_table = NULL;
3021 const unsigned char *extra = NULL;
3091 3022
3092 re_token_t br_token; 3023 re_token_t br_token;
3093 re_bitset_ptr_t sbcset; 3024 re_bitset_ptr_t sbcset;
3094#ifdef RE_ENABLE_I18N
3095 re_charset_t *mbcset; 3025 re_charset_t *mbcset;
3096 Idx coll_sym_alloc = 0, range_alloc = 0, mbchar_alloc = 0; 3026 Idx coll_sym_alloc = 0, range_alloc = 0, mbchar_alloc = 0;
3097 Idx equiv_class_alloc = 0, char_class_alloc = 0; 3027 Idx equiv_class_alloc = 0, char_class_alloc = 0;
3098#endif /* not RE_ENABLE_I18N */
3099 bool non_match = false; 3028 bool non_match = false;
3100 bin_tree_t *work_tree; 3029 bin_tree_t *work_tree;
3101 int token_len; 3030 int token_len;
@@ -3111,26 +3040,17 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
3111 */ 3040 */
3112 collseqwc = _NL_CURRENT (LC_COLLATE, _NL_COLLATE_COLLSEQWC); 3041 collseqwc = _NL_CURRENT (LC_COLLATE, _NL_COLLATE_COLLSEQWC);
3113 table_size = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_SYMB_HASH_SIZEMB); 3042 table_size = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_SYMB_HASH_SIZEMB);
3114 symb_table = (const int32_t *) _NL_CURRENT (LC_COLLATE, 3043 symb_table = _NL_CURRENT (LC_COLLATE, _NL_COLLATE_SYMB_TABLEMB);
3115 _NL_COLLATE_SYMB_TABLEMB);
3116 extra = (const unsigned char *) _NL_CURRENT (LC_COLLATE, 3044 extra = (const unsigned char *) _NL_CURRENT (LC_COLLATE,
3117 _NL_COLLATE_SYMB_EXTRAMB); 3045 _NL_COLLATE_SYMB_EXTRAMB);
3118 } 3046 }
3119#endif 3047#endif
3120 sbcset = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1); 3048 sbcset = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1);
3121#ifdef RE_ENABLE_I18N
3122 mbcset = (re_charset_t *) calloc (sizeof (re_charset_t), 1); 3049 mbcset = (re_charset_t *) calloc (sizeof (re_charset_t), 1);
3123#endif /* RE_ENABLE_I18N */
3124#ifdef RE_ENABLE_I18N
3125 if (__glibc_unlikely (sbcset == NULL || mbcset == NULL)) 3050 if (__glibc_unlikely (sbcset == NULL || mbcset == NULL))
3126#else
3127 if (__glibc_unlikely (sbcset == NULL))
3128#endif /* RE_ENABLE_I18N */
3129 { 3051 {
3130 re_free (sbcset); 3052 re_free (sbcset);
3131#ifdef RE_ENABLE_I18N
3132 re_free (mbcset); 3053 re_free (mbcset);
3133#endif
3134 *err = REG_ESPACE; 3054 *err = REG_ESPACE;
3135 return NULL; 3055 return NULL;
3136 } 3056 }
@@ -3143,9 +3063,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
3143 } 3063 }
3144 if (token->type == OP_NON_MATCH_LIST) 3064 if (token->type == OP_NON_MATCH_LIST)
3145 { 3065 {
3146#ifdef RE_ENABLE_I18N
3147 mbcset->non_match = 1; 3066 mbcset->non_match = 1;
3148#endif /* not RE_ENABLE_I18N */
3149 non_match = true; 3067 non_match = true;
3150 if (syntax & RE_HAT_LISTS_NOT_NEWLINE) 3068 if (syntax & RE_HAT_LISTS_NOT_NEWLINE)
3151 bitset_set (sbcset, '\n'); 3069 bitset_set (sbcset, '\n');
@@ -3228,18 +3146,10 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
3228 3146
3229 token_len = peek_token_bracket (token, regexp, syntax); 3147 token_len = peek_token_bracket (token, regexp, syntax);
3230 3148
3231#ifdef _LIBC
3232 *err = build_range_exp (sbcset, mbcset, &range_alloc, 3149 *err = build_range_exp (sbcset, mbcset, &range_alloc,
3233 &start_elem, &end_elem); 3150 &start_elem, &end_elem,
3234#else 3151 dfa, syntax, nrules, collseqmb, collseqwc,
3235# ifdef RE_ENABLE_I18N 3152 table_size, symb_table, extra);
3236 *err = build_range_exp (syntax, sbcset,
3237 dfa->mb_cur_max > 1 ? mbcset : NULL,
3238 &range_alloc, &start_elem, &end_elem);
3239# else
3240 *err = build_range_exp (syntax, sbcset, &start_elem, &end_elem);
3241# endif
3242#endif /* RE_ENABLE_I18N */
3243 if (__glibc_unlikely (*err != REG_NOERROR)) 3153 if (__glibc_unlikely (*err != REG_NOERROR))
3244 goto parse_bracket_exp_free_return; 3154 goto parse_bracket_exp_free_return;
3245 } 3155 }
@@ -3250,7 +3160,6 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
3250 case SB_CHAR: 3160 case SB_CHAR:
3251 bitset_set (sbcset, start_elem.opr.ch); 3161 bitset_set (sbcset, start_elem.opr.ch);
3252 break; 3162 break;
3253#ifdef RE_ENABLE_I18N
3254 case MB_CHAR: 3163 case MB_CHAR:
3255 /* Check whether the array has enough space. */ 3164 /* Check whether the array has enough space. */
3256 if (__glibc_unlikely (mbchar_alloc == mbcset->nmbchars)) 3165 if (__glibc_unlikely (mbchar_alloc == mbcset->nmbchars))
@@ -3268,30 +3177,24 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
3268 } 3177 }
3269 mbcset->mbchars[mbcset->nmbchars++] = start_elem.opr.wch; 3178 mbcset->mbchars[mbcset->nmbchars++] = start_elem.opr.wch;
3270 break; 3179 break;
3271#endif /* RE_ENABLE_I18N */
3272 case EQUIV_CLASS: 3180 case EQUIV_CLASS:
3273 *err = build_equiv_class (sbcset, 3181 *err = build_equiv_class (sbcset,
3274#ifdef RE_ENABLE_I18N
3275 mbcset, &equiv_class_alloc, 3182 mbcset, &equiv_class_alloc,
3276#endif /* RE_ENABLE_I18N */
3277 start_elem.opr.name); 3183 start_elem.opr.name);
3278 if (__glibc_unlikely (*err != REG_NOERROR)) 3184 if (__glibc_unlikely (*err != REG_NOERROR))
3279 goto parse_bracket_exp_free_return; 3185 goto parse_bracket_exp_free_return;
3280 break; 3186 break;
3281 case COLL_SYM: 3187 case COLL_SYM:
3282 *err = build_collating_symbol (sbcset, 3188 *err = build_collating_symbol (sbcset,
3283#ifdef RE_ENABLE_I18N
3284 mbcset, &coll_sym_alloc, 3189 mbcset, &coll_sym_alloc,
3285#endif /* RE_ENABLE_I18N */ 3190 start_elem.opr.name,
3286 start_elem.opr.name); 3191 nrules, table_size, symb_table, extra);
3287 if (__glibc_unlikely (*err != REG_NOERROR)) 3192 if (__glibc_unlikely (*err != REG_NOERROR))
3288 goto parse_bracket_exp_free_return; 3193 goto parse_bracket_exp_free_return;
3289 break; 3194 break;
3290 case CHAR_CLASS: 3195 case CHAR_CLASS:
3291 *err = build_charclass (regexp->trans, sbcset, 3196 *err = build_charclass (regexp->trans, sbcset,
3292#ifdef RE_ENABLE_I18N
3293 mbcset, &char_class_alloc, 3197 mbcset, &char_class_alloc,
3294#endif /* RE_ENABLE_I18N */
3295 (const char *) start_elem.opr.name, 3198 (const char *) start_elem.opr.name,
3296 syntax); 3199 syntax);
3297 if (__glibc_unlikely (*err != REG_NOERROR)) 3200 if (__glibc_unlikely (*err != REG_NOERROR))
@@ -3317,7 +3220,6 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
3317 if (non_match) 3220 if (non_match)
3318 bitset_not (sbcset); 3221 bitset_not (sbcset);
3319 3222
3320#ifdef RE_ENABLE_I18N
3321 /* Ensure only single byte characters are set. */ 3223 /* Ensure only single byte characters are set. */
3322 if (dfa->mb_cur_max > 1) 3224 if (dfa->mb_cur_max > 1)
3323 bitset_mask (sbcset, dfa->sb_char); 3225 bitset_mask (sbcset, dfa->sb_char);
@@ -3361,11 +3263,8 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
3361 } 3263 }
3362 } 3264 }
3363 else 3265 else
3364#endif /* not RE_ENABLE_I18N */
3365 { 3266 {
3366#ifdef RE_ENABLE_I18N
3367 free_charset (mbcset); 3267 free_charset (mbcset);
3368#endif
3369 /* Build a tree for simple bracket. */ 3268 /* Build a tree for simple bracket. */
3370 br_token.type = SIMPLE_BRACKET; 3269 br_token.type = SIMPLE_BRACKET;
3371 br_token.opr.sbcset = sbcset; 3270 br_token.opr.sbcset = sbcset;
@@ -3379,9 +3278,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
3379 *err = REG_ESPACE; 3278 *err = REG_ESPACE;
3380 parse_bracket_exp_free_return: 3279 parse_bracket_exp_free_return:
3381 re_free (sbcset); 3280 re_free (sbcset);
3382#ifdef RE_ENABLE_I18N
3383 free_charset (mbcset); 3281 free_charset (mbcset);
3384#endif /* RE_ENABLE_I18N */
3385 return NULL; 3282 return NULL;
3386} 3283}
3387 3284
@@ -3392,7 +3289,6 @@ parse_bracket_element (bracket_elem_t *elem, re_string_t *regexp,
3392 re_token_t *token, int token_len, re_dfa_t *dfa, 3289 re_token_t *token, int token_len, re_dfa_t *dfa,
3393 reg_syntax_t syntax, bool accept_hyphen) 3290 reg_syntax_t syntax, bool accept_hyphen)
3394{ 3291{
3395#ifdef RE_ENABLE_I18N
3396 int cur_char_size; 3292 int cur_char_size;
3397 cur_char_size = re_string_char_size_at (regexp, re_string_cur_idx (regexp)); 3293 cur_char_size = re_string_char_size_at (regexp, re_string_cur_idx (regexp));
3398 if (cur_char_size > 1) 3294 if (cur_char_size > 1)
@@ -3402,7 +3298,6 @@ parse_bracket_element (bracket_elem_t *elem, re_string_t *regexp,
3402 re_string_skip_bytes (regexp, cur_char_size); 3298 re_string_skip_bytes (regexp, cur_char_size);
3403 return REG_NOERROR; 3299 return REG_NOERROR;
3404 } 3300 }
3405#endif /* RE_ENABLE_I18N */
3406 re_string_skip_bytes (regexp, token_len); /* Skip a token. */ 3301 re_string_skip_bytes (regexp, token_len); /* Skip a token. */
3407 if (token->type == OP_OPEN_COLL_ELEM || token->type == OP_OPEN_CHAR_CLASS 3302 if (token->type == OP_OPEN_COLL_ELEM || token->type == OP_OPEN_CHAR_CLASS
3408 || token->type == OP_OPEN_EQUIV_CLASS) 3303 || token->type == OP_OPEN_EQUIV_CLASS)
@@ -3475,12 +3370,8 @@ parse_bracket_symbol (bracket_elem_t *elem, re_string_t *regexp,
3475 is a pointer argument since we may update it. */ 3370 is a pointer argument since we may update it. */
3476 3371
3477static reg_errcode_t 3372static reg_errcode_t
3478#ifdef RE_ENABLE_I18N
3479build_equiv_class (bitset_t sbcset, re_charset_t *mbcset, 3373build_equiv_class (bitset_t sbcset, re_charset_t *mbcset,
3480 Idx *equiv_class_alloc, const unsigned char *name) 3374 Idx *equiv_class_alloc, const unsigned char *name)
3481#else /* not RE_ENABLE_I18N */
3482build_equiv_class (bitset_t sbcset, const unsigned char *name)
3483#endif /* not RE_ENABLE_I18N */
3484{ 3375{
3485#ifdef _LIBC 3376#ifdef _LIBC
3486 uint32_t nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES); 3377 uint32_t nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
@@ -3560,14 +3451,9 @@ build_equiv_class (bitset_t sbcset, const unsigned char *name)
3560 is a pointer argument since we may update it. */ 3451 is a pointer argument since we may update it. */
3561 3452
3562static reg_errcode_t 3453static reg_errcode_t
3563#ifdef RE_ENABLE_I18N
3564build_charclass (RE_TRANSLATE_TYPE trans, bitset_t sbcset, 3454build_charclass (RE_TRANSLATE_TYPE trans, bitset_t sbcset,
3565 re_charset_t *mbcset, Idx *char_class_alloc, 3455 re_charset_t *mbcset, Idx *char_class_alloc,
3566 const char *class_name, reg_syntax_t syntax) 3456 const char *class_name, reg_syntax_t syntax)
3567#else /* not RE_ENABLE_I18N */
3568build_charclass (RE_TRANSLATE_TYPE trans, bitset_t sbcset,
3569 const char *class_name, reg_syntax_t syntax)
3570#endif /* not RE_ENABLE_I18N */
3571{ 3457{
3572 int i; 3458 int i;
3573 const char *name = class_name; 3459 const char *name = class_name;
@@ -3578,7 +3464,6 @@ build_charclass (RE_TRANSLATE_TYPE trans, bitset_t sbcset,
3578 && (strcmp (name, "upper") == 0 || strcmp (name, "lower") == 0)) 3464 && (strcmp (name, "upper") == 0 || strcmp (name, "lower") == 0))
3579 name = "alpha"; 3465 name = "alpha";
3580 3466
3581#ifdef RE_ENABLE_I18N
3582 /* Check the space of the arrays. */ 3467 /* Check the space of the arrays. */
3583 if (__glibc_unlikely (*char_class_alloc == mbcset->nchar_classes)) 3468 if (__glibc_unlikely (*char_class_alloc == mbcset->nchar_classes))
3584 { 3469 {
@@ -3594,7 +3479,6 @@ build_charclass (RE_TRANSLATE_TYPE trans, bitset_t sbcset,
3594 *char_class_alloc = new_char_class_alloc; 3479 *char_class_alloc = new_char_class_alloc;
3595 } 3480 }
3596 mbcset->char_classes[mbcset->nchar_classes++] = __wctype (name); 3481 mbcset->char_classes[mbcset->nchar_classes++] = __wctype (name);
3597#endif /* RE_ENABLE_I18N */
3598 3482
3599#define BUILD_CHARCLASS_LOOP(ctype_func) \ 3483#define BUILD_CHARCLASS_LOOP(ctype_func) \
3600 do { \ 3484 do { \
@@ -3649,10 +3533,8 @@ build_charclass_op (re_dfa_t *dfa, RE_TRANSLATE_TYPE trans,
3649 reg_errcode_t *err) 3533 reg_errcode_t *err)
3650{ 3534{
3651 re_bitset_ptr_t sbcset; 3535 re_bitset_ptr_t sbcset;
3652#ifdef RE_ENABLE_I18N
3653 re_charset_t *mbcset; 3536 re_charset_t *mbcset;
3654 Idx alloc = 0; 3537 Idx alloc = 0;
3655#endif /* not RE_ENABLE_I18N */
3656 reg_errcode_t ret; 3538 reg_errcode_t ret;
3657 bin_tree_t *tree; 3539 bin_tree_t *tree;
3658 3540
@@ -3662,7 +3544,6 @@ build_charclass_op (re_dfa_t *dfa, RE_TRANSLATE_TYPE trans,
3662 *err = REG_ESPACE; 3544 *err = REG_ESPACE;
3663 return NULL; 3545 return NULL;
3664 } 3546 }
3665#ifdef RE_ENABLE_I18N
3666 mbcset = (re_charset_t *) calloc (sizeof (re_charset_t), 1); 3547 mbcset = (re_charset_t *) calloc (sizeof (re_charset_t), 1);
3667 if (__glibc_unlikely (mbcset == NULL)) 3548 if (__glibc_unlikely (mbcset == NULL))
3668 { 3549 {
@@ -3671,21 +3552,14 @@ build_charclass_op (re_dfa_t *dfa, RE_TRANSLATE_TYPE trans,
3671 return NULL; 3552 return NULL;
3672 } 3553 }
3673 mbcset->non_match = non_match; 3554 mbcset->non_match = non_match;
3674#endif /* RE_ENABLE_I18N */
3675 3555
3676 /* We don't care the syntax in this case. */ 3556 /* We don't care the syntax in this case. */
3677 ret = build_charclass (trans, sbcset, 3557 ret = build_charclass (trans, sbcset, mbcset, &alloc, class_name, 0);
3678#ifdef RE_ENABLE_I18N
3679 mbcset, &alloc,
3680#endif /* RE_ENABLE_I18N */
3681 class_name, 0);
3682 3558
3683 if (__glibc_unlikely (ret != REG_NOERROR)) 3559 if (__glibc_unlikely (ret != REG_NOERROR))
3684 { 3560 {
3685 re_free (sbcset); 3561 re_free (sbcset);
3686#ifdef RE_ENABLE_I18N
3687 free_charset (mbcset); 3562 free_charset (mbcset);
3688#endif /* RE_ENABLE_I18N */
3689 *err = ret; 3563 *err = ret;
3690 return NULL; 3564 return NULL;
3691 } 3565 }
@@ -3697,11 +3571,9 @@ build_charclass_op (re_dfa_t *dfa, RE_TRANSLATE_TYPE trans,
3697 if (non_match) 3571 if (non_match)
3698 bitset_not (sbcset); 3572 bitset_not (sbcset);
3699 3573
3700#ifdef RE_ENABLE_I18N
3701 /* Ensure only single byte characters are set. */ 3574 /* Ensure only single byte characters are set. */
3702 if (dfa->mb_cur_max > 1) 3575 if (dfa->mb_cur_max > 1)
3703 bitset_mask (sbcset, dfa->sb_char); 3576 bitset_mask (sbcset, dfa->sb_char);
3704#endif
3705 3577
3706 /* Build a tree for simple bracket. */ 3578 /* Build a tree for simple bracket. */
3707 re_token_t br_token = { .type = SIMPLE_BRACKET, .opr.sbcset = sbcset }; 3579 re_token_t br_token = { .type = SIMPLE_BRACKET, .opr.sbcset = sbcset };
@@ -3709,7 +3581,6 @@ build_charclass_op (re_dfa_t *dfa, RE_TRANSLATE_TYPE trans,
3709 if (__glibc_unlikely (tree == NULL)) 3581 if (__glibc_unlikely (tree == NULL))
3710 goto build_word_op_espace; 3582 goto build_word_op_espace;
3711 3583
3712#ifdef RE_ENABLE_I18N
3713 if (dfa->mb_cur_max > 1) 3584 if (dfa->mb_cur_max > 1)
3714 { 3585 {
3715 bin_tree_t *mbc_tree; 3586 bin_tree_t *mbc_tree;
@@ -3730,15 +3601,10 @@ build_charclass_op (re_dfa_t *dfa, RE_TRANSLATE_TYPE trans,
3730 free_charset (mbcset); 3601 free_charset (mbcset);
3731 return tree; 3602 return tree;
3732 } 3603 }
3733#else /* not RE_ENABLE_I18N */
3734 return tree;
3735#endif /* not RE_ENABLE_I18N */
3736 3604
3737 build_word_op_espace: 3605 build_word_op_espace:
3738 re_free (sbcset); 3606 re_free (sbcset);
3739#ifdef RE_ENABLE_I18N
3740 free_charset (mbcset); 3607 free_charset (mbcset);
3741#endif /* RE_ENABLE_I18N */
3742 *err = REG_ESPACE; 3608 *err = REG_ESPACE;
3743 return NULL; 3609 return NULL;
3744} 3610}
@@ -3771,21 +3637,19 @@ fetch_number (re_string_t *input, re_token_t *token, reg_syntax_t syntax)
3771 return num; 3637 return num;
3772} 3638}
3773 3639
3774#ifdef RE_ENABLE_I18N
3775static void 3640static void
3776free_charset (re_charset_t *cset) 3641free_charset (re_charset_t *cset)
3777{ 3642{
3778 re_free (cset->mbchars); 3643 re_free (cset->mbchars);
3779# ifdef _LIBC 3644#ifdef _LIBC
3780 re_free (cset->coll_syms); 3645 re_free (cset->coll_syms);
3781 re_free (cset->equiv_classes); 3646 re_free (cset->equiv_classes);
3782# endif 3647#endif
3783 re_free (cset->range_starts); 3648 re_free (cset->range_starts);
3784 re_free (cset->range_ends); 3649 re_free (cset->range_ends);
3785 re_free (cset->char_classes); 3650 re_free (cset->char_classes);
3786 re_free (cset); 3651 re_free (cset);
3787} 3652}
3788#endif /* RE_ENABLE_I18N */
3789 3653
3790/* Functions for binary tree operation. */ 3654/* Functions for binary tree operation. */
3791 3655
@@ -3851,13 +3715,10 @@ mark_opt_subexp (void *extra, bin_tree_t *node)
3851static void 3715static void
3852free_token (re_token_t *node) 3716free_token (re_token_t *node)
3853{ 3717{
3854#ifdef RE_ENABLE_I18N
3855 if (node->type == COMPLEX_BRACKET && node->duplicated == 0) 3718 if (node->type == COMPLEX_BRACKET && node->duplicated == 0)
3856 free_charset (node->opr.mbcset); 3719 free_charset (node->opr.mbcset);
3857 else 3720 else if (node->type == SIMPLE_BRACKET && node->duplicated == 0)
3858#endif /* RE_ENABLE_I18N */ 3721 re_free (node->opr.sbcset);
3859 if (node->type == SIMPLE_BRACKET && node->duplicated == 0)
3860 re_free (node->opr.sbcset);
3861} 3722}
3862 3723
3863/* Worker function for tree walking. Free the allocated memory inside NODE 3724/* Worker function for tree walking. Free the allocated memory inside NODE
diff --git a/lib/regex_internal.c b/lib/regex_internal.c
index aefcfa2f52e..9767cd0d07f 100644
--- a/lib/regex_internal.c
+++ b/lib/regex_internal.c
@@ -30,10 +30,8 @@ static re_dfastate_t *create_cd_newstate (const re_dfa_t *dfa,
30 re_hashval_t hash); 30 re_hashval_t hash);
31static reg_errcode_t re_string_realloc_buffers (re_string_t *pstr, 31static reg_errcode_t re_string_realloc_buffers (re_string_t *pstr,
32 Idx new_buf_len); 32 Idx new_buf_len);
33#ifdef RE_ENABLE_I18N
34static void build_wcs_buffer (re_string_t *pstr); 33static void build_wcs_buffer (re_string_t *pstr);
35static reg_errcode_t build_wcs_upper_buffer (re_string_t *pstr); 34static reg_errcode_t build_wcs_upper_buffer (re_string_t *pstr);
36#endif /* RE_ENABLE_I18N */
37static void build_upper_buffer (re_string_t *pstr); 35static void build_upper_buffer (re_string_t *pstr);
38static void re_string_translate_buffer (re_string_t *pstr); 36static void re_string_translate_buffer (re_string_t *pstr);
39static unsigned int re_string_context_at (const re_string_t *input, Idx idx, 37static unsigned int re_string_context_at (const re_string_t *input, Idx idx,
@@ -91,7 +89,6 @@ re_string_construct (re_string_t *pstr, const char *str, Idx len,
91 89
92 if (icase) 90 if (icase)
93 { 91 {
94#ifdef RE_ENABLE_I18N
95 if (dfa->mb_cur_max > 1) 92 if (dfa->mb_cur_max > 1)
96 { 93 {
97 while (1) 94 while (1)
@@ -109,16 +106,13 @@ re_string_construct (re_string_t *pstr, const char *str, Idx len,
109 } 106 }
110 } 107 }
111 else 108 else
112#endif /* RE_ENABLE_I18N */
113 build_upper_buffer (pstr); 109 build_upper_buffer (pstr);
114 } 110 }
115 else 111 else
116 { 112 {
117#ifdef RE_ENABLE_I18N
118 if (dfa->mb_cur_max > 1) 113 if (dfa->mb_cur_max > 1)
119 build_wcs_buffer (pstr); 114 build_wcs_buffer (pstr);
120 else 115 else
121#endif /* RE_ENABLE_I18N */
122 { 116 {
123 if (trans != NULL) 117 if (trans != NULL)
124 re_string_translate_buffer (pstr); 118 re_string_translate_buffer (pstr);
@@ -139,7 +133,6 @@ static reg_errcode_t
139__attribute_warn_unused_result__ 133__attribute_warn_unused_result__
140re_string_realloc_buffers (re_string_t *pstr, Idx new_buf_len) 134re_string_realloc_buffers (re_string_t *pstr, Idx new_buf_len)
141{ 135{
142#ifdef RE_ENABLE_I18N
143 if (pstr->mb_cur_max > 1) 136 if (pstr->mb_cur_max > 1)
144 { 137 {
145 wint_t *new_wcs; 138 wint_t *new_wcs;
@@ -162,7 +155,6 @@ re_string_realloc_buffers (re_string_t *pstr, Idx new_buf_len)
162 pstr->offsets = new_offsets; 155 pstr->offsets = new_offsets;
163 } 156 }
164 } 157 }
165#endif /* RE_ENABLE_I18N */
166 if (pstr->mbs_allocated) 158 if (pstr->mbs_allocated)
167 { 159 {
168 unsigned char *new_mbs = re_realloc (pstr->mbs, unsigned char, 160 unsigned char *new_mbs = re_realloc (pstr->mbs, unsigned char,
@@ -194,7 +186,6 @@ re_string_construct_common (const char *str, Idx len, re_string_t *pstr,
194 pstr->raw_stop = pstr->stop; 186 pstr->raw_stop = pstr->stop;
195} 187}
196 188
197#ifdef RE_ENABLE_I18N
198 189
199/* Build wide character buffer PSTR->WCS. 190/* Build wide character buffer PSTR->WCS.
200 If the byte sequence of the string are: 191 If the byte sequence of the string are:
@@ -530,7 +521,6 @@ re_string_skip_chars (re_string_t *pstr, Idx new_raw_idx, wint_t *last_wc)
530 *last_wc = wc; 521 *last_wc = wc;
531 return rawbuf_idx; 522 return rawbuf_idx;
532} 523}
533#endif /* RE_ENABLE_I18N */
534 524
535/* Build the buffer PSTR->MBS, and apply the translation if we need. 525/* Build the buffer PSTR->MBS, and apply the translation if we need.
536 This function is used in case of REG_ICASE. */ 526 This function is used in case of REG_ICASE. */
@@ -585,10 +575,8 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
585 else 575 else
586 { 576 {
587 /* Reset buffer. */ 577 /* Reset buffer. */
588#ifdef RE_ENABLE_I18N
589 if (pstr->mb_cur_max > 1) 578 if (pstr->mb_cur_max > 1)
590 memset (&pstr->cur_state, '\0', sizeof (mbstate_t)); 579 memset (&pstr->cur_state, '\0', sizeof (mbstate_t));
591#endif /* RE_ENABLE_I18N */
592 pstr->len = pstr->raw_len; 580 pstr->len = pstr->raw_len;
593 pstr->stop = pstr->raw_stop; 581 pstr->stop = pstr->raw_stop;
594 pstr->valid_len = 0; 582 pstr->valid_len = 0;
@@ -608,7 +596,6 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
608 if (__glibc_likely (offset < pstr->valid_raw_len)) 596 if (__glibc_likely (offset < pstr->valid_raw_len))
609 { 597 {
610 /* Yes, move them to the front of the buffer. */ 598 /* Yes, move them to the front of the buffer. */
611#ifdef RE_ENABLE_I18N
612 if (__glibc_unlikely (pstr->offsets_needed)) 599 if (__glibc_unlikely (pstr->offsets_needed))
613 { 600 {
614 Idx low = 0, high = pstr->valid_len, mid; 601 Idx low = 0, high = pstr->valid_len, mid;
@@ -672,15 +659,12 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
672 } 659 }
673 } 660 }
674 else 661 else
675#endif
676 { 662 {
677 pstr->tip_context = re_string_context_at (pstr, offset - 1, 663 pstr->tip_context = re_string_context_at (pstr, offset - 1,
678 eflags); 664 eflags);
679#ifdef RE_ENABLE_I18N
680 if (pstr->mb_cur_max > 1) 665 if (pstr->mb_cur_max > 1)
681 memmove (pstr->wcs, pstr->wcs + offset, 666 memmove (pstr->wcs, pstr->wcs + offset,
682 (pstr->valid_len - offset) * sizeof (wint_t)); 667 (pstr->valid_len - offset) * sizeof (wint_t));
683#endif /* RE_ENABLE_I18N */
684 if (__glibc_unlikely (pstr->mbs_allocated)) 668 if (__glibc_unlikely (pstr->mbs_allocated))
685 memmove (pstr->mbs, pstr->mbs + offset, 669 memmove (pstr->mbs, pstr->mbs + offset,
686 pstr->valid_len - offset); 670 pstr->valid_len - offset);
@@ -691,7 +675,6 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
691 } 675 }
692 else 676 else
693 { 677 {
694#ifdef RE_ENABLE_I18N
695 /* No, skip all characters until IDX. */ 678 /* No, skip all characters until IDX. */
696 Idx prev_valid_len = pstr->valid_len; 679 Idx prev_valid_len = pstr->valid_len;
697 680
@@ -701,9 +684,7 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
701 pstr->stop = pstr->raw_stop - idx + offset; 684 pstr->stop = pstr->raw_stop - idx + offset;
702 pstr->offsets_needed = 0; 685 pstr->offsets_needed = 0;
703 } 686 }
704#endif
705 pstr->valid_len = 0; 687 pstr->valid_len = 0;
706#ifdef RE_ENABLE_I18N
707 if (pstr->mb_cur_max > 1) 688 if (pstr->mb_cur_max > 1)
708 { 689 {
709 Idx wcs_idx; 690 Idx wcs_idx;
@@ -787,7 +768,6 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
787 pstr->valid_raw_len = pstr->valid_len; 768 pstr->valid_raw_len = pstr->valid_len;
788 } 769 }
789 else 770 else
790#endif /* RE_ENABLE_I18N */
791 { 771 {
792 int c = pstr->raw_mbs[pstr->raw_mbs_idx + offset - 1]; 772 int c = pstr->raw_mbs[pstr->raw_mbs_idx + offset - 1];
793 pstr->valid_raw_len = 0; 773 pstr->valid_raw_len = 0;
@@ -807,7 +787,6 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
807 pstr->stop -= offset; 787 pstr->stop -= offset;
808 788
809 /* Then build the buffers. */ 789 /* Then build the buffers. */
810#ifdef RE_ENABLE_I18N
811 if (pstr->mb_cur_max > 1) 790 if (pstr->mb_cur_max > 1)
812 { 791 {
813 if (pstr->icase) 792 if (pstr->icase)
@@ -820,7 +799,6 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
820 build_wcs_buffer (pstr); 799 build_wcs_buffer (pstr);
821 } 800 }
822 else 801 else
823#endif /* RE_ENABLE_I18N */
824 if (__glibc_unlikely (pstr->mbs_allocated)) 802 if (__glibc_unlikely (pstr->mbs_allocated))
825 { 803 {
826 if (pstr->icase) 804 if (pstr->icase)
@@ -846,28 +824,22 @@ re_string_peek_byte_case (const re_string_t *pstr, Idx idx)
846 if (__glibc_likely (!pstr->mbs_allocated)) 824 if (__glibc_likely (!pstr->mbs_allocated))
847 return re_string_peek_byte (pstr, idx); 825 return re_string_peek_byte (pstr, idx);
848 826
849#ifdef RE_ENABLE_I18N
850 if (pstr->mb_cur_max > 1 827 if (pstr->mb_cur_max > 1
851 && ! re_string_is_single_byte_char (pstr, pstr->cur_idx + idx)) 828 && ! re_string_is_single_byte_char (pstr, pstr->cur_idx + idx))
852 return re_string_peek_byte (pstr, idx); 829 return re_string_peek_byte (pstr, idx);
853#endif
854 830
855 off = pstr->cur_idx + idx; 831 off = pstr->cur_idx + idx;
856#ifdef RE_ENABLE_I18N
857 if (pstr->offsets_needed) 832 if (pstr->offsets_needed)
858 off = pstr->offsets[off]; 833 off = pstr->offsets[off];
859#endif
860 834
861 ch = pstr->raw_mbs[pstr->raw_mbs_idx + off]; 835 ch = pstr->raw_mbs[pstr->raw_mbs_idx + off];
862 836
863#ifdef RE_ENABLE_I18N
864 /* Ensure that e.g. for tr_TR.UTF-8 BACKSLASH DOTLESS SMALL LETTER I 837 /* Ensure that e.g. for tr_TR.UTF-8 BACKSLASH DOTLESS SMALL LETTER I
865 this function returns CAPITAL LETTER I instead of first byte of 838 this function returns CAPITAL LETTER I instead of first byte of
866 DOTLESS SMALL LETTER I. The latter would confuse the parser, 839 DOTLESS SMALL LETTER I. The latter would confuse the parser,
867 since peek_byte_case doesn't advance cur_idx in any way. */ 840 since peek_byte_case doesn't advance cur_idx in any way. */
868 if (pstr->offsets_needed && !isascii (ch)) 841 if (pstr->offsets_needed && !isascii (ch))
869 return re_string_peek_byte (pstr, idx); 842 return re_string_peek_byte (pstr, idx);
870#endif
871 843
872 return ch; 844 return ch;
873} 845}
@@ -878,7 +850,6 @@ re_string_fetch_byte_case (re_string_t *pstr)
878 if (__glibc_likely (!pstr->mbs_allocated)) 850 if (__glibc_likely (!pstr->mbs_allocated))
879 return re_string_fetch_byte (pstr); 851 return re_string_fetch_byte (pstr);
880 852
881#ifdef RE_ENABLE_I18N
882 if (pstr->offsets_needed) 853 if (pstr->offsets_needed)
883 { 854 {
884 Idx off; 855 Idx off;
@@ -904,7 +875,6 @@ re_string_fetch_byte_case (re_string_t *pstr)
904 re_string_char_size_at (pstr, pstr->cur_idx)); 875 re_string_char_size_at (pstr, pstr->cur_idx));
905 return ch; 876 return ch;
906 } 877 }
907#endif
908 878
909 return pstr->raw_mbs[pstr->raw_mbs_idx + pstr->cur_idx++]; 879 return pstr->raw_mbs[pstr->raw_mbs_idx + pstr->cur_idx++];
910} 880}
@@ -912,10 +882,8 @@ re_string_fetch_byte_case (re_string_t *pstr)
912static void 882static void
913re_string_destruct (re_string_t *pstr) 883re_string_destruct (re_string_t *pstr)
914{ 884{
915#ifdef RE_ENABLE_I18N
916 re_free (pstr->wcs); 885 re_free (pstr->wcs);
917 re_free (pstr->offsets); 886 re_free (pstr->offsets);
918#endif /* RE_ENABLE_I18N */
919 if (pstr->mbs_allocated) 887 if (pstr->mbs_allocated)
920 re_free (pstr->mbs); 888 re_free (pstr->mbs);
921} 889}
@@ -933,7 +901,6 @@ re_string_context_at (const re_string_t *input, Idx idx, int eflags)
933 if (__glibc_unlikely (idx == input->len)) 901 if (__glibc_unlikely (idx == input->len))
934 return ((eflags & REG_NOTEOL) ? CONTEXT_ENDBUF 902 return ((eflags & REG_NOTEOL) ? CONTEXT_ENDBUF
935 : CONTEXT_NEWLINE | CONTEXT_ENDBUF); 903 : CONTEXT_NEWLINE | CONTEXT_ENDBUF);
936#ifdef RE_ENABLE_I18N
937 if (input->mb_cur_max > 1) 904 if (input->mb_cur_max > 1)
938 { 905 {
939 wint_t wc; 906 wint_t wc;
@@ -953,7 +920,6 @@ re_string_context_at (const re_string_t *input, Idx idx, int eflags)
953 ? CONTEXT_NEWLINE : 0); 920 ? CONTEXT_NEWLINE : 0);
954 } 921 }
955 else 922 else
956#endif
957 { 923 {
958 c = re_string_byte_at (input, idx); 924 c = re_string_byte_at (input, idx);
959 if (bitset_contain (input->word_char, c)) 925 if (bitset_contain (input->word_char, c))
@@ -1451,11 +1417,9 @@ re_dfa_add_node (re_dfa_t *dfa, re_token_t token)
1451 } 1417 }
1452 dfa->nodes[dfa->nodes_len] = token; 1418 dfa->nodes[dfa->nodes_len] = token;
1453 dfa->nodes[dfa->nodes_len].constraint = 0; 1419 dfa->nodes[dfa->nodes_len].constraint = 0;
1454#ifdef RE_ENABLE_I18N
1455 dfa->nodes[dfa->nodes_len].accept_mb = 1420 dfa->nodes[dfa->nodes_len].accept_mb =
1456 ((token.type == OP_PERIOD && dfa->mb_cur_max > 1) 1421 ((token.type == OP_PERIOD && dfa->mb_cur_max > 1)
1457 || token.type == COMPLEX_BRACKET); 1422 || token.type == COMPLEX_BRACKET);
1458#endif
1459 dfa->nexts[dfa->nodes_len] = -1; 1423 dfa->nexts[dfa->nodes_len] = -1;
1460 re_node_set_init_empty (dfa->edests + dfa->nodes_len); 1424 re_node_set_init_empty (dfa->edests + dfa->nodes_len);
1461 re_node_set_init_empty (dfa->eclosures + dfa->nodes_len); 1425 re_node_set_init_empty (dfa->eclosures + dfa->nodes_len);
@@ -1651,9 +1615,7 @@ create_ci_newstate (const re_dfa_t *dfa, const re_node_set *nodes,
1651 re_token_type_t type = node->type; 1615 re_token_type_t type = node->type;
1652 if (type == CHARACTER && !node->constraint) 1616 if (type == CHARACTER && !node->constraint)
1653 continue; 1617 continue;
1654#ifdef RE_ENABLE_I18N
1655 newstate->accept_mb |= node->accept_mb; 1618 newstate->accept_mb |= node->accept_mb;
1656#endif /* RE_ENABLE_I18N */
1657 1619
1658 /* If the state has the halt node, the state is a halt state. */ 1620 /* If the state has the halt node, the state is a halt state. */
1659 if (type == END_OF_RE) 1621 if (type == END_OF_RE)
@@ -1705,9 +1667,7 @@ create_cd_newstate (const re_dfa_t *dfa, const re_node_set *nodes,
1705 1667
1706 if (type == CHARACTER && !constraint) 1668 if (type == CHARACTER && !constraint)
1707 continue; 1669 continue;
1708#ifdef RE_ENABLE_I18N
1709 newstate->accept_mb |= node->accept_mb; 1670 newstate->accept_mb |= node->accept_mb;
1710#endif /* RE_ENABLE_I18N */
1711 1671
1712 /* If the state has the halt node, the state is a halt state. */ 1672 /* If the state has the halt node, the state is a halt state. */
1713 if (type == END_OF_RE) 1673 if (type == END_OF_RE)
diff --git a/lib/regex_internal.h b/lib/regex_internal.h
index 1245e782ffc..8493db2701a 100644
--- a/lib/regex_internal.h
+++ b/lib/regex_internal.h
@@ -116,10 +116,6 @@
116# define gettext_noop(String) String 116# define gettext_noop(String) String
117#endif 117#endif
118 118
119#if (defined MB_CUR_MAX && HAVE_WCTYPE_H && HAVE_ISWCTYPE) || _LIBC
120# define RE_ENABLE_I18N
121#endif
122
123/* Number of ASCII characters. */ 119/* Number of ASCII characters. */
124#define ASCII_CHARS 0x80 120#define ASCII_CHARS 0x80
125 121
@@ -150,6 +146,11 @@
150# define __regfree regfree 146# define __regfree regfree
151#endif /* not _LIBC */ 147#endif /* not _LIBC */
152 148
149/* Types related to integers. Unless protected by #ifdef _LIBC, the
150 regex code should avoid exact-width types like int32_t and uint64_t
151 as some non-GCC platforms lack them, an issue when this code is
152 used in Gnulib. */
153
153#ifndef SSIZE_MAX 154#ifndef SSIZE_MAX
154# define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2)) 155# define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2))
155#endif 156#endif
@@ -246,10 +247,8 @@ typedef enum
246 SIMPLE_BRACKET = 3, 247 SIMPLE_BRACKET = 3,
247 OP_BACK_REF = 4, 248 OP_BACK_REF = 4,
248 OP_PERIOD = 5, 249 OP_PERIOD = 5,
249#ifdef RE_ENABLE_I18N
250 COMPLEX_BRACKET = 6, 250 COMPLEX_BRACKET = 6,
251 OP_UTF8_PERIOD = 7, 251 OP_UTF8_PERIOD = 7,
252#endif /* RE_ENABLE_I18N */
253 252
254 /* We define EPSILON_BIT as a macro so that OP_OPEN_SUBEXP is used 253 /* We define EPSILON_BIT as a macro so that OP_OPEN_SUBEXP is used
255 when the debugger shows values of this enum type. */ 254 when the debugger shows values of this enum type. */
@@ -287,30 +286,29 @@ typedef enum
287 286
288} re_token_type_t; 287} re_token_type_t;
289 288
290#ifdef RE_ENABLE_I18N
291typedef struct 289typedef struct
292{ 290{
293 /* Multibyte characters. */ 291 /* Multibyte characters. */
294 wchar_t *mbchars; 292 wchar_t *mbchars;
295 293
294#ifdef _LIBC
296 /* Collating symbols. */ 295 /* Collating symbols. */
297# ifdef _LIBC
298 int32_t *coll_syms; 296 int32_t *coll_syms;
299# endif 297#endif
300 298
299#ifdef _LIBC
301 /* Equivalence classes. */ 300 /* Equivalence classes. */
302# ifdef _LIBC
303 int32_t *equiv_classes; 301 int32_t *equiv_classes;
304# endif 302#endif
305 303
306 /* Range expressions. */ 304 /* Range expressions. */
307# ifdef _LIBC 305#ifdef _LIBC
308 uint32_t *range_starts; 306 uint32_t *range_starts;
309 uint32_t *range_ends; 307 uint32_t *range_ends;
310# else /* not _LIBC */ 308#else
311 wchar_t *range_starts; 309 wchar_t *range_starts;
312 wchar_t *range_ends; 310 wchar_t *range_ends;
313# endif /* not _LIBC */ 311#endif
314 312
315 /* Character classes. */ 313 /* Character classes. */
316 wctype_t *char_classes; 314 wctype_t *char_classes;
@@ -333,7 +331,6 @@ typedef struct
333 /* # of character classes. */ 331 /* # of character classes. */
334 Idx nchar_classes; 332 Idx nchar_classes;
335} re_charset_t; 333} re_charset_t;
336#endif /* RE_ENABLE_I18N */
337 334
338typedef struct 335typedef struct
339{ 336{
@@ -341,9 +338,7 @@ typedef struct
341 { 338 {
342 unsigned char c; /* for CHARACTER */ 339 unsigned char c; /* for CHARACTER */
343 re_bitset_ptr_t sbcset; /* for SIMPLE_BRACKET */ 340 re_bitset_ptr_t sbcset; /* for SIMPLE_BRACKET */
344#ifdef RE_ENABLE_I18N
345 re_charset_t *mbcset; /* for COMPLEX_BRACKET */ 341 re_charset_t *mbcset; /* for COMPLEX_BRACKET */
346#endif /* RE_ENABLE_I18N */
347 Idx idx; /* for BACK_REF */ 342 Idx idx; /* for BACK_REF */
348 re_context_type ctx_type; /* for ANCHOR */ 343 re_context_type ctx_type; /* for ANCHOR */
349 } opr; 344 } opr;
@@ -355,12 +350,10 @@ typedef struct
355 unsigned int constraint : 10; /* context constraint */ 350 unsigned int constraint : 10; /* context constraint */
356 unsigned int duplicated : 1; 351 unsigned int duplicated : 1;
357 unsigned int opt_subexp : 1; 352 unsigned int opt_subexp : 1;
358#ifdef RE_ENABLE_I18N
359 unsigned int accept_mb : 1; 353 unsigned int accept_mb : 1;
360 /* These 2 bits can be moved into the union if needed (e.g. if running out 354 /* These 2 bits can be moved into the union if needed (e.g. if running out
361 of bits; move opr.c to opr.c.c and move the flags to opr.c.flags). */ 355 of bits; move opr.c to opr.c.c and move the flags to opr.c.flags). */
362 unsigned int mb_partial : 1; 356 unsigned int mb_partial : 1;
363#endif
364 unsigned int word_char : 1; 357 unsigned int word_char : 1;
365} re_token_t; 358} re_token_t;
366 359
@@ -375,12 +368,10 @@ struct re_string_t
375 REG_ICASE, upper cases of the string are stored, otherwise MBS points 368 REG_ICASE, upper cases of the string are stored, otherwise MBS points
376 the same address that RAW_MBS points. */ 369 the same address that RAW_MBS points. */
377 unsigned char *mbs; 370 unsigned char *mbs;
378#ifdef RE_ENABLE_I18N
379 /* Store the wide character string which is corresponding to MBS. */ 371 /* Store the wide character string which is corresponding to MBS. */
380 wint_t *wcs; 372 wint_t *wcs;
381 Idx *offsets; 373 Idx *offsets;
382 mbstate_t cur_state; 374 mbstate_t cur_state;
383#endif
384 /* Index in RAW_MBS. Each character mbs[i] corresponds to 375 /* Index in RAW_MBS. Each character mbs[i] corresponds to
385 raw_mbs[raw_mbs_idx + i]. */ 376 raw_mbs[raw_mbs_idx + i]. */
386 Idx raw_mbs_idx; 377 Idx raw_mbs_idx;
@@ -779,7 +770,6 @@ bitset_mask (bitset_t dest, const bitset_t src)
779 dest[bitset_i] &= src[bitset_i]; 770 dest[bitset_i] &= src[bitset_i];
780} 771}
781 772
782#ifdef RE_ENABLE_I18N
783/* Functions for re_string. */ 773/* Functions for re_string. */
784static int 774static int
785__attribute__ ((pure, unused)) 775__attribute__ ((pure, unused))
@@ -803,15 +793,15 @@ re_string_wchar_at (const re_string_t *pstr, Idx idx)
803 return (wint_t) pstr->wcs[idx]; 793 return (wint_t) pstr->wcs[idx];
804} 794}
805 795
806# ifdef _LIBC 796#ifdef _LIBC
807# include <locale/weight.h> 797# include <locale/weight.h>
808# endif 798#endif
809 799
810static int 800static int
811__attribute__ ((pure, unused)) 801__attribute__ ((pure, unused))
812re_string_elem_size_at (const re_string_t *pstr, Idx idx) 802re_string_elem_size_at (const re_string_t *pstr, Idx idx)
813{ 803{
814# ifdef _LIBC 804#ifdef _LIBC
815 const unsigned char *p, *extra; 805 const unsigned char *p, *extra;
816 const int32_t *table, *indirect; 806 const int32_t *table, *indirect;
817 uint_fast32_t nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES); 807 uint_fast32_t nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
@@ -827,11 +817,10 @@ re_string_elem_size_at (const re_string_t *pstr, Idx idx)
827 findidx (table, indirect, extra, &p, pstr->len - idx); 817 findidx (table, indirect, extra, &p, pstr->len - idx);
828 return p - pstr->mbs - idx; 818 return p - pstr->mbs - idx;
829 } 819 }
830 else 820#endif /* _LIBC */
831# endif /* _LIBC */ 821
832 return 1; 822 return 1;
833} 823}
834#endif /* RE_ENABLE_I18N */
835 824
836#ifdef _LIBC 825#ifdef _LIBC
837# if __GNUC__ >= 7 826# if __GNUC__ >= 7
diff --git a/lib/regexec.c b/lib/regexec.c
index 83e9aaf8cad..3196708373f 100644
--- a/lib/regexec.c
+++ b/lib/regexec.c
@@ -67,11 +67,9 @@ static reg_errcode_t set_regs (const regex_t *preg,
67 bool fl_backtrack); 67 bool fl_backtrack);
68static reg_errcode_t free_fail_stack_return (struct re_fail_stack_t *fs); 68static reg_errcode_t free_fail_stack_return (struct re_fail_stack_t *fs);
69 69
70#ifdef RE_ENABLE_I18N
71static int sift_states_iter_mb (const re_match_context_t *mctx, 70static int sift_states_iter_mb (const re_match_context_t *mctx,
72 re_sift_context_t *sctx, 71 re_sift_context_t *sctx,
73 Idx node_idx, Idx str_idx, Idx max_str_idx); 72 Idx node_idx, Idx str_idx, Idx max_str_idx);
74#endif /* RE_ENABLE_I18N */
75static reg_errcode_t sift_states_backward (const re_match_context_t *mctx, 73static reg_errcode_t sift_states_backward (const re_match_context_t *mctx,
76 re_sift_context_t *sctx); 74 re_sift_context_t *sctx);
77static reg_errcode_t build_sifted_states (const re_match_context_t *mctx, 75static reg_errcode_t build_sifted_states (const re_match_context_t *mctx,
@@ -123,10 +121,8 @@ static re_dfastate_t *transit_state_sb (reg_errcode_t *err,
123 re_match_context_t *mctx, 121 re_match_context_t *mctx,
124 re_dfastate_t *pstate); 122 re_dfastate_t *pstate);
125#endif 123#endif
126#ifdef RE_ENABLE_I18N
127static reg_errcode_t transit_state_mb (re_match_context_t *mctx, 124static reg_errcode_t transit_state_mb (re_match_context_t *mctx,
128 re_dfastate_t *pstate); 125 re_dfastate_t *pstate);
129#endif /* RE_ENABLE_I18N */
130static reg_errcode_t transit_state_bkref (re_match_context_t *mctx, 126static reg_errcode_t transit_state_bkref (re_match_context_t *mctx,
131 const re_node_set *nodes); 127 const re_node_set *nodes);
132static reg_errcode_t get_subexp (re_match_context_t *mctx, 128static reg_errcode_t get_subexp (re_match_context_t *mctx,
@@ -156,14 +152,12 @@ static reg_errcode_t expand_bkref_cache (re_match_context_t *mctx,
156 re_node_set *cur_nodes, Idx cur_str, 152 re_node_set *cur_nodes, Idx cur_str,
157 Idx subexp_num, int type); 153 Idx subexp_num, int type);
158static bool build_trtable (const re_dfa_t *dfa, re_dfastate_t *state); 154static bool build_trtable (const re_dfa_t *dfa, re_dfastate_t *state);
159#ifdef RE_ENABLE_I18N
160static int check_node_accept_bytes (const re_dfa_t *dfa, Idx node_idx, 155static int check_node_accept_bytes (const re_dfa_t *dfa, Idx node_idx,
161 const re_string_t *input, Idx idx); 156 const re_string_t *input, Idx idx);
162# ifdef _LIBC 157#ifdef _LIBC
163static unsigned int find_collation_sequence_value (const unsigned char *mbs, 158static unsigned int find_collation_sequence_value (const unsigned char *mbs,
164 size_t name_len); 159 size_t name_len);
165# endif /* _LIBC */ 160#endif
166#endif /* RE_ENABLE_I18N */
167static Idx group_nodes_into_DFAstates (const re_dfa_t *dfa, 161static Idx group_nodes_into_DFAstates (const re_dfa_t *dfa,
168 const re_dfastate_t *state, 162 const re_dfastate_t *state,
169 re_node_set *states_node, 163 re_node_set *states_node,
@@ -758,10 +752,9 @@ re_search_internal (const regex_t *preg, const char *string, Idx length,
758 752
759 offset = match_first - mctx.input.raw_mbs_idx; 753 offset = match_first - mctx.input.raw_mbs_idx;
760 } 754 }
761 /* If MATCH_FIRST is out of the buffer, leave it as '\0'. 755 /* Use buffer byte if OFFSET is in buffer, otherwise '\0'. */
762 Note that MATCH_FIRST must not be smaller than 0. */ 756 ch = (offset < mctx.input.valid_len
763 ch = (match_first >= length 757 ? re_string_byte_at (&mctx.input, offset) : 0);
764 ? 0 : re_string_byte_at (&mctx.input, offset));
765 if (fastmap[ch]) 758 if (fastmap[ch])
766 break; 759 break;
767 match_first += incr; 760 match_first += incr;
@@ -780,12 +773,10 @@ re_search_internal (const regex_t *preg, const char *string, Idx length,
780 if (__glibc_unlikely (err != REG_NOERROR)) 773 if (__glibc_unlikely (err != REG_NOERROR))
781 goto free_return; 774 goto free_return;
782 775
783#ifdef RE_ENABLE_I18N 776 /* Don't consider this char as a possible match start if it part,
784 /* Don't consider this char as a possible match start if it part, 777 yet isn't the head, of a multibyte character. */
785 yet isn't the head, of a multibyte character. */
786 if (!sb && !re_string_first_byte (&mctx.input, 0)) 778 if (!sb && !re_string_first_byte (&mctx.input, 0))
787 continue; 779 continue;
788#endif
789 780
790 /* It seems to be appropriate one, then use the matcher. */ 781 /* It seems to be appropriate one, then use the matcher. */
791 /* We assume that the matching starts from 0. */ 782 /* We assume that the matching starts from 0. */
@@ -859,7 +850,6 @@ re_search_internal (const regex_t *preg, const char *string, Idx length,
859 for (reg_idx = 0; reg_idx < nmatch; ++reg_idx) 850 for (reg_idx = 0; reg_idx < nmatch; ++reg_idx)
860 if (pmatch[reg_idx].rm_so != -1) 851 if (pmatch[reg_idx].rm_so != -1)
861 { 852 {
862#ifdef RE_ENABLE_I18N
863 if (__glibc_unlikely (mctx.input.offsets_needed != 0)) 853 if (__glibc_unlikely (mctx.input.offsets_needed != 0))
864 { 854 {
865 pmatch[reg_idx].rm_so = 855 pmatch[reg_idx].rm_so =
@@ -871,9 +861,6 @@ re_search_internal (const regex_t *preg, const char *string, Idx length,
871 ? mctx.input.valid_raw_len 861 ? mctx.input.valid_raw_len
872 : mctx.input.offsets[pmatch[reg_idx].rm_eo]); 862 : mctx.input.offsets[pmatch[reg_idx].rm_eo]);
873 } 863 }
874#else
875 DEBUG_ASSERT (mctx.input.offsets_needed == 0);
876#endif
877 pmatch[reg_idx].rm_so += match_first; 864 pmatch[reg_idx].rm_so += match_first;
878 pmatch[reg_idx].rm_eo += match_first; 865 pmatch[reg_idx].rm_eo += match_first;
879 } 866 }
@@ -997,8 +984,7 @@ prune_impossible_nodes (re_match_context_t *mctx)
997 We must select appropriate initial state depending on the context, 984 We must select appropriate initial state depending on the context,
998 since initial states may have constraints like "\<", "^", etc.. */ 985 since initial states may have constraints like "\<", "^", etc.. */
999 986
1000static inline re_dfastate_t * 987static __always_inline re_dfastate_t *
1001__attribute__ ((always_inline))
1002acquire_init_state_context (reg_errcode_t *err, const re_match_context_t *mctx, 988acquire_init_state_context (reg_errcode_t *err, const re_match_context_t *mctx,
1003 Idx idx) 989 Idx idx)
1004{ 990{
@@ -1262,12 +1248,9 @@ proceed_next_node (const re_match_context_t *mctx, Idx nregs, regmatch_t *regs,
1262 Idx naccepted = 0; 1248 Idx naccepted = 0;
1263 re_token_type_t type = dfa->nodes[node].type; 1249 re_token_type_t type = dfa->nodes[node].type;
1264 1250
1265#ifdef RE_ENABLE_I18N
1266 if (dfa->nodes[node].accept_mb) 1251 if (dfa->nodes[node].accept_mb)
1267 naccepted = check_node_accept_bytes (dfa, node, &mctx->input, *pidx); 1252 naccepted = check_node_accept_bytes (dfa, node, &mctx->input, *pidx);
1268 else 1253 else if (type == OP_BACK_REF)
1269#endif /* RE_ENABLE_I18N */
1270 if (type == OP_BACK_REF)
1271 { 1254 {
1272 Idx subexp_idx = dfa->nodes[node].opr.idx + 1; 1255 Idx subexp_idx = dfa->nodes[node].opr.idx + 1;
1273 if (subexp_idx < nregs) 1256 if (subexp_idx < nregs)
@@ -1635,12 +1618,10 @@ build_sifted_states (const re_match_context_t *mctx, re_sift_context_t *sctx,
1635 bool ok; 1618 bool ok;
1636 DEBUG_ASSERT (!IS_EPSILON_NODE (dfa->nodes[prev_node].type)); 1619 DEBUG_ASSERT (!IS_EPSILON_NODE (dfa->nodes[prev_node].type));
1637 1620
1638#ifdef RE_ENABLE_I18N
1639 /* If the node may accept "multi byte". */ 1621 /* If the node may accept "multi byte". */
1640 if (dfa->nodes[prev_node].accept_mb) 1622 if (dfa->nodes[prev_node].accept_mb)
1641 naccepted = sift_states_iter_mb (mctx, sctx, prev_node, 1623 naccepted = sift_states_iter_mb (mctx, sctx, prev_node,
1642 str_idx, sctx->last_str_idx); 1624 str_idx, sctx->last_str_idx);
1643#endif /* RE_ENABLE_I18N */
1644 1625
1645 /* We don't check backreferences here. 1626 /* We don't check backreferences here.
1646 See update_cur_sifted_state(). */ 1627 See update_cur_sifted_state(). */
@@ -1689,6 +1670,7 @@ clean_state_log_if_needed (re_match_context_t *mctx, Idx next_state_log_idx)
1689 1670
1690 if (top < next_state_log_idx) 1671 if (top < next_state_log_idx)
1691 { 1672 {
1673 DEBUG_ASSERT (mctx->state_log != NULL);
1692 memset (mctx->state_log + top + 1, '\0', 1674 memset (mctx->state_log + top + 1, '\0',
1693 sizeof (re_dfastate_t *) * (next_state_log_idx - top)); 1675 sizeof (re_dfastate_t *) * (next_state_log_idx - top));
1694 mctx->state_log_top = next_state_log_idx; 1676 mctx->state_log_top = next_state_log_idx;
@@ -2177,7 +2159,6 @@ sift_states_bkref (const re_match_context_t *mctx, re_sift_context_t *sctx,
2177} 2159}
2178 2160
2179 2161
2180#ifdef RE_ENABLE_I18N
2181static int 2162static int
2182sift_states_iter_mb (const re_match_context_t *mctx, re_sift_context_t *sctx, 2163sift_states_iter_mb (const re_match_context_t *mctx, re_sift_context_t *sctx,
2183 Idx node_idx, Idx str_idx, Idx max_str_idx) 2164 Idx node_idx, Idx str_idx, Idx max_str_idx)
@@ -2197,8 +2178,6 @@ sift_states_iter_mb (const re_match_context_t *mctx, re_sift_context_t *sctx,
2197 'naccepted' bytes input. */ 2178 'naccepted' bytes input. */
2198 return naccepted; 2179 return naccepted;
2199} 2180}
2200#endif /* RE_ENABLE_I18N */
2201
2202 2181
2203/* Functions for state transition. */ 2182/* Functions for state transition. */
2204 2183
@@ -2216,7 +2195,6 @@ transit_state (reg_errcode_t *err, re_match_context_t *mctx,
2216 re_dfastate_t **trtable; 2195 re_dfastate_t **trtable;
2217 unsigned char ch; 2196 unsigned char ch;
2218 2197
2219#ifdef RE_ENABLE_I18N
2220 /* If the current state can accept multibyte. */ 2198 /* If the current state can accept multibyte. */
2221 if (__glibc_unlikely (state->accept_mb)) 2199 if (__glibc_unlikely (state->accept_mb))
2222 { 2200 {
@@ -2224,7 +2202,6 @@ transit_state (reg_errcode_t *err, re_match_context_t *mctx,
2224 if (__glibc_unlikely (*err != REG_NOERROR)) 2202 if (__glibc_unlikely (*err != REG_NOERROR))
2225 return NULL; 2203 return NULL;
2226 } 2204 }
2227#endif /* RE_ENABLE_I18N */
2228 2205
2229 /* Then decide the next state with the single byte. */ 2206 /* Then decide the next state with the single byte. */
2230#if 0 2207#if 0
@@ -2445,7 +2422,6 @@ transit_state_sb (reg_errcode_t *err, re_match_context_t *mctx,
2445} 2422}
2446#endif 2423#endif
2447 2424
2448#ifdef RE_ENABLE_I18N
2449static reg_errcode_t 2425static reg_errcode_t
2450transit_state_mb (re_match_context_t *mctx, re_dfastate_t *pstate) 2426transit_state_mb (re_match_context_t *mctx, re_dfastate_t *pstate)
2451{ 2427{
@@ -2513,7 +2489,6 @@ transit_state_mb (re_match_context_t *mctx, re_dfastate_t *pstate)
2513 } 2489 }
2514 return REG_NOERROR; 2490 return REG_NOERROR;
2515} 2491}
2516#endif /* RE_ENABLE_I18N */
2517 2492
2518static reg_errcode_t 2493static reg_errcode_t
2519transit_state_bkref (re_match_context_t *mctx, const re_node_set *nodes) 2494transit_state_bkref (re_match_context_t *mctx, const re_node_set *nodes)
@@ -3003,9 +2978,7 @@ check_arrival_add_next_nodes (re_match_context_t *mctx, Idx str_idx,
3003 const re_dfa_t *const dfa = mctx->dfa; 2978 const re_dfa_t *const dfa = mctx->dfa;
3004 bool ok; 2979 bool ok;
3005 Idx cur_idx; 2980 Idx cur_idx;
3006#ifdef RE_ENABLE_I18N
3007 reg_errcode_t err = REG_NOERROR; 2981 reg_errcode_t err = REG_NOERROR;
3008#endif
3009 re_node_set union_set; 2982 re_node_set union_set;
3010 re_node_set_init_empty (&union_set); 2983 re_node_set_init_empty (&union_set);
3011 for (cur_idx = 0; cur_idx < cur_nodes->nelem; ++cur_idx) 2984 for (cur_idx = 0; cur_idx < cur_nodes->nelem; ++cur_idx)
@@ -3014,7 +2987,6 @@ check_arrival_add_next_nodes (re_match_context_t *mctx, Idx str_idx,
3014 Idx cur_node = cur_nodes->elems[cur_idx]; 2987 Idx cur_node = cur_nodes->elems[cur_idx];
3015 DEBUG_ASSERT (!IS_EPSILON_NODE (dfa->nodes[cur_node].type)); 2988 DEBUG_ASSERT (!IS_EPSILON_NODE (dfa->nodes[cur_node].type));
3016 2989
3017#ifdef RE_ENABLE_I18N
3018 /* If the node may accept "multi byte". */ 2990 /* If the node may accept "multi byte". */
3019 if (dfa->nodes[cur_node].accept_mb) 2991 if (dfa->nodes[cur_node].accept_mb)
3020 { 2992 {
@@ -3052,7 +3024,7 @@ check_arrival_add_next_nodes (re_match_context_t *mctx, Idx str_idx,
3052 } 3024 }
3053 } 3025 }
3054 } 3026 }
3055#endif /* RE_ENABLE_I18N */ 3027
3056 if (naccepted 3028 if (naccepted
3057 || check_node_accept (mctx, dfa->nodes + cur_node, str_idx)) 3029 || check_node_accept (mctx, dfa->nodes + cur_node, str_idx))
3058 { 3030 {
@@ -3476,18 +3448,15 @@ group_nodes_into_DFAstates (const re_dfa_t *dfa, const re_dfastate_t *state,
3476 } 3448 }
3477 else if (type == OP_PERIOD) 3449 else if (type == OP_PERIOD)
3478 { 3450 {
3479#ifdef RE_ENABLE_I18N
3480 if (dfa->mb_cur_max > 1) 3451 if (dfa->mb_cur_max > 1)
3481 bitset_merge (accepts, dfa->sb_char); 3452 bitset_merge (accepts, dfa->sb_char);
3482 else 3453 else
3483#endif
3484 bitset_set_all (accepts); 3454 bitset_set_all (accepts);
3485 if (!(dfa->syntax & RE_DOT_NEWLINE)) 3455 if (!(dfa->syntax & RE_DOT_NEWLINE))
3486 bitset_clear (accepts, '\n'); 3456 bitset_clear (accepts, '\n');
3487 if (dfa->syntax & RE_DOT_NOT_NULL) 3457 if (dfa->syntax & RE_DOT_NOT_NULL)
3488 bitset_clear (accepts, '\0'); 3458 bitset_clear (accepts, '\0');
3489 } 3459 }
3490#ifdef RE_ENABLE_I18N
3491 else if (type == OP_UTF8_PERIOD) 3460 else if (type == OP_UTF8_PERIOD)
3492 { 3461 {
3493 if (ASCII_CHARS % BITSET_WORD_BITS == 0) 3462 if (ASCII_CHARS % BITSET_WORD_BITS == 0)
@@ -3499,7 +3468,6 @@ group_nodes_into_DFAstates (const re_dfa_t *dfa, const re_dfastate_t *state,
3499 if (dfa->syntax & RE_DOT_NOT_NULL) 3468 if (dfa->syntax & RE_DOT_NOT_NULL)
3500 bitset_clear (accepts, '\0'); 3469 bitset_clear (accepts, '\0');
3501 } 3470 }
3502#endif
3503 else 3471 else
3504 continue; 3472 continue;
3505 3473
@@ -3530,12 +3498,10 @@ group_nodes_into_DFAstates (const re_dfa_t *dfa, const re_dfastate_t *state,
3530 bitset_empty (accepts); 3498 bitset_empty (accepts);
3531 continue; 3499 continue;
3532 } 3500 }
3533#ifdef RE_ENABLE_I18N
3534 if (dfa->mb_cur_max > 1) 3501 if (dfa->mb_cur_max > 1)
3535 for (j = 0; j < BITSET_WORDS; ++j) 3502 for (j = 0; j < BITSET_WORDS; ++j)
3536 any_set |= (accepts[j] &= (dfa->word_char[j] | ~dfa->sb_char[j])); 3503 any_set |= (accepts[j] &= (dfa->word_char[j] | ~dfa->sb_char[j]));
3537 else 3504 else
3538#endif
3539 for (j = 0; j < BITSET_WORDS; ++j) 3505 for (j = 0; j < BITSET_WORDS; ++j)
3540 any_set |= (accepts[j] &= dfa->word_char[j]); 3506 any_set |= (accepts[j] &= dfa->word_char[j]);
3541 if (!any_set) 3507 if (!any_set)
@@ -3549,12 +3515,10 @@ group_nodes_into_DFAstates (const re_dfa_t *dfa, const re_dfastate_t *state,
3549 bitset_empty (accepts); 3515 bitset_empty (accepts);
3550 continue; 3516 continue;
3551 } 3517 }
3552#ifdef RE_ENABLE_I18N
3553 if (dfa->mb_cur_max > 1) 3518 if (dfa->mb_cur_max > 1)
3554 for (j = 0; j < BITSET_WORDS; ++j) 3519 for (j = 0; j < BITSET_WORDS; ++j)
3555 any_set |= (accepts[j] &= ~(dfa->word_char[j] & dfa->sb_char[j])); 3520 any_set |= (accepts[j] &= ~(dfa->word_char[j] & dfa->sb_char[j]));
3556 else 3521 else
3557#endif
3558 for (j = 0; j < BITSET_WORDS; ++j) 3522 for (j = 0; j < BITSET_WORDS; ++j)
3559 any_set |= (accepts[j] &= ~dfa->word_char[j]); 3523 any_set |= (accepts[j] &= ~dfa->word_char[j]);
3560 if (!any_set) 3524 if (!any_set)
@@ -3631,7 +3595,6 @@ group_nodes_into_DFAstates (const re_dfa_t *dfa, const re_dfastate_t *state,
3631 return -1; 3595 return -1;
3632} 3596}
3633 3597
3634#ifdef RE_ENABLE_I18N
3635/* Check how many bytes the node 'dfa->nodes[node_idx]' accepts. 3598/* Check how many bytes the node 'dfa->nodes[node_idx]' accepts.
3636 Return the number of the bytes the node accepts. 3599 Return the number of the bytes the node accepts.
3637 STR_IDX is the current index of the input string. 3600 STR_IDX is the current index of the input string.
@@ -3640,9 +3603,9 @@ group_nodes_into_DFAstates (const re_dfa_t *dfa, const re_dfastate_t *state,
3640 one collating element like '.', '[a-z]', opposite to the other nodes 3603 one collating element like '.', '[a-z]', opposite to the other nodes
3641 can only accept one byte. */ 3604 can only accept one byte. */
3642 3605
3643# ifdef _LIBC 3606#ifdef _LIBC
3644# include <locale/weight.h> 3607# include <locale/weight.h>
3645# endif 3608#endif
3646 3609
3647static int 3610static int
3648check_node_accept_bytes (const re_dfa_t *dfa, Idx node_idx, 3611check_node_accept_bytes (const re_dfa_t *dfa, Idx node_idx,
@@ -3726,12 +3689,12 @@ check_node_accept_bytes (const re_dfa_t *dfa, Idx node_idx,
3726 if (node->type == COMPLEX_BRACKET) 3689 if (node->type == COMPLEX_BRACKET)
3727 { 3690 {
3728 const re_charset_t *cset = node->opr.mbcset; 3691 const re_charset_t *cset = node->opr.mbcset;
3729# ifdef _LIBC 3692#ifdef _LIBC
3730 const unsigned char *pin 3693 const unsigned char *pin
3731 = ((const unsigned char *) re_string_get_buffer (input) + str_idx); 3694 = ((const unsigned char *) re_string_get_buffer (input) + str_idx);
3732 Idx j; 3695 Idx j;
3733 uint32_t nrules; 3696 uint32_t nrules;
3734# endif /* _LIBC */ 3697#endif
3735 int match_len = 0; 3698 int match_len = 0;
3736 wchar_t wc = ((cset->nranges || cset->nchar_classes || cset->nmbchars) 3699 wchar_t wc = ((cset->nranges || cset->nchar_classes || cset->nmbchars)
3737 ? re_string_wchar_at (input, str_idx) : 0); 3700 ? re_string_wchar_at (input, str_idx) : 0);
@@ -3754,7 +3717,7 @@ check_node_accept_bytes (const re_dfa_t *dfa, Idx node_idx,
3754 } 3717 }
3755 } 3718 }
3756 3719
3757# ifdef _LIBC 3720#ifdef _LIBC
3758 nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES); 3721 nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
3759 if (nrules != 0) 3722 if (nrules != 0)
3760 { 3723 {
@@ -3843,7 +3806,7 @@ check_node_accept_bytes (const re_dfa_t *dfa, Idx node_idx,
3843 } 3806 }
3844 } 3807 }
3845 else 3808 else
3846# endif /* _LIBC */ 3809#endif /* _LIBC */
3847 { 3810 {
3848 /* match with range expression? */ 3811 /* match with range expression? */
3849 for (i = 0; i < cset->nranges; ++i) 3812 for (i = 0; i < cset->nranges; ++i)
@@ -3869,7 +3832,7 @@ check_node_accept_bytes (const re_dfa_t *dfa, Idx node_idx,
3869 return 0; 3832 return 0;
3870} 3833}
3871 3834
3872# ifdef _LIBC 3835#ifdef _LIBC
3873static unsigned int 3836static unsigned int
3874find_collation_sequence_value (const unsigned char *mbs, size_t mbs_len) 3837find_collation_sequence_value (const unsigned char *mbs, size_t mbs_len)
3875{ 3838{
@@ -3927,8 +3890,7 @@ find_collation_sequence_value (const unsigned char *mbs, size_t mbs_len)
3927 return UINT_MAX; 3890 return UINT_MAX;
3928 } 3891 }
3929} 3892}
3930# endif /* _LIBC */ 3893#endif /* _LIBC */
3931#endif /* RE_ENABLE_I18N */
3932 3894
3933/* Check whether the node accepts the byte which is IDX-th 3895/* Check whether the node accepts the byte which is IDX-th
3934 byte of the INPUT. */ 3896 byte of the INPUT. */
@@ -3951,12 +3913,10 @@ check_node_accept (const re_match_context_t *mctx, const re_token_t *node,
3951 return false; 3913 return false;
3952 break; 3914 break;
3953 3915
3954#ifdef RE_ENABLE_I18N
3955 case OP_UTF8_PERIOD: 3916 case OP_UTF8_PERIOD:
3956 if (ch >= ASCII_CHARS) 3917 if (ch >= ASCII_CHARS)
3957 return false; 3918 return false;
3958 FALLTHROUGH; 3919 FALLTHROUGH;
3959#endif
3960 case OP_PERIOD: 3920 case OP_PERIOD:
3961 if ((ch == '\n' && !(mctx->dfa->syntax & RE_DOT_NEWLINE)) 3921 if ((ch == '\n' && !(mctx->dfa->syntax & RE_DOT_NEWLINE))
3962 || (ch == '\0' && (mctx->dfa->syntax & RE_DOT_NOT_NULL))) 3922 || (ch == '\0' && (mctx->dfa->syntax & RE_DOT_NOT_NULL)))
@@ -4017,7 +3977,6 @@ extend_buffers (re_match_context_t *mctx, int min_len)
4017 /* Then reconstruct the buffers. */ 3977 /* Then reconstruct the buffers. */
4018 if (pstr->icase) 3978 if (pstr->icase)
4019 { 3979 {
4020#ifdef RE_ENABLE_I18N
4021 if (pstr->mb_cur_max > 1) 3980 if (pstr->mb_cur_max > 1)
4022 { 3981 {
4023 ret = build_wcs_upper_buffer (pstr); 3982 ret = build_wcs_upper_buffer (pstr);
@@ -4025,16 +3984,13 @@ extend_buffers (re_match_context_t *mctx, int min_len)
4025 return ret; 3984 return ret;
4026 } 3985 }
4027 else 3986 else
4028#endif /* RE_ENABLE_I18N */
4029 build_upper_buffer (pstr); 3987 build_upper_buffer (pstr);
4030 } 3988 }
4031 else 3989 else
4032 { 3990 {
4033#ifdef RE_ENABLE_I18N
4034 if (pstr->mb_cur_max > 1) 3991 if (pstr->mb_cur_max > 1)
4035 build_wcs_buffer (pstr); 3992 build_wcs_buffer (pstr);
4036 else 3993 else
4037#endif /* RE_ENABLE_I18N */
4038 { 3994 {
4039 if (pstr->trans != NULL) 3995 if (pstr->trans != NULL)
4040 re_string_translate_buffer (pstr); 3996 re_string_translate_buffer (pstr);
diff --git a/lib/string.in.h b/lib/string.in.h
index 8d77ae38000..afe73508677 100644
--- a/lib/string.in.h
+++ b/lib/string.in.h
@@ -67,6 +67,35 @@
67# include <strings.h> 67# include <strings.h>
68#endif 68#endif
69 69
70/* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers
71 that can be freed by passing them as the Ith argument to the
72 function F. */
73#ifndef _GL_ATTRIBUTE_DEALLOC
74# if __GNUC__ >= 11
75# define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i)))
76# else
77# define _GL_ATTRIBUTE_DEALLOC(f, i)
78# endif
79#endif
80
81/* _GL_ATTRIBUTE_DEALLOC_FREE declares that the function returns pointers that
82 can be freed via 'free'; it can be used only after declaring 'free'. */
83/* Applies to: functions. Cannot be used on inline functions. */
84#ifndef _GL_ATTRIBUTE_DEALLOC_FREE
85# define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (free, 1)
86#endif
87
88/* _GL_ATTRIBUTE_MALLOC declares that the function returns a pointer to freshly
89 allocated memory. */
90/* Applies to: functions. */
91#ifndef _GL_ATTRIBUTE_MALLOC
92# if __GNUC__ >= 3 || defined __clang__
93# define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
94# else
95# define _GL_ATTRIBUTE_MALLOC
96# endif
97#endif
98
70/* The __attribute__ feature is available in gcc versions 2.5 and later. 99/* The __attribute__ feature is available in gcc versions 2.5 and later.
71 The attribute __pure__ was added in gcc 2.96. */ 100 The attribute __pure__ was added in gcc 2.96. */
72#ifndef _GL_ATTRIBUTE_PURE 101#ifndef _GL_ATTRIBUTE_PURE
diff --git a/lib/sys_random.in.h b/lib/sys_random.in.h
index 1abd6c544e0..8b4b934a1e7 100644
--- a/lib/sys_random.in.h
+++ b/lib/sys_random.in.h
@@ -23,8 +23,10 @@
23 23
24#if @HAVE_SYS_RANDOM_H@ 24#if @HAVE_SYS_RANDOM_H@
25 25
26/* On uClibc, <sys/random.h> assumes prior inclusion of <stddef.h>. */ 26/* On uClibc < 1.0.35, <sys/random.h> assumes prior inclusion of <stddef.h>.
27# if defined __UCLIBC__ 27 Do not use __UCLIBC__ here, as it might not be defined yet.
28 But avoid namespace pollution on glibc systems. */
29# ifndef __GLIBC__
28# include <stddef.h> 30# include <stddef.h>
29# endif 31# endif
30/* On Mac OS X 10.5, <sys/random.h> assumes prior inclusion of <sys/types.h>. 32/* On Mac OS X 10.5, <sys/random.h> assumes prior inclusion of <sys/types.h>.