aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggert2018-10-15 00:55:37 -0500
committerPaul Eggert2018-10-15 00:57:57 -0500
commit3d91dc1bb5aeecda786ebe1805c33d14c8bd89fa (patch)
tree155498240a837b179319741542aaa78c8a47c9ab
parent6b8fd34c4ab1aa23b180440cdc8210900896bbf4 (diff)
downloademacs-3d91dc1bb5aeecda786ebe1805c33d14c8bd89fa.tar.gz
emacs-3d91dc1bb5aeecda786ebe1805c33d14c8bd89fa.zip
Update lib/regex from glibc via Gnulib
This syncs recent refactorings from glibc, and incorporates: 2018-10-15 libc-config: merge from glibc 2018-10-15 regex: depend on libc-config * .gitignore: Do not ignore m4/_*.m4. * lib/cdefs.h: New file, copied from Gnulib. * lib/gnulib.mk.in, m4/gnulib-comp.m4: Regenerate. * lib/libc-config.h, m4/__inline.m4: New files, copied from Gnulib. * lib/regcomp.c, lib/regex.c, lib/regex_internal.c: * lib/regex_internal.h, lib/regexec.c: Copy from glibc via Gnulib.
-rw-r--r--.gitignore1
-rw-r--r--lib/cdefs.h514
-rw-r--r--lib/gnulib.mk.in12
-rw-r--r--lib/libc-config.h174
-rw-r--r--lib/regcomp.c305
-rw-r--r--lib/regex.c2
-rw-r--r--lib/regex_internal.c152
-rw-r--r--lib/regex_internal.h20
-rw-r--r--lib/regexec.c363
-rw-r--r--m4/__inline.m422
-rw-r--r--m4/gnulib-comp.m416
11 files changed, 1163 insertions, 418 deletions
diff --git a/.gitignore b/.gitignore
index 26fe4bb34e8..8ab4e8d4077 100644
--- a/.gitignore
+++ b/.gitignore
@@ -264,6 +264,7 @@ etc/emacs.tmpdesktop
264*.in-h 264*.in-h
265_* 265_*
266!lib/_Noreturn.h 266!lib/_Noreturn.h
267!m4/_*.m4
267/bin/ 268/bin/
268/BIN/ 269/BIN/
269/data/ 270/data/
diff --git a/lib/cdefs.h b/lib/cdefs.h
new file mode 100644
index 00000000000..2d620cccaff
--- /dev/null
+++ b/lib/cdefs.h
@@ -0,0 +1,514 @@
1/* Copyright (C) 1992-2018 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public
6 License as published by the Free Software Foundation; either
7 version 3 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 General Public License for more details.
13
14 You should have received a copy of the GNU General Public
15 License along with the GNU C Library; if not, see
16 <https://www.gnu.org/licenses/>. */
17
18#ifndef _SYS_CDEFS_H
19#define _SYS_CDEFS_H 1
20
21/* We are almost always included from features.h. */
22#ifndef _FEATURES_H
23# include <features.h>
24#endif
25
26/* The GNU libc does not support any K&R compilers or the traditional mode
27 of ISO C compilers anymore. Check for some of the combinations not
28 anymore supported. */
29#if defined __GNUC__ && !defined __STDC__
30# error "You need a ISO C conforming compiler to use the glibc headers"
31#endif
32
33/* Some user header file might have defined this before. */
34#undef __P
35#undef __PMT
36
37#ifdef __GNUC__
38
39/* All functions, except those with callbacks or those that
40 synchronize memory, are leaf functions. */
41# if __GNUC_PREREQ (4, 6) && !defined _LIBC
42# define __LEAF , __leaf__
43# define __LEAF_ATTR __attribute__ ((__leaf__))
44# else
45# define __LEAF
46# define __LEAF_ATTR
47# endif
48
49/* GCC can always grok prototypes. For C++ programs we add throw()
50 to help it optimize the function calls. But this works only with
51 gcc 2.8.x and egcs. For gcc 3.2 and up we even mark C functions
52 as non-throwing using a function attribute since programs can use
53 the -fexceptions options for C code as well. */
54# if !defined __cplusplus && __GNUC_PREREQ (3, 3)
55# define __THROW __attribute__ ((__nothrow__ __LEAF))
56# define __THROWNL __attribute__ ((__nothrow__))
57# define __NTH(fct) __attribute__ ((__nothrow__ __LEAF)) fct
58# define __NTHNL(fct) __attribute__ ((__nothrow__)) fct
59# else
60# if defined __cplusplus && __GNUC_PREREQ (2,8)
61# define __THROW throw ()
62# define __THROWNL throw ()
63# define __NTH(fct) __LEAF_ATTR fct throw ()
64# define __NTHNL(fct) fct throw ()
65# else
66# define __THROW
67# define __THROWNL
68# define __NTH(fct) fct
69# define __NTHNL(fct) fct
70# endif
71# endif
72
73#else /* Not GCC. */
74
75# if (defined __cplusplus \
76 || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L))
77# define __inline inline
78# else
79# define __inline /* No inline functions. */
80# endif
81
82# define __THROW
83# define __THROWNL
84# define __NTH(fct) fct
85
86#endif /* GCC. */
87
88/* Compilers that are not clang may object to
89 #if defined __clang__ && __has_extension(...)
90 even though they do not need to evaluate the right-hand side of the &&. */
91#if defined __clang__ && defined __has_extension
92# define __glibc_clang_has_extension(ext) __has_extension (ext)
93#else
94# define __glibc_clang_has_extension(ext) 0
95#endif
96
97/* These two macros are not used in glibc anymore. They are kept here
98 only because some other projects expect the macros to be defined. */
99#define __P(args) args
100#define __PMT(args) args
101
102/* For these things, GCC behaves the ANSI way normally,
103 and the non-ANSI way under -traditional. */
104
105#define __CONCAT(x,y) x ## y
106#define __STRING(x) #x
107
108/* This is not a typedef so `const __ptr_t' does the right thing. */
109#define __ptr_t void *
110
111
112/* C++ needs to know that types and declarations are C, not C++. */
113#ifdef __cplusplus
114# define __BEGIN_DECLS extern "C" {
115# define __END_DECLS }
116#else
117# define __BEGIN_DECLS
118# define __END_DECLS
119#endif
120
121
122/* Fortify support. */
123#define __bos(ptr) __builtin_object_size (ptr, __USE_FORTIFY_LEVEL > 1)
124#define __bos0(ptr) __builtin_object_size (ptr, 0)
125
126#if __GNUC_PREREQ (4,3)
127# define __warndecl(name, msg) \
128 extern void name (void) __attribute__((__warning__ (msg)))
129# define __warnattr(msg) __attribute__((__warning__ (msg)))
130# define __errordecl(name, msg) \
131 extern void name (void) __attribute__((__error__ (msg)))
132#else
133# define __warndecl(name, msg) extern void name (void)
134# define __warnattr(msg)
135# define __errordecl(name, msg) extern void name (void)
136#endif
137
138/* Support for flexible arrays.
139 Headers that should use flexible arrays only if they're "real"
140 (e.g. only if they won't affect sizeof()) should test
141 #if __glibc_c99_flexarr_available. */
142#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
143# define __flexarr []
144# define __glibc_c99_flexarr_available 1
145#elif __GNUC_PREREQ (2,97)
146/* GCC 2.97 supports C99 flexible array members as an extension,
147 even when in C89 mode or compiling C++ (any version). */
148# define __flexarr []
149# define __glibc_c99_flexarr_available 1
150#elif defined __GNUC__
151/* Pre-2.97 GCC did not support C99 flexible arrays but did have
152 an equivalent extension with slightly different notation. */
153# define __flexarr [0]
154# define __glibc_c99_flexarr_available 1
155#else
156/* Some other non-C99 compiler. Approximate with [1]. */
157# define __flexarr [1]
158# define __glibc_c99_flexarr_available 0
159#endif
160
161
162/* __asm__ ("xyz") is used throughout the headers to rename functions
163 at the assembly language level. This is wrapped by the __REDIRECT
164 macro, in order to support compilers that can do this some other
165 way. When compilers don't support asm-names at all, we have to do
166 preprocessor tricks instead (which don't have exactly the right
167 semantics, but it's the best we can do).
168
169 Example:
170 int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); */
171
172#if defined __GNUC__ && __GNUC__ >= 2
173
174# define __REDIRECT(name, proto, alias) name proto __asm__ (__ASMNAME (#alias))
175# ifdef __cplusplus
176# define __REDIRECT_NTH(name, proto, alias) \
177 name proto __THROW __asm__ (__ASMNAME (#alias))
178# define __REDIRECT_NTHNL(name, proto, alias) \
179 name proto __THROWNL __asm__ (__ASMNAME (#alias))
180# else
181# define __REDIRECT_NTH(name, proto, alias) \
182 name proto __asm__ (__ASMNAME (#alias)) __THROW
183# define __REDIRECT_NTHNL(name, proto, alias) \
184 name proto __asm__ (__ASMNAME (#alias)) __THROWNL
185# endif
186# define __ASMNAME(cname) __ASMNAME2 (__USER_LABEL_PREFIX__, cname)
187# define __ASMNAME2(prefix, cname) __STRING (prefix) cname
188
189/*
190#elif __SOME_OTHER_COMPILER__
191
192# define __REDIRECT(name, proto, alias) name proto; \
193 _Pragma("let " #name " = " #alias)
194*/
195#endif
196
197/* GCC has various useful declarations that can be made with the
198 `__attribute__' syntax. All of the ways we use this do fine if
199 they are omitted for compilers that don't understand it. */
200#if !defined __GNUC__ || __GNUC__ < 2
201# define __attribute__(xyz) /* Ignore */
202#endif
203
204/* At some point during the gcc 2.96 development the `malloc' attribute
205 for functions was introduced. We don't want to use it unconditionally
206 (although this would be possible) since it generates warnings. */
207#if __GNUC_PREREQ (2,96)
208# define __attribute_malloc__ __attribute__ ((__malloc__))
209#else
210# define __attribute_malloc__ /* Ignore */
211#endif
212
213/* Tell the compiler which arguments to an allocation function
214 indicate the size of the allocation. */
215#if __GNUC_PREREQ (4, 3)
216# define __attribute_alloc_size__(params) \
217 __attribute__ ((__alloc_size__ params))
218#else
219# define __attribute_alloc_size__(params) /* Ignore. */
220#endif
221
222/* At some point during the gcc 2.96 development the `pure' attribute
223 for functions was introduced. We don't want to use it unconditionally
224 (although this would be possible) since it generates warnings. */
225#if __GNUC_PREREQ (2,96)
226# define __attribute_pure__ __attribute__ ((__pure__))
227#else
228# define __attribute_pure__ /* Ignore */
229#endif
230
231/* This declaration tells the compiler that the value is constant. */
232#if __GNUC_PREREQ (2,5)
233# define __attribute_const__ __attribute__ ((__const__))
234#else
235# define __attribute_const__ /* Ignore */
236#endif
237
238/* At some point during the gcc 3.1 development the `used' attribute
239 for functions was introduced. We don't want to use it unconditionally
240 (although this would be possible) since it generates warnings. */
241#if __GNUC_PREREQ (3,1)
242# define __attribute_used__ __attribute__ ((__used__))
243# define __attribute_noinline__ __attribute__ ((__noinline__))
244#else
245# define __attribute_used__ __attribute__ ((__unused__))
246# define __attribute_noinline__ /* Ignore */
247#endif
248
249/* Since version 3.2, gcc allows marking deprecated functions. */
250#if __GNUC_PREREQ (3,2)
251# define __attribute_deprecated__ __attribute__ ((__deprecated__))
252#else
253# define __attribute_deprecated__ /* Ignore */
254#endif
255
256/* Since version 4.5, gcc also allows one to specify the message printed
257 when a deprecated function is used. clang claims to be gcc 4.2, but
258 may also support this feature. */
259#if __GNUC_PREREQ (4,5) || \
260 __glibc_clang_has_extension (__attribute_deprecated_with_message__)
261# define __attribute_deprecated_msg__(msg) \
262 __attribute__ ((__deprecated__ (msg)))
263#else
264# define __attribute_deprecated_msg__(msg) __attribute_deprecated__
265#endif
266
267/* At some point during the gcc 2.8 development the `format_arg' attribute
268 for functions was introduced. We don't want to use it unconditionally
269 (although this would be possible) since it generates warnings.
270 If several `format_arg' attributes are given for the same function, in
271 gcc-3.0 and older, all but the last one are ignored. In newer gccs,
272 all designated arguments are considered. */
273#if __GNUC_PREREQ (2,8)
274# define __attribute_format_arg__(x) __attribute__ ((__format_arg__ (x)))
275#else
276# define __attribute_format_arg__(x) /* Ignore */
277#endif
278
279/* At some point during the gcc 2.97 development the `strfmon' format
280 attribute for functions was introduced. We don't want to use it
281 unconditionally (although this would be possible) since it
282 generates warnings. */
283#if __GNUC_PREREQ (2,97)
284# define __attribute_format_strfmon__(a,b) \
285 __attribute__ ((__format__ (__strfmon__, a, b)))
286#else
287# define __attribute_format_strfmon__(a,b) /* Ignore */
288#endif
289
290/* The nonnull function attribute marks pointer parameters that
291 must not be NULL. Do not define __nonnull if it is already defined,
292 for portability when this file is used in Gnulib. */
293#ifndef __nonnull
294# if __GNUC_PREREQ (3,3)
295# define __nonnull(params) __attribute__ ((__nonnull__ params))
296# else
297# define __nonnull(params)
298# endif
299#endif
300
301/* If fortification mode, we warn about unused results of certain
302 function calls which can lead to problems. */
303#if __GNUC_PREREQ (3,4)
304# define __attribute_warn_unused_result__ \
305 __attribute__ ((__warn_unused_result__))
306# if defined __USE_FORTIFY_LEVEL && __USE_FORTIFY_LEVEL > 0
307# define __wur __attribute_warn_unused_result__
308# endif
309#else
310# define __attribute_warn_unused_result__ /* empty */
311#endif
312#ifndef __wur
313# define __wur /* Ignore */
314#endif
315
316/* Forces a function to be always inlined. */
317#if __GNUC_PREREQ (3,2)
318/* The Linux kernel defines __always_inline in stddef.h (283d7573), and
319 it conflicts with this definition. Therefore undefine it first to
320 allow either header to be included first. */
321# undef __always_inline
322# define __always_inline __inline __attribute__ ((__always_inline__))
323#else
324# undef __always_inline
325# define __always_inline __inline
326#endif
327
328/* Associate error messages with the source location of the call site rather
329 than with the source location inside the function. */
330#if __GNUC_PREREQ (4,3)
331# define __attribute_artificial__ __attribute__ ((__artificial__))
332#else
333# define __attribute_artificial__ /* Ignore */
334#endif
335
336/* GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99
337 inline semantics, unless -fgnu89-inline is used. Using __GNUC_STDC_INLINE__
338 or __GNUC_GNU_INLINE is not a good enough check for gcc because gcc versions
339 older than 4.3 may define these macros and still not guarantee GNU inlining
340 semantics.
341
342 clang++ identifies itself as gcc-4.2, but has support for GNU inlining
343 semantics, that can be checked fot by using the __GNUC_STDC_INLINE_ and
344 __GNUC_GNU_INLINE__ macro definitions. */
345#if (!defined __cplusplus || __GNUC_PREREQ (4,3) \
346 || (defined __clang__ && (defined __GNUC_STDC_INLINE__ \
347 || defined __GNUC_GNU_INLINE__)))
348# if defined __GNUC_STDC_INLINE__ || defined __cplusplus
349# define __extern_inline extern __inline __attribute__ ((__gnu_inline__))
350# define __extern_always_inline \
351 extern __always_inline __attribute__ ((__gnu_inline__))
352# else
353# define __extern_inline extern __inline
354# define __extern_always_inline extern __always_inline
355# endif
356#endif
357
358#ifdef __extern_always_inline
359# define __fortify_function __extern_always_inline __attribute_artificial__
360#endif
361
362/* GCC 4.3 and above allow passing all anonymous arguments of an
363 __extern_always_inline function to some other vararg function. */
364#if __GNUC_PREREQ (4,3)
365# define __va_arg_pack() __builtin_va_arg_pack ()
366# define __va_arg_pack_len() __builtin_va_arg_pack_len ()
367#endif
368
369/* It is possible to compile containing GCC extensions even if GCC is
370 run in pedantic mode if the uses are carefully marked using the
371 `__extension__' keyword. But this is not generally available before
372 version 2.8. */
373#if !__GNUC_PREREQ (2,8)
374# define __extension__ /* Ignore */
375#endif
376
377/* __restrict is known in EGCS 1.2 and above. */
378#if !__GNUC_PREREQ (2,92)
379# if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
380# define __restrict restrict
381# else
382# define __restrict /* Ignore */
383# endif
384#endif
385
386/* ISO C99 also allows to declare arrays as non-overlapping. The syntax is
387 array_name[restrict]
388 GCC 3.1 supports this. */
389#if __GNUC_PREREQ (3,1) && !defined __GNUG__
390# define __restrict_arr __restrict
391#else
392# ifdef __GNUC__
393# define __restrict_arr /* Not supported in old GCC. */
394# else
395# if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
396# define __restrict_arr restrict
397# else
398/* Some other non-C99 compiler. */
399# define __restrict_arr /* Not supported. */
400# endif
401# endif
402#endif
403
404#if __GNUC__ >= 3
405# define __glibc_unlikely(cond) __builtin_expect ((cond), 0)
406# define __glibc_likely(cond) __builtin_expect ((cond), 1)
407#else
408# define __glibc_unlikely(cond) (cond)
409# define __glibc_likely(cond) (cond)
410#endif
411
412#ifdef __has_attribute
413# define __glibc_has_attribute(attr) __has_attribute (attr)
414#else
415# define __glibc_has_attribute(attr) 0
416#endif
417
418#if (!defined _Noreturn \
419 && (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 201112 \
420 && !__GNUC_PREREQ (4,7))
421# if __GNUC_PREREQ (2,8)
422# define _Noreturn __attribute__ ((__noreturn__))
423# else
424# define _Noreturn
425# endif
426#endif
427
428#if __GNUC_PREREQ (8, 0)
429/* Describes a char array whose address can safely be passed as the first
430 argument to strncpy and strncat, as the char array is not necessarily
431 a NUL-terminated string. */
432# define __attribute_nonstring__ __attribute__ ((__nonstring__))
433#else
434# define __attribute_nonstring__
435#endif
436
437#if (!defined _Static_assert && !defined __cplusplus \
438 && (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 201112 \
439 && (!__GNUC_PREREQ (4, 6) || defined __STRICT_ANSI__))
440# define _Static_assert(expr, diagnostic) \
441 extern int (*__Static_assert_function (void)) \
442 [!!sizeof (struct { int __error_if_negative: (expr) ? 2 : -1; })]
443#endif
444
445/* The #ifndef lets Gnulib avoid including these on non-glibc
446 platforms, where the includes typically do not exist. */
447#ifndef __WORDSIZE
448# include <bits/wordsize.h>
449# include <bits/long-double.h>
450#endif
451
452#if defined __LONG_DOUBLE_MATH_OPTIONAL && defined __NO_LONG_DOUBLE_MATH
453# define __LDBL_COMPAT 1
454# ifdef __REDIRECT
455# define __LDBL_REDIR1(name, proto, alias) __REDIRECT (name, proto, alias)
456# define __LDBL_REDIR(name, proto) \
457 __LDBL_REDIR1 (name, proto, __nldbl_##name)
458# define __LDBL_REDIR1_NTH(name, proto, alias) __REDIRECT_NTH (name, proto, alias)
459# define __LDBL_REDIR_NTH(name, proto) \
460 __LDBL_REDIR1_NTH (name, proto, __nldbl_##name)
461# define __LDBL_REDIR1_DECL(name, alias) \
462 extern __typeof (name) name __asm (__ASMNAME (#alias));
463# define __LDBL_REDIR_DECL(name) \
464 extern __typeof (name) name __asm (__ASMNAME ("__nldbl_" #name));
465# define __REDIRECT_LDBL(name, proto, alias) \
466 __LDBL_REDIR1 (name, proto, __nldbl_##alias)
467# define __REDIRECT_NTH_LDBL(name, proto, alias) \
468 __LDBL_REDIR1_NTH (name, proto, __nldbl_##alias)
469# endif
470#endif
471#if !defined __LDBL_COMPAT || !defined __REDIRECT
472# define __LDBL_REDIR1(name, proto, alias) name proto
473# define __LDBL_REDIR(name, proto) name proto
474# define __LDBL_REDIR1_NTH(name, proto, alias) name proto __THROW
475# define __LDBL_REDIR_NTH(name, proto) name proto __THROW
476# define __LDBL_REDIR_DECL(name)
477# ifdef __REDIRECT
478# define __REDIRECT_LDBL(name, proto, alias) __REDIRECT (name, proto, alias)
479# define __REDIRECT_NTH_LDBL(name, proto, alias) \
480 __REDIRECT_NTH (name, proto, alias)
481# endif
482#endif
483
484/* __glibc_macro_warning (MESSAGE) issues warning MESSAGE. This is
485 intended for use in preprocessor macros.
486
487 Note: MESSAGE must be a _single_ string; concatenation of string
488 literals is not supported. */
489#if __GNUC_PREREQ (4,8) || __glibc_clang_prereq (3,5)
490# define __glibc_macro_warning1(message) _Pragma (#message)
491# define __glibc_macro_warning(message) \
492 __glibc_macro_warning1 (GCC warning message)
493#else
494# define __glibc_macro_warning(msg)
495#endif
496
497/* Generic selection (ISO C11) is a C-only feature, available in GCC
498 since version 4.9. Previous versions do not provide generic
499 selection, even though they might set __STDC_VERSION__ to 201112L,
500 when in -std=c11 mode. Thus, we must check for !defined __GNUC__
501 when testing __STDC_VERSION__ for generic selection support.
502 On the other hand, Clang also defines __GNUC__, so a clang-specific
503 check is required to enable the use of generic selection. */
504#if !defined __cplusplus \
505 && (__GNUC_PREREQ (4, 9) \
506 || __glibc_clang_has_extension (c_generic_selections) \
507 || (!defined __GNUC__ && defined __STDC_VERSION__ \
508 && __STDC_VERSION__ >= 201112L))
509# define __HAVE_GENERIC_SELECTION 1
510#else
511# define __HAVE_GENERIC_SELECTION 0
512#endif
513
514#endif /* sys/cdefs.h */
diff --git a/lib/gnulib.mk.in b/lib/gnulib.mk.in
index 431d0c0b77b..982d3c5c297 100644
--- a/lib/gnulib.mk.in
+++ b/lib/gnulib.mk.in
@@ -1040,6 +1040,7 @@ gamegroup = @gamegroup@
1040gameuser = @gameuser@ 1040gameuser = @gameuser@
1041gl_GNULIB_ENABLED_03e0aaad4cb89ca757653bd367a6ccb7 = @gl_GNULIB_ENABLED_03e0aaad4cb89ca757653bd367a6ccb7@ 1041gl_GNULIB_ENABLED_03e0aaad4cb89ca757653bd367a6ccb7 = @gl_GNULIB_ENABLED_03e0aaad4cb89ca757653bd367a6ccb7@
1042gl_GNULIB_ENABLED_2049e887c7e5308faad27b3f894bb8c9 = @gl_GNULIB_ENABLED_2049e887c7e5308faad27b3f894bb8c9@ 1042gl_GNULIB_ENABLED_2049e887c7e5308faad27b3f894bb8c9 = @gl_GNULIB_ENABLED_2049e887c7e5308faad27b3f894bb8c9@
1043gl_GNULIB_ENABLED_21ee726a3540c09237a8e70c0baf7467 = @gl_GNULIB_ENABLED_21ee726a3540c09237a8e70c0baf7467@
1043gl_GNULIB_ENABLED_260941c0e5dc67ec9e87d1fb321c300b = @gl_GNULIB_ENABLED_260941c0e5dc67ec9e87d1fb321c300b@ 1044gl_GNULIB_ENABLED_260941c0e5dc67ec9e87d1fb321c300b = @gl_GNULIB_ENABLED_260941c0e5dc67ec9e87d1fb321c300b@
1044gl_GNULIB_ENABLED_37f71b604aa9c54446783d80f42fe547 = @gl_GNULIB_ENABLED_37f71b604aa9c54446783d80f42fe547@ 1045gl_GNULIB_ENABLED_37f71b604aa9c54446783d80f42fe547 = @gl_GNULIB_ENABLED_37f71b604aa9c54446783d80f42fe547@
1045gl_GNULIB_ENABLED_5264294aa0a5557541b53c8c741f7f31 = @gl_GNULIB_ENABLED_5264294aa0a5557541b53c8c741f7f31@ 1046gl_GNULIB_ENABLED_5264294aa0a5557541b53c8c741f7f31 = @gl_GNULIB_ENABLED_5264294aa0a5557541b53c8c741f7f31@
@@ -1900,6 +1901,17 @@ EXTRA_DIST += inttypes.in.h
1900endif 1901endif
1901## end gnulib module inttypes-incomplete 1902## end gnulib module inttypes-incomplete
1902 1903
1904## begin gnulib module libc-config
1905ifeq (,$(OMIT_GNULIB_MODULE_libc-config))
1906
1907ifneq (,$(gl_GNULIB_ENABLED_21ee726a3540c09237a8e70c0baf7467))
1908
1909endif
1910EXTRA_DIST += cdefs.h libc-config.h
1911
1912endif
1913## end gnulib module libc-config
1914
1903## begin gnulib module limits-h 1915## begin gnulib module limits-h
1904ifeq (,$(OMIT_GNULIB_MODULE_limits-h)) 1916ifeq (,$(OMIT_GNULIB_MODULE_limits-h))
1905 1917
diff --git a/lib/libc-config.h b/lib/libc-config.h
new file mode 100644
index 00000000000..d7b40935cd4
--- /dev/null
+++ b/lib/libc-config.h
@@ -0,0 +1,174 @@
1/* System definitions for code taken from the GNU C Library
2
3 Copyright 2017-2018 Free Software Foundation, Inc.
4
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public
7 License as published by the Free Software Foundation; either
8 version 3 of the License, or (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public
16 License along with this program; if not, see
17 <https://www.gnu.org/licenses/>. */
18
19/* Written by Paul Eggert. */
20
21/* This is intended to be a good-enough substitute for glibc system
22 macros like those defined in <sys/cdefs.h>, so that Gnulib code
23 shared with glibc can do this as the first #include:
24
25 #ifndef _LIBC
26 # include <libc-config.h>
27 #endif
28
29 When compiled as part of glibc this is a no-op; when compiled as
30 part of Gnulib this includes Gnulib's <config.h> and defines macros
31 that glibc library code would normally assume. */
32
33#include <config.h>
34
35/* On glibc this includes <features.h> and <sys/cdefs.h> and #defines
36 _FEATURES_H, __WORDSIZE, and __set_errno. On FreeBSD 11 it
37 includes <sys/cdefs.h> which defines __nonnull. Elsewhere it
38 is harmless. */
39#include <errno.h>
40
41/* From glibc <errno.h>. */
42#ifndef __set_errno
43# define __set_errno(val) (errno = (val))
44#endif
45
46/* From glibc <features.h>. */
47
48#ifndef __GNUC_PREREQ
49# if defined __GNUC__ && defined __GNUC_MINOR__
50# define __GNUC_PREREQ(maj, min) ((maj) < __GNUC__ + ((min) <= __GNUC_MINOR__))
51# else
52# define __GNUC_PREREQ(maj, min) 0
53# endif
54#endif
55
56#ifndef __glibc_clang_prereq
57# if defined __clang_major__ && defined __clang_minor__
58# define __glibc_clang_prereq(maj, min) \
59 ((maj) < __clang_major__ + ((min) <= __clang_minor__))
60# else
61# define __glibc_clang_prereq(maj, min) 0
62# endif
63#endif
64
65
66/* Prepare to include <cdefs.h>, which is our copy of glibc
67 <sys/cdefs.h>. */
68
69/* Define _FEATURES_H so that <cdefs.h> does not include <features.h>. */
70#ifndef _FEATURES_H
71# define _FEATURES_H 1
72#endif
73/* Define __WORDSIZE so that <cdefs.h> does not attempt to include
74 nonexistent files. Make it a syntax error, since Gnulib does not
75 use __WORDSIZE now, and if Gnulib uses it later the syntax error
76 will let us know that __WORDSIZE needs configuring. */
77#ifndef __WORDSIZE
78# define __WORDSIZE %%%
79#endif
80/* Undef the macros unconditionally defined by our copy of glibc
81 <sys/cdefs.h>, so that they do not clash with any system-defined
82 versions. */
83#undef _SYS_CDEFS_H
84#undef __ASMNAME
85#undef __ASMNAME2
86#undef __BEGIN_DECLS
87#undef __CONCAT
88#undef __END_DECLS
89#undef __HAVE_GENERIC_SELECTION
90#undef __LDBL_COMPAT
91#undef __LDBL_REDIR
92#undef __LDBL_REDIR1
93#undef __LDBL_REDIR1_DECL
94#undef __LDBL_REDIR1_NTH
95#undef __LDBL_REDIR_DECL
96#undef __LDBL_REDIR_NTH
97#undef __LEAF
98#undef __LEAF_ATTR
99#undef __NTH
100#undef __NTHNL
101#undef __P
102#undef __PMT
103#undef __REDIRECT
104#undef __REDIRECT_LDBL
105#undef __REDIRECT_NTH
106#undef __REDIRECT_NTHNL
107#undef __REDIRECT_NTH_LDBL
108#undef __STRING
109#undef __THROW
110#undef __THROWNL
111#undef __always_inline
112#undef __attribute__
113#undef __attribute_alloc_size__
114#undef __attribute_artificial__
115#undef __attribute_const__
116#undef __attribute_deprecated__
117#undef __attribute_deprecated_msg__
118#undef __attribute_format_arg__
119#undef __attribute_format_strfmon__
120#undef __attribute_malloc__
121#undef __attribute_noinline__
122#undef __attribute_nonstring__
123#undef __attribute_pure__
124#undef __attribute_used__
125#undef __attribute_warn_unused_result__
126#undef __bos
127#undef __bos0
128#undef __errordecl
129#undef __extension__
130#undef __extern_always_inline
131#undef __extern_inline
132#undef __flexarr
133#undef __fortify_function
134#undef __glibc_c99_flexarr_available
135#undef __glibc_clang_has_extension
136#undef __glibc_likely
137#undef __glibc_macro_warning
138#undef __glibc_macro_warning1
139#undef __glibc_unlikely
140#undef __inline
141#undef __ptr_t
142#undef __restrict
143#undef __restrict_arr
144#undef __va_arg_pack
145#undef __va_arg_pack_len
146#undef __warnattr
147#undef __warndecl
148
149/* Include our copy of glibc <sys/cdefs.h>. */
150#include <cdefs.h>
151
152/* <cdefs.h> __inline is too pessimistic for non-GCC. */
153#undef __inline
154#ifndef HAVE___INLINE
155# if 199901 <= __STDC_VERSION__ || defined inline
156# define __inline inline
157# else
158# define __inline
159# endif
160#endif
161
162
163/* A substitute for glibc <libc-symbols.h>, good enough for Gnulib. */
164#define attribute_hidden
165#define libc_hidden_proto(name, ...)
166#define libc_hidden_def(name)
167#define libc_hidden_weak(name)
168#define libc_hidden_ver(local, name)
169#define strong_alias(name, aliasname)
170#define weak_alias(name, aliasname)
171
172/* A substitute for glibc <shlib-compat.h>, good enough for Gnulib. */
173#define SHLIB_COMPAT(lib, introduced, obsoleted) 0
174#define versioned_symbol(lib, local, symbol, version)
diff --git a/lib/regcomp.c b/lib/regcomp.c
index 0e4816c89c2..0b05a63b632 100644
--- a/lib/regcomp.c
+++ b/lib/regcomp.c
@@ -476,7 +476,7 @@ regcomp (regex_t *_Restrict_ preg, const char *_Restrict_ pattern, int cflags)
476 476
477 /* Try to allocate space for the fastmap. */ 477 /* Try to allocate space for the fastmap. */
478 preg->fastmap = re_malloc (char, SBC_MAX); 478 preg->fastmap = re_malloc (char, SBC_MAX);
479 if (BE (preg->fastmap == NULL, 0)) 479 if (__glibc_unlikely (preg->fastmap == NULL))
480 return REG_ESPACE; 480 return REG_ESPACE;
481 481
482 syntax |= (cflags & REG_ICASE) ? RE_ICASE : 0; 482 syntax |= (cflags & REG_ICASE) ? RE_ICASE : 0;
@@ -502,7 +502,7 @@ regcomp (regex_t *_Restrict_ preg, const char *_Restrict_ pattern, int cflags)
502 ret = REG_EPAREN; 502 ret = REG_EPAREN;
503 503
504 /* We have already checked preg->fastmap != NULL. */ 504 /* We have already checked preg->fastmap != NULL. */
505 if (BE (ret == REG_NOERROR, 1)) 505 if (__glibc_likely (ret == REG_NOERROR))
506 /* Compute the fastmap now, since regexec cannot modify the pattern 506 /* Compute the fastmap now, since regexec cannot modify the pattern
507 buffer. This function never fails in this implementation. */ 507 buffer. This function never fails in this implementation. */
508 (void) re_compile_fastmap (preg); 508 (void) re_compile_fastmap (preg);
@@ -529,10 +529,9 @@ regerror (int errcode, const regex_t *_Restrict_ preg, char *_Restrict_ errbuf,
529{ 529{
530 const char *msg; 530 const char *msg;
531 size_t msg_size; 531 size_t msg_size;
532 int nerrcodes = sizeof __re_error_msgid_idx / sizeof __re_error_msgid_idx[0];
532 533
533 if (BE (errcode < 0 534 if (__glibc_unlikely (errcode < 0 || errcode >= nerrcodes))
534 || errcode >= (int) (sizeof (__re_error_msgid_idx)
535 / sizeof (__re_error_msgid_idx[0])), 0))
536 /* Only error codes returned by the rest of the code should be passed 535 /* Only error codes returned by the rest of the code should be passed
537 to this routine. If we are given anything else, or if other regex 536 to this routine. If we are given anything else, or if other regex
538 code generates an invalid error code, then the program has a bug. 537 code generates an invalid error code, then the program has a bug.
@@ -543,10 +542,10 @@ regerror (int errcode, const regex_t *_Restrict_ preg, char *_Restrict_ errbuf,
543 542
544 msg_size = strlen (msg) + 1; /* Includes the null. */ 543 msg_size = strlen (msg) + 1; /* Includes the null. */
545 544
546 if (BE (errbuf_size != 0, 1)) 545 if (__glibc_likely (errbuf_size != 0))
547 { 546 {
548 size_t cpy_size = msg_size; 547 size_t cpy_size = msg_size;
549 if (BE (msg_size > errbuf_size, 0)) 548 if (__glibc_unlikely (msg_size > errbuf_size))
550 { 549 {
551 cpy_size = errbuf_size - 1; 550 cpy_size = errbuf_size - 1;
552 errbuf[cpy_size] = '\0'; 551 errbuf[cpy_size] = '\0';
@@ -644,7 +643,7 @@ void
644regfree (regex_t *preg) 643regfree (regex_t *preg)
645{ 644{
646 re_dfa_t *dfa = preg->buffer; 645 re_dfa_t *dfa = preg->buffer;
647 if (BE (dfa != NULL, 1)) 646 if (__glibc_likely (dfa != NULL))
648 { 647 {
649 lock_fini (dfa->lock); 648 lock_fini (dfa->lock);
650 free_dfa_content (dfa); 649 free_dfa_content (dfa);
@@ -754,7 +753,7 @@ re_compile_internal (regex_t *preg, const char * pattern, size_t length,
754 753
755 /* Initialize the dfa. */ 754 /* Initialize the dfa. */
756 dfa = preg->buffer; 755 dfa = preg->buffer;
757 if (BE (preg->allocated < sizeof (re_dfa_t), 0)) 756 if (__glibc_unlikely (preg->allocated < sizeof (re_dfa_t)))
758 { 757 {
759 /* If zero allocated, but buffer is non-null, try to realloc 758 /* If zero allocated, but buffer is non-null, try to realloc
760 enough space. This loses if buffer's address is bogus, but 759 enough space. This loses if buffer's address is bogus, but
@@ -769,9 +768,9 @@ re_compile_internal (regex_t *preg, const char * pattern, size_t length,
769 preg->used = sizeof (re_dfa_t); 768 preg->used = sizeof (re_dfa_t);
770 769
771 err = init_dfa (dfa, length); 770 err = init_dfa (dfa, length);
772 if (BE (err == REG_NOERROR && lock_init (dfa->lock) != 0, 0)) 771 if (__glibc_unlikely (err == REG_NOERROR && lock_init (dfa->lock) != 0))
773 err = REG_ESPACE; 772 err = REG_ESPACE;
774 if (BE (err != REG_NOERROR, 0)) 773 if (__glibc_unlikely (err != REG_NOERROR))
775 { 774 {
776 free_dfa_content (dfa); 775 free_dfa_content (dfa);
777 preg->buffer = NULL; 776 preg->buffer = NULL;
@@ -786,7 +785,7 @@ re_compile_internal (regex_t *preg, const char * pattern, size_t length,
786 785
787 err = re_string_construct (&regexp, pattern, length, preg->translate, 786 err = re_string_construct (&regexp, pattern, length, preg->translate,
788 (syntax & RE_ICASE) != 0, dfa); 787 (syntax & RE_ICASE) != 0, dfa);
789 if (BE (err != REG_NOERROR, 0)) 788 if (__glibc_unlikely (err != REG_NOERROR))
790 { 789 {
791 re_compile_internal_free_return: 790 re_compile_internal_free_return:
792 free_workarea_compile (preg); 791 free_workarea_compile (preg);
@@ -801,12 +800,12 @@ re_compile_internal (regex_t *preg, const char * pattern, size_t length,
801 /* Parse the regular expression, and build a structure tree. */ 800 /* Parse the regular expression, and build a structure tree. */
802 preg->re_nsub = 0; 801 preg->re_nsub = 0;
803 dfa->str_tree = parse (&regexp, preg, syntax, &err); 802 dfa->str_tree = parse (&regexp, preg, syntax, &err);
804 if (BE (dfa->str_tree == NULL, 0)) 803 if (__glibc_unlikely (dfa->str_tree == NULL))
805 goto re_compile_internal_free_return; 804 goto re_compile_internal_free_return;
806 805
807 /* Analyze the tree and create the nfa. */ 806 /* Analyze the tree and create the nfa. */
808 err = analyze (preg); 807 err = analyze (preg);
809 if (BE (err != REG_NOERROR, 0)) 808 if (__glibc_unlikely (err != REG_NOERROR))
810 goto re_compile_internal_free_return; 809 goto re_compile_internal_free_return;
811 810
812#ifdef RE_ENABLE_I18N 811#ifdef RE_ENABLE_I18N
@@ -822,7 +821,7 @@ re_compile_internal (regex_t *preg, const char * pattern, size_t length,
822 free_workarea_compile (preg); 821 free_workarea_compile (preg);
823 re_string_destruct (&regexp); 822 re_string_destruct (&regexp);
824 823
825 if (BE (err != REG_NOERROR, 0)) 824 if (__glibc_unlikely (err != REG_NOERROR))
826 { 825 {
827 lock_fini (dfa->lock); 826 lock_fini (dfa->lock);
828 free_dfa_content (dfa); 827 free_dfa_content (dfa);
@@ -864,7 +863,8 @@ init_dfa (re_dfa_t *dfa, size_t pat_len)
864 calculation below, and for similar doubling calculations 863 calculation below, and for similar doubling calculations
865 elsewhere. And it's <= rather than <, because some of the 864 elsewhere. And it's <= rather than <, because some of the
866 doubling calculations add 1 afterwards. */ 865 doubling calculations add 1 afterwards. */
867 if (BE (MIN (IDX_MAX, SIZE_MAX / max_object_size) / 2 <= pat_len, 0)) 866 if (__glibc_unlikely (MIN (IDX_MAX, SIZE_MAX / max_object_size) / 2
867 <= pat_len))
868 return REG_ESPACE; 868 return REG_ESPACE;
869 869
870 dfa->nodes_alloc = pat_len + 1; 870 dfa->nodes_alloc = pat_len + 1;
@@ -908,7 +908,7 @@ init_dfa (re_dfa_t *dfa, size_t pat_len)
908 int i, j, ch; 908 int i, j, ch;
909 909
910 dfa->sb_char = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1); 910 dfa->sb_char = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1);
911 if (BE (dfa->sb_char == NULL, 0)) 911 if (__glibc_unlikely (dfa->sb_char == NULL))
912 return REG_ESPACE; 912 return REG_ESPACE;
913 913
914 /* Set the bits corresponding to single byte chars. */ 914 /* Set the bits corresponding to single byte chars. */
@@ -927,7 +927,7 @@ init_dfa (re_dfa_t *dfa, size_t pat_len)
927 } 927 }
928#endif 928#endif
929 929
930 if (BE (dfa->nodes == NULL || dfa->state_table == NULL, 0)) 930 if (__glibc_unlikely (dfa->nodes == NULL || dfa->state_table == NULL))
931 return REG_ESPACE; 931 return REG_ESPACE;
932 return REG_NOERROR; 932 return REG_NOERROR;
933} 933}
@@ -943,7 +943,7 @@ init_word_char (re_dfa_t *dfa)
943 int j; 943 int j;
944 int ch = 0; 944 int ch = 0;
945 dfa->word_ops_used = 1; 945 dfa->word_ops_used = 1;
946 if (BE (dfa->map_notascii == 0, 1)) 946 if (__glibc_likely (dfa->map_notascii == 0))
947 { 947 {
948 /* Avoid uint32_t and uint64_t as some non-GCC platforms lack 948 /* Avoid uint32_t and uint64_t as some non-GCC platforms lack
949 them, an issue when this code is used in Gnulib. */ 949 them, an issue when this code is used in Gnulib. */
@@ -970,7 +970,7 @@ init_word_char (re_dfa_t *dfa)
970 goto general_case; 970 goto general_case;
971 ch = 128; 971 ch = 128;
972 972
973 if (BE (dfa->is_utf8, 1)) 973 if (__glibc_likely (dfa->is_utf8))
974 { 974 {
975 memset (&dfa->word_char[i], '\0', (SBC_MAX - ch) / 8); 975 memset (&dfa->word_char[i], '\0', (SBC_MAX - ch) / 8);
976 return; 976 return;
@@ -1017,7 +1017,7 @@ create_initial_state (re_dfa_t *dfa)
1017 first = dfa->str_tree->first->node_idx; 1017 first = dfa->str_tree->first->node_idx;
1018 dfa->init_node = first; 1018 dfa->init_node = first;
1019 err = re_node_set_init_copy (&init_nodes, dfa->eclosures + first); 1019 err = re_node_set_init_copy (&init_nodes, dfa->eclosures + first);
1020 if (BE (err != REG_NOERROR, 0)) 1020 if (__glibc_unlikely (err != REG_NOERROR))
1021 return err; 1021 return err;
1022 1022
1023 /* The back-references which are in initial states can epsilon transit, 1023 /* The back-references which are in initial states can epsilon transit,
@@ -1061,7 +1061,7 @@ create_initial_state (re_dfa_t *dfa)
1061 /* It must be the first time to invoke acquire_state. */ 1061 /* It must be the first time to invoke acquire_state. */
1062 dfa->init_state = re_acquire_state_context (&err, dfa, &init_nodes, 0); 1062 dfa->init_state = re_acquire_state_context (&err, dfa, &init_nodes, 0);
1063 /* We don't check ERR here, since the initial state must not be NULL. */ 1063 /* We don't check ERR here, since the initial state must not be NULL. */
1064 if (BE (dfa->init_state == NULL, 0)) 1064 if (__glibc_unlikely (dfa->init_state == NULL))
1065 return err; 1065 return err;
1066 if (dfa->init_state->has_constraint) 1066 if (dfa->init_state->has_constraint)
1067 { 1067 {
@@ -1073,8 +1073,9 @@ create_initial_state (re_dfa_t *dfa)
1073 &init_nodes, 1073 &init_nodes,
1074 CONTEXT_NEWLINE 1074 CONTEXT_NEWLINE
1075 | CONTEXT_BEGBUF); 1075 | CONTEXT_BEGBUF);
1076 if (BE (dfa->init_state_word == NULL || dfa->init_state_nl == NULL 1076 if (__glibc_unlikely (dfa->init_state_word == NULL
1077 || dfa->init_state_begbuf == NULL, 0)) 1077 || dfa->init_state_nl == NULL
1078 || dfa->init_state_begbuf == NULL))
1078 return err; 1079 return err;
1079 } 1080 }
1080 else 1081 else
@@ -1181,8 +1182,8 @@ analyze (regex_t *preg)
1181 dfa->org_indices = re_malloc (Idx, dfa->nodes_alloc); 1182 dfa->org_indices = re_malloc (Idx, dfa->nodes_alloc);
1182 dfa->edests = re_malloc (re_node_set, dfa->nodes_alloc); 1183 dfa->edests = re_malloc (re_node_set, dfa->nodes_alloc);
1183 dfa->eclosures = re_malloc (re_node_set, dfa->nodes_alloc); 1184 dfa->eclosures = re_malloc (re_node_set, dfa->nodes_alloc);
1184 if (BE (dfa->nexts == NULL || dfa->org_indices == NULL || dfa->edests == NULL 1185 if (__glibc_unlikely (dfa->nexts == NULL || dfa->org_indices == NULL
1185 || dfa->eclosures == NULL, 0)) 1186 || dfa->edests == NULL || dfa->eclosures == NULL))
1186 return REG_ESPACE; 1187 return REG_ESPACE;
1187 1188
1188 dfa->subexp_map = re_malloc (Idx, preg->re_nsub); 1189 dfa->subexp_map = re_malloc (Idx, preg->re_nsub);
@@ -1203,17 +1204,17 @@ analyze (regex_t *preg)
1203 } 1204 }
1204 1205
1205 ret = postorder (dfa->str_tree, lower_subexps, preg); 1206 ret = postorder (dfa->str_tree, lower_subexps, preg);
1206 if (BE (ret != REG_NOERROR, 0)) 1207 if (__glibc_unlikely (ret != REG_NOERROR))
1207 return ret; 1208 return ret;
1208 ret = postorder (dfa->str_tree, calc_first, dfa); 1209 ret = postorder (dfa->str_tree, calc_first, dfa);
1209 if (BE (ret != REG_NOERROR, 0)) 1210 if (__glibc_unlikely (ret != REG_NOERROR))
1210 return ret; 1211 return ret;
1211 preorder (dfa->str_tree, calc_next, dfa); 1212 preorder (dfa->str_tree, calc_next, dfa);
1212 ret = preorder (dfa->str_tree, link_nfa_nodes, dfa); 1213 ret = preorder (dfa->str_tree, link_nfa_nodes, dfa);
1213 if (BE (ret != REG_NOERROR, 0)) 1214 if (__glibc_unlikely (ret != REG_NOERROR))
1214 return ret; 1215 return ret;
1215 ret = calc_eclosure (dfa); 1216 ret = calc_eclosure (dfa);
1216 if (BE (ret != REG_NOERROR, 0)) 1217 if (__glibc_unlikely (ret != REG_NOERROR))
1217 return ret; 1218 return ret;
1218 1219
1219 /* We only need this during the prune_impossible_nodes pass in regexec.c; 1220 /* We only need this during the prune_impossible_nodes pass in regexec.c;
@@ -1222,7 +1223,7 @@ analyze (regex_t *preg)
1222 || dfa->nbackref) 1223 || dfa->nbackref)
1223 { 1224 {
1224 dfa->inveclosures = re_malloc (re_node_set, dfa->nodes_len); 1225 dfa->inveclosures = re_malloc (re_node_set, dfa->nodes_len);
1225 if (BE (dfa->inveclosures == NULL, 0)) 1226 if (__glibc_unlikely (dfa->inveclosures == NULL))
1226 return REG_ESPACE; 1227 return REG_ESPACE;
1227 ret = calc_inveclosure (dfa); 1228 ret = calc_inveclosure (dfa);
1228 } 1229 }
@@ -1252,7 +1253,7 @@ postorder (bin_tree_t *root, reg_errcode_t (fn (void *, bin_tree_t *)),
1252 do 1253 do
1253 { 1254 {
1254 reg_errcode_t err = fn (extra, node); 1255 reg_errcode_t err = fn (extra, node);
1255 if (BE (err != REG_NOERROR, 0)) 1256 if (__glibc_unlikely (err != REG_NOERROR))
1256 return err; 1257 return err;
1257 if (node->parent == NULL) 1258 if (node->parent == NULL)
1258 return REG_NOERROR; 1259 return REG_NOERROR;
@@ -1274,7 +1275,7 @@ preorder (bin_tree_t *root, reg_errcode_t (fn (void *, bin_tree_t *)),
1274 for (node = root; ; ) 1275 for (node = root; ; )
1275 { 1276 {
1276 reg_errcode_t err = fn (extra, node); 1277 reg_errcode_t err = fn (extra, node);
1277 if (BE (err != REG_NOERROR, 0)) 1278 if (__glibc_unlikely (err != REG_NOERROR))
1278 return err; 1279 return err;
1279 1280
1280 /* Go to the left node, or up and to the right. */ 1281 /* Go to the left node, or up and to the right. */
@@ -1375,7 +1376,8 @@ lower_subexp (reg_errcode_t *err, regex_t *preg, bin_tree_t *node)
1375 cls = create_tree (dfa, NULL, NULL, OP_CLOSE_SUBEXP); 1376 cls = create_tree (dfa, NULL, NULL, OP_CLOSE_SUBEXP);
1376 tree1 = body ? create_tree (dfa, body, cls, CONCAT) : cls; 1377 tree1 = body ? create_tree (dfa, body, cls, CONCAT) : cls;
1377 tree = create_tree (dfa, op, tree1, CONCAT); 1378 tree = create_tree (dfa, op, tree1, CONCAT);
1378 if (BE (tree == NULL || tree1 == NULL || op == NULL || cls == NULL, 0)) 1379 if (__glibc_unlikely (tree == NULL || tree1 == NULL
1380 || op == NULL || cls == NULL))
1379 { 1381 {
1380 *err = REG_ESPACE; 1382 *err = REG_ESPACE;
1381 return NULL; 1383 return NULL;
@@ -1401,7 +1403,7 @@ calc_first (void *extra, bin_tree_t *node)
1401 { 1403 {
1402 node->first = node; 1404 node->first = node;
1403 node->node_idx = re_dfa_add_node (dfa, node->token); 1405 node->node_idx = re_dfa_add_node (dfa, node->token);
1404 if (BE (node->node_idx == -1, 0)) 1406 if (__glibc_unlikely (node->node_idx == -1))
1405 return REG_ESPACE; 1407 return REG_ESPACE;
1406 if (node->token.type == ANCHOR) 1408 if (node->token.type == ANCHOR)
1407 dfa->nodes[node->node_idx].constraint = node->token.opr.ctx_type; 1409 dfa->nodes[node->node_idx].constraint = node->token.opr.ctx_type;
@@ -1512,11 +1514,11 @@ duplicate_node_closure (re_dfa_t *dfa, Idx top_org_node, Idx top_clone_node,
1512 org_dest = dfa->nexts[org_node]; 1514 org_dest = dfa->nexts[org_node];
1513 re_node_set_empty (dfa->edests + clone_node); 1515 re_node_set_empty (dfa->edests + clone_node);
1514 clone_dest = duplicate_node (dfa, org_dest, constraint); 1516 clone_dest = duplicate_node (dfa, org_dest, constraint);
1515 if (BE (clone_dest == -1, 0)) 1517 if (__glibc_unlikely (clone_dest == -1))
1516 return REG_ESPACE; 1518 return REG_ESPACE;
1517 dfa->nexts[clone_node] = dfa->nexts[org_node]; 1519 dfa->nexts[clone_node] = dfa->nexts[org_node];
1518 ok = re_node_set_insert (dfa->edests + clone_node, clone_dest); 1520 ok = re_node_set_insert (dfa->edests + clone_node, clone_dest);
1519 if (BE (! ok, 0)) 1521 if (__glibc_unlikely (! ok))
1520 return REG_ESPACE; 1522 return REG_ESPACE;
1521 } 1523 }
1522 else if (dfa->edests[org_node].nelem == 0) 1524 else if (dfa->edests[org_node].nelem == 0)
@@ -1538,17 +1540,17 @@ duplicate_node_closure (re_dfa_t *dfa, Idx top_org_node, Idx top_clone_node,
1538 if (org_node == root_node && clone_node != org_node) 1540 if (org_node == root_node && clone_node != org_node)
1539 { 1541 {
1540 ok = re_node_set_insert (dfa->edests + clone_node, org_dest); 1542 ok = re_node_set_insert (dfa->edests + clone_node, org_dest);
1541 if (BE (! ok, 0)) 1543 if (__glibc_unlikely (! ok))
1542 return REG_ESPACE; 1544 return REG_ESPACE;
1543 break; 1545 break;
1544 } 1546 }
1545 /* In case the node has another constraint, append it. */ 1547 /* In case the node has another constraint, append it. */
1546 constraint |= dfa->nodes[org_node].constraint; 1548 constraint |= dfa->nodes[org_node].constraint;
1547 clone_dest = duplicate_node (dfa, org_dest, constraint); 1549 clone_dest = duplicate_node (dfa, org_dest, constraint);
1548 if (BE (clone_dest == -1, 0)) 1550 if (__glibc_unlikely (clone_dest == -1))
1549 return REG_ESPACE; 1551 return REG_ESPACE;
1550 ok = re_node_set_insert (dfa->edests + clone_node, clone_dest); 1552 ok = re_node_set_insert (dfa->edests + clone_node, clone_dest);
1551 if (BE (! ok, 0)) 1553 if (__glibc_unlikely (! ok))
1552 return REG_ESPACE; 1554 return REG_ESPACE;
1553 } 1555 }
1554 else /* dfa->edests[org_node].nelem == 2 */ 1556 else /* dfa->edests[org_node].nelem == 2 */
@@ -1564,14 +1566,14 @@ duplicate_node_closure (re_dfa_t *dfa, Idx top_org_node, Idx top_clone_node,
1564 /* There is no such duplicated node, create a new one. */ 1566 /* There is no such duplicated node, create a new one. */
1565 reg_errcode_t err; 1567 reg_errcode_t err;
1566 clone_dest = duplicate_node (dfa, org_dest, constraint); 1568 clone_dest = duplicate_node (dfa, org_dest, constraint);
1567 if (BE (clone_dest == -1, 0)) 1569 if (__glibc_unlikely (clone_dest == -1))
1568 return REG_ESPACE; 1570 return REG_ESPACE;
1569 ok = re_node_set_insert (dfa->edests + clone_node, clone_dest); 1571 ok = re_node_set_insert (dfa->edests + clone_node, clone_dest);
1570 if (BE (! ok, 0)) 1572 if (__glibc_unlikely (! ok))
1571 return REG_ESPACE; 1573 return REG_ESPACE;
1572 err = duplicate_node_closure (dfa, org_dest, clone_dest, 1574 err = duplicate_node_closure (dfa, org_dest, clone_dest,
1573 root_node, constraint); 1575 root_node, constraint);
1574 if (BE (err != REG_NOERROR, 0)) 1576 if (__glibc_unlikely (err != REG_NOERROR))
1575 return err; 1577 return err;
1576 } 1578 }
1577 else 1579 else
@@ -1579,16 +1581,16 @@ duplicate_node_closure (re_dfa_t *dfa, Idx top_org_node, Idx top_clone_node,
1579 /* There is a duplicated node which satisfies the constraint, 1581 /* There is a duplicated node which satisfies the constraint,
1580 use it to avoid infinite loop. */ 1582 use it to avoid infinite loop. */
1581 ok = re_node_set_insert (dfa->edests + clone_node, clone_dest); 1583 ok = re_node_set_insert (dfa->edests + clone_node, clone_dest);
1582 if (BE (! ok, 0)) 1584 if (__glibc_unlikely (! ok))
1583 return REG_ESPACE; 1585 return REG_ESPACE;
1584 } 1586 }
1585 1587
1586 org_dest = dfa->edests[org_node].elems[1]; 1588 org_dest = dfa->edests[org_node].elems[1];
1587 clone_dest = duplicate_node (dfa, org_dest, constraint); 1589 clone_dest = duplicate_node (dfa, org_dest, constraint);
1588 if (BE (clone_dest == -1, 0)) 1590 if (__glibc_unlikely (clone_dest == -1))
1589 return REG_ESPACE; 1591 return REG_ESPACE;
1590 ok = re_node_set_insert (dfa->edests + clone_node, clone_dest); 1592 ok = re_node_set_insert (dfa->edests + clone_node, clone_dest);
1591 if (BE (! ok, 0)) 1593 if (__glibc_unlikely (! ok))
1592 return REG_ESPACE; 1594 return REG_ESPACE;
1593 } 1595 }
1594 org_node = org_dest; 1596 org_node = org_dest;
@@ -1622,7 +1624,7 @@ static Idx
1622duplicate_node (re_dfa_t *dfa, Idx org_idx, unsigned int constraint) 1624duplicate_node (re_dfa_t *dfa, Idx org_idx, unsigned int constraint)
1623{ 1625{
1624 Idx dup_idx = re_dfa_add_node (dfa, dfa->nodes[org_idx]); 1626 Idx dup_idx = re_dfa_add_node (dfa, dfa->nodes[org_idx]);
1625 if (BE (dup_idx != -1, 1)) 1627 if (__glibc_likely (dup_idx != -1))
1626 { 1628 {
1627 dfa->nodes[dup_idx].constraint = constraint; 1629 dfa->nodes[dup_idx].constraint = constraint;
1628 dfa->nodes[dup_idx].constraint |= dfa->nodes[org_idx].constraint; 1630 dfa->nodes[dup_idx].constraint |= dfa->nodes[org_idx].constraint;
@@ -1648,7 +1650,7 @@ calc_inveclosure (re_dfa_t *dfa)
1648 for (idx = 0; idx < dfa->eclosures[src].nelem; ++idx) 1650 for (idx = 0; idx < dfa->eclosures[src].nelem; ++idx)
1649 { 1651 {
1650 ok = re_node_set_insert_last (dfa->inveclosures + elems[idx], src); 1652 ok = re_node_set_insert_last (dfa->inveclosures + elems[idx], src);
1651 if (BE (! ok, 0)) 1653 if (__glibc_unlikely (! ok))
1652 return REG_ESPACE; 1654 return REG_ESPACE;
1653 } 1655 }
1654 } 1656 }
@@ -1689,7 +1691,7 @@ calc_eclosure (re_dfa_t *dfa)
1689 continue; 1691 continue;
1690 /* Calculate epsilon closure of 'node_idx'. */ 1692 /* Calculate epsilon closure of 'node_idx'. */
1691 err = calc_eclosure_iter (&eclosure_elem, dfa, node_idx, true); 1693 err = calc_eclosure_iter (&eclosure_elem, dfa, node_idx, true);
1692 if (BE (err != REG_NOERROR, 0)) 1694 if (__glibc_unlikely (err != REG_NOERROR))
1693 return err; 1695 return err;
1694 1696
1695 if (dfa->eclosures[node_idx].nelem == 0) 1697 if (dfa->eclosures[node_idx].nelem == 0)
@@ -1712,7 +1714,7 @@ calc_eclosure_iter (re_node_set *new_set, re_dfa_t *dfa, Idx node, bool root)
1712 bool ok; 1714 bool ok;
1713 bool incomplete = false; 1715 bool incomplete = false;
1714 err = re_node_set_alloc (&eclosure, dfa->edests[node].nelem + 1); 1716 err = re_node_set_alloc (&eclosure, dfa->edests[node].nelem + 1);
1715 if (BE (err != REG_NOERROR, 0)) 1717 if (__glibc_unlikely (err != REG_NOERROR))
1716 return err; 1718 return err;
1717 1719
1718 /* This indicates that we are calculating this node now. 1720 /* This indicates that we are calculating this node now.
@@ -1727,7 +1729,7 @@ calc_eclosure_iter (re_node_set *new_set, re_dfa_t *dfa, Idx node, bool root)
1727 { 1729 {
1728 err = duplicate_node_closure (dfa, node, node, node, 1730 err = duplicate_node_closure (dfa, node, node, node,
1729 dfa->nodes[node].constraint); 1731 dfa->nodes[node].constraint);
1730 if (BE (err != REG_NOERROR, 0)) 1732 if (__glibc_unlikely (err != REG_NOERROR))
1731 return err; 1733 return err;
1732 } 1734 }
1733 1735
@@ -1749,14 +1751,14 @@ calc_eclosure_iter (re_node_set *new_set, re_dfa_t *dfa, Idx node, bool root)
1749 if (dfa->eclosures[edest].nelem == 0) 1751 if (dfa->eclosures[edest].nelem == 0)
1750 { 1752 {
1751 err = calc_eclosure_iter (&eclosure_elem, dfa, edest, false); 1753 err = calc_eclosure_iter (&eclosure_elem, dfa, edest, false);
1752 if (BE (err != REG_NOERROR, 0)) 1754 if (__glibc_unlikely (err != REG_NOERROR))
1753 return err; 1755 return err;
1754 } 1756 }
1755 else 1757 else
1756 eclosure_elem = dfa->eclosures[edest]; 1758 eclosure_elem = dfa->eclosures[edest];
1757 /* Merge the epsilon closure of 'edest'. */ 1759 /* Merge the epsilon closure of 'edest'. */
1758 err = re_node_set_merge (&eclosure, &eclosure_elem); 1760 err = re_node_set_merge (&eclosure, &eclosure_elem);
1759 if (BE (err != REG_NOERROR, 0)) 1761 if (__glibc_unlikely (err != REG_NOERROR))
1760 return err; 1762 return err;
1761 /* If the epsilon closure of 'edest' is incomplete, 1763 /* If the epsilon closure of 'edest' is incomplete,
1762 the epsilon closure of this node is also incomplete. */ 1764 the epsilon closure of this node is also incomplete. */
@@ -1769,7 +1771,7 @@ calc_eclosure_iter (re_node_set *new_set, re_dfa_t *dfa, Idx node, bool root)
1769 1771
1770 /* An epsilon closure includes itself. */ 1772 /* An epsilon closure includes itself. */
1771 ok = re_node_set_insert (&eclosure, node); 1773 ok = re_node_set_insert (&eclosure, node);
1772 if (BE (! ok, 0)) 1774 if (__glibc_unlikely (! ok))
1773 return REG_ESPACE; 1775 return REG_ESPACE;
1774 if (incomplete && !root) 1776 if (incomplete && !root)
1775 dfa->eclosures[node].nelem = 0; 1777 dfa->eclosures[node].nelem = 0;
@@ -2139,14 +2141,14 @@ parse (re_string_t *regexp, regex_t *preg, reg_syntax_t syntax,
2139 dfa->syntax = syntax; 2141 dfa->syntax = syntax;
2140 fetch_token (&current_token, regexp, syntax | RE_CARET_ANCHORS_HERE); 2142 fetch_token (&current_token, regexp, syntax | RE_CARET_ANCHORS_HERE);
2141 tree = parse_reg_exp (regexp, preg, &current_token, syntax, 0, err); 2143 tree = parse_reg_exp (regexp, preg, &current_token, syntax, 0, err);
2142 if (BE (*err != REG_NOERROR && tree == NULL, 0)) 2144 if (__glibc_unlikely (*err != REG_NOERROR && tree == NULL))
2143 return NULL; 2145 return NULL;
2144 eor = create_tree (dfa, NULL, NULL, END_OF_RE); 2146 eor = create_tree (dfa, NULL, NULL, END_OF_RE);
2145 if (tree != NULL) 2147 if (tree != NULL)
2146 root = create_tree (dfa, tree, eor, CONCAT); 2148 root = create_tree (dfa, tree, eor, CONCAT);
2147 else 2149 else
2148 root = eor; 2150 root = eor;
2149 if (BE (eor == NULL || root == NULL, 0)) 2151 if (__glibc_unlikely (eor == NULL || root == NULL))
2150 { 2152 {
2151 *err = REG_ESPACE; 2153 *err = REG_ESPACE;
2152 return NULL; 2154 return NULL;
@@ -2171,7 +2173,7 @@ parse_reg_exp (re_string_t *regexp, regex_t *preg, re_token_t *token,
2171 bin_tree_t *tree, *branch = NULL; 2173 bin_tree_t *tree, *branch = NULL;
2172 bitset_word_t initial_bkref_map = dfa->completed_bkref_map; 2174 bitset_word_t initial_bkref_map = dfa->completed_bkref_map;
2173 tree = parse_branch (regexp, preg, token, syntax, nest, err); 2175 tree = parse_branch (regexp, preg, token, syntax, nest, err);
2174 if (BE (*err != REG_NOERROR && tree == NULL, 0)) 2176 if (__glibc_unlikely (*err != REG_NOERROR && tree == NULL))
2175 return NULL; 2177 return NULL;
2176 2178
2177 while (token->type == OP_ALT) 2179 while (token->type == OP_ALT)
@@ -2183,7 +2185,7 @@ parse_reg_exp (re_string_t *regexp, regex_t *preg, re_token_t *token,
2183 bitset_word_t accumulated_bkref_map = dfa->completed_bkref_map; 2185 bitset_word_t accumulated_bkref_map = dfa->completed_bkref_map;
2184 dfa->completed_bkref_map = initial_bkref_map; 2186 dfa->completed_bkref_map = initial_bkref_map;
2185 branch = parse_branch (regexp, preg, token, syntax, nest, err); 2187 branch = parse_branch (regexp, preg, token, syntax, nest, err);
2186 if (BE (*err != REG_NOERROR && branch == NULL, 0)) 2188 if (__glibc_unlikely (*err != REG_NOERROR && branch == NULL))
2187 { 2189 {
2188 if (tree != NULL) 2190 if (tree != NULL)
2189 postorder (tree, free_tree, NULL); 2191 postorder (tree, free_tree, NULL);
@@ -2194,7 +2196,7 @@ parse_reg_exp (re_string_t *regexp, regex_t *preg, re_token_t *token,
2194 else 2196 else
2195 branch = NULL; 2197 branch = NULL;
2196 tree = create_tree (dfa, tree, branch, OP_ALT); 2198 tree = create_tree (dfa, tree, branch, OP_ALT);
2197 if (BE (tree == NULL, 0)) 2199 if (__glibc_unlikely (tree == NULL))
2198 { 2200 {
2199 *err = REG_ESPACE; 2201 *err = REG_ESPACE;
2200 return NULL; 2202 return NULL;
@@ -2219,14 +2221,14 @@ parse_branch (re_string_t *regexp, regex_t *preg, re_token_t *token,
2219 bin_tree_t *tree, *expr; 2221 bin_tree_t *tree, *expr;
2220 re_dfa_t *dfa = preg->buffer; 2222 re_dfa_t *dfa = preg->buffer;
2221 tree = parse_expression (regexp, preg, token, syntax, nest, err); 2223 tree = parse_expression (regexp, preg, token, syntax, nest, err);
2222 if (BE (*err != REG_NOERROR && tree == NULL, 0)) 2224 if (__glibc_unlikely (*err != REG_NOERROR && tree == NULL))
2223 return NULL; 2225 return NULL;
2224 2226
2225 while (token->type != OP_ALT && token->type != END_OF_RE 2227 while (token->type != OP_ALT && token->type != END_OF_RE
2226 && (nest == 0 || token->type != OP_CLOSE_SUBEXP)) 2228 && (nest == 0 || token->type != OP_CLOSE_SUBEXP))
2227 { 2229 {
2228 expr = parse_expression (regexp, preg, token, syntax, nest, err); 2230 expr = parse_expression (regexp, preg, token, syntax, nest, err);
2229 if (BE (*err != REG_NOERROR && expr == NULL, 0)) 2231 if (__glibc_unlikely (*err != REG_NOERROR && expr == NULL))
2230 { 2232 {
2231 if (tree != NULL) 2233 if (tree != NULL)
2232 postorder (tree, free_tree, NULL); 2234 postorder (tree, free_tree, NULL);
@@ -2267,7 +2269,7 @@ parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token,
2267 { 2269 {
2268 case CHARACTER: 2270 case CHARACTER:
2269 tree = create_token_tree (dfa, NULL, NULL, token); 2271 tree = create_token_tree (dfa, NULL, NULL, token);
2270 if (BE (tree == NULL, 0)) 2272 if (__glibc_unlikely (tree == NULL))
2271 { 2273 {
2272 *err = REG_ESPACE; 2274 *err = REG_ESPACE;
2273 return NULL; 2275 return NULL;
@@ -2282,7 +2284,7 @@ parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token,
2282 fetch_token (token, regexp, syntax); 2284 fetch_token (token, regexp, syntax);
2283 mbc_remain = create_token_tree (dfa, NULL, NULL, token); 2285 mbc_remain = create_token_tree (dfa, NULL, NULL, token);
2284 tree = create_tree (dfa, tree, mbc_remain, CONCAT); 2286 tree = create_tree (dfa, tree, mbc_remain, CONCAT);
2285 if (BE (mbc_remain == NULL || tree == NULL, 0)) 2287 if (__glibc_unlikely (mbc_remain == NULL || tree == NULL))
2286 { 2288 {
2287 *err = REG_ESPACE; 2289 *err = REG_ESPACE;
2288 return NULL; 2290 return NULL;
@@ -2294,25 +2296,25 @@ parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token,
2294 2296
2295 case OP_OPEN_SUBEXP: 2297 case OP_OPEN_SUBEXP:
2296 tree = parse_sub_exp (regexp, preg, token, syntax, nest + 1, err); 2298 tree = parse_sub_exp (regexp, preg, token, syntax, nest + 1, err);
2297 if (BE (*err != REG_NOERROR && tree == NULL, 0)) 2299 if (__glibc_unlikely (*err != REG_NOERROR && tree == NULL))
2298 return NULL; 2300 return NULL;
2299 break; 2301 break;
2300 2302
2301 case OP_OPEN_BRACKET: 2303 case OP_OPEN_BRACKET:
2302 tree = parse_bracket_exp (regexp, dfa, token, syntax, err); 2304 tree = parse_bracket_exp (regexp, dfa, token, syntax, err);
2303 if (BE (*err != REG_NOERROR && tree == NULL, 0)) 2305 if (__glibc_unlikely (*err != REG_NOERROR && tree == NULL))
2304 return NULL; 2306 return NULL;
2305 break; 2307 break;
2306 2308
2307 case OP_BACK_REF: 2309 case OP_BACK_REF:
2308 if (!BE (dfa->completed_bkref_map & (1 << token->opr.idx), 1)) 2310 if (!__glibc_likely (dfa->completed_bkref_map & (1 << token->opr.idx)))
2309 { 2311 {
2310 *err = REG_ESUBREG; 2312 *err = REG_ESUBREG;
2311 return NULL; 2313 return NULL;
2312 } 2314 }
2313 dfa->used_bkref_map |= 1 << token->opr.idx; 2315 dfa->used_bkref_map |= 1 << token->opr.idx;
2314 tree = create_token_tree (dfa, NULL, NULL, token); 2316 tree = create_token_tree (dfa, NULL, NULL, token);
2315 if (BE (tree == NULL, 0)) 2317 if (__glibc_unlikely (tree == NULL))
2316 { 2318 {
2317 *err = REG_ESPACE; 2319 *err = REG_ESPACE;
2318 return NULL; 2320 return NULL;
@@ -2358,7 +2360,7 @@ parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token,
2358 /* mb_partial and word_char bits should be initialized already 2360 /* mb_partial and word_char bits should be initialized already
2359 by peek_token. */ 2361 by peek_token. */
2360 tree = create_token_tree (dfa, NULL, NULL, token); 2362 tree = create_token_tree (dfa, NULL, NULL, token);
2361 if (BE (tree == NULL, 0)) 2363 if (__glibc_unlikely (tree == NULL))
2362 { 2364 {
2363 *err = REG_ESPACE; 2365 *err = REG_ESPACE;
2364 return NULL; 2366 return NULL;
@@ -2388,7 +2390,8 @@ parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token,
2388 } 2390 }
2389 tree_last = create_token_tree (dfa, NULL, NULL, token); 2391 tree_last = create_token_tree (dfa, NULL, NULL, token);
2390 tree = create_tree (dfa, tree_first, tree_last, OP_ALT); 2392 tree = create_tree (dfa, tree_first, tree_last, OP_ALT);
2391 if (BE (tree_first == NULL || tree_last == NULL || tree == NULL, 0)) 2393 if (__glibc_unlikely (tree_first == NULL || tree_last == NULL
2394 || tree == NULL))
2392 { 2395 {
2393 *err = REG_ESPACE; 2396 *err = REG_ESPACE;
2394 return NULL; 2397 return NULL;
@@ -2397,7 +2400,7 @@ parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token,
2397 else 2400 else
2398 { 2401 {
2399 tree = create_token_tree (dfa, NULL, NULL, token); 2402 tree = create_token_tree (dfa, NULL, NULL, token);
2400 if (BE (tree == NULL, 0)) 2403 if (__glibc_unlikely (tree == NULL))
2401 { 2404 {
2402 *err = REG_ESPACE; 2405 *err = REG_ESPACE;
2403 return NULL; 2406 return NULL;
@@ -2412,7 +2415,7 @@ parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token,
2412 2415
2413 case OP_PERIOD: 2416 case OP_PERIOD:
2414 tree = create_token_tree (dfa, NULL, NULL, token); 2417 tree = create_token_tree (dfa, NULL, NULL, token);
2415 if (BE (tree == NULL, 0)) 2418 if (__glibc_unlikely (tree == NULL))
2416 { 2419 {
2417 *err = REG_ESPACE; 2420 *err = REG_ESPACE;
2418 return NULL; 2421 return NULL;
@@ -2427,7 +2430,7 @@ parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token,
2427 "alnum", 2430 "alnum",
2428 "_", 2431 "_",
2429 token->type == OP_NOTWORD, err); 2432 token->type == OP_NOTWORD, err);
2430 if (BE (*err != REG_NOERROR && tree == NULL, 0)) 2433 if (__glibc_unlikely (*err != REG_NOERROR && tree == NULL))
2431 return NULL; 2434 return NULL;
2432 break; 2435 break;
2433 2436
@@ -2437,7 +2440,7 @@ parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token,
2437 "space", 2440 "space",
2438 "", 2441 "",
2439 token->type == OP_NOTSPACE, err); 2442 token->type == OP_NOTSPACE, err);
2440 if (BE (*err != REG_NOERROR && tree == NULL, 0)) 2443 if (__glibc_unlikely (*err != REG_NOERROR && tree == NULL))
2441 return NULL; 2444 return NULL;
2442 break; 2445 break;
2443 2446
@@ -2463,7 +2466,7 @@ parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token,
2463 { 2466 {
2464 bin_tree_t *dup_tree = parse_dup_op (tree, regexp, dfa, token, 2467 bin_tree_t *dup_tree = parse_dup_op (tree, regexp, dfa, token,
2465 syntax, err); 2468 syntax, err);
2466 if (BE (*err != REG_NOERROR && dup_tree == NULL, 0)) 2469 if (__glibc_unlikely (*err != REG_NOERROR && dup_tree == NULL))
2467 { 2470 {
2468 if (tree != NULL) 2471 if (tree != NULL)
2469 postorder (tree, free_tree, NULL); 2472 postorder (tree, free_tree, NULL);
@@ -2509,13 +2512,14 @@ parse_sub_exp (re_string_t *regexp, regex_t *preg, re_token_t *token,
2509 else 2512 else
2510 { 2513 {
2511 tree = parse_reg_exp (regexp, preg, token, syntax, nest, err); 2514 tree = parse_reg_exp (regexp, preg, token, syntax, nest, err);
2512 if (BE (*err == REG_NOERROR && token->type != OP_CLOSE_SUBEXP, 0)) 2515 if (__glibc_unlikely (*err == REG_NOERROR
2516 && token->type != OP_CLOSE_SUBEXP))
2513 { 2517 {
2514 if (tree != NULL) 2518 if (tree != NULL)
2515 postorder (tree, free_tree, NULL); 2519 postorder (tree, free_tree, NULL);
2516 *err = REG_EPAREN; 2520 *err = REG_EPAREN;
2517 } 2521 }
2518 if (BE (*err != REG_NOERROR, 0)) 2522 if (__glibc_unlikely (*err != REG_NOERROR))
2519 return NULL; 2523 return NULL;
2520 } 2524 }
2521 2525
@@ -2523,7 +2527,7 @@ parse_sub_exp (re_string_t *regexp, regex_t *preg, re_token_t *token,
2523 dfa->completed_bkref_map |= 1 << cur_nsub; 2527 dfa->completed_bkref_map |= 1 << cur_nsub;
2524 2528
2525 tree = create_tree (dfa, tree, NULL, SUBEXP); 2529 tree = create_tree (dfa, tree, NULL, SUBEXP);
2526 if (BE (tree == NULL, 0)) 2530 if (__glibc_unlikely (tree == NULL))
2527 { 2531 {
2528 *err = REG_ESPACE; 2532 *err = REG_ESPACE;
2529 return NULL; 2533 return NULL;
@@ -2556,17 +2560,17 @@ parse_dup_op (bin_tree_t *elem, re_string_t *regexp, re_dfa_t *dfa,
2556 return NULL; 2560 return NULL;
2557 } 2561 }
2558 } 2562 }
2559 if (BE (start != -2, 1)) 2563 if (__glibc_likely (start != -2))
2560 { 2564 {
2561 /* We treat "{n}" as "{n,n}". */ 2565 /* We treat "{n}" as "{n,n}". */
2562 end = ((token->type == OP_CLOSE_DUP_NUM) ? start 2566 end = ((token->type == OP_CLOSE_DUP_NUM) ? start
2563 : ((token->type == CHARACTER && token->opr.c == ',') 2567 : ((token->type == CHARACTER && token->opr.c == ',')
2564 ? fetch_number (regexp, token, syntax) : -2)); 2568 ? fetch_number (regexp, token, syntax) : -2));
2565 } 2569 }
2566 if (BE (start == -2 || end == -2, 0)) 2570 if (__glibc_unlikely (start == -2 || end == -2))
2567 { 2571 {
2568 /* Invalid sequence. */ 2572 /* Invalid sequence. */
2569 if (BE (!(syntax & RE_INVALID_INTERVAL_ORD), 0)) 2573 if (__glibc_unlikely (!(syntax & RE_INVALID_INTERVAL_ORD)))
2570 { 2574 {
2571 if (token->type == END_OF_RE) 2575 if (token->type == END_OF_RE)
2572 *err = REG_EBRACE; 2576 *err = REG_EBRACE;
@@ -2585,15 +2589,15 @@ parse_dup_op (bin_tree_t *elem, re_string_t *regexp, re_dfa_t *dfa,
2585 return elem; 2589 return elem;
2586 } 2590 }
2587 2591
2588 if (BE ((end != -1 && start > end) 2592 if (__glibc_unlikely ((end != -1 && start > end)
2589 || token->type != OP_CLOSE_DUP_NUM, 0)) 2593 || token->type != OP_CLOSE_DUP_NUM))
2590 { 2594 {
2591 /* First number greater than second. */ 2595 /* First number greater than second. */
2592 *err = REG_BADBR; 2596 *err = REG_BADBR;
2593 return NULL; 2597 return NULL;
2594 } 2598 }
2595 2599
2596 if (BE (RE_DUP_MAX < (end == -1 ? start : end), 0)) 2600 if (__glibc_unlikely (RE_DUP_MAX < (end == -1 ? start : end)))
2597 { 2601 {
2598 *err = REG_ESIZE; 2602 *err = REG_ESIZE;
2599 return NULL; 2603 return NULL;
@@ -2607,23 +2611,23 @@ parse_dup_op (bin_tree_t *elem, re_string_t *regexp, re_dfa_t *dfa,
2607 2611
2608 fetch_token (token, regexp, syntax); 2612 fetch_token (token, regexp, syntax);
2609 2613
2610 if (BE (elem == NULL, 0)) 2614 if (__glibc_unlikely (elem == NULL))
2611 return NULL; 2615 return NULL;
2612 if (BE (start == 0 && end == 0, 0)) 2616 if (__glibc_unlikely (start == 0 && end == 0))
2613 { 2617 {
2614 postorder (elem, free_tree, NULL); 2618 postorder (elem, free_tree, NULL);
2615 return NULL; 2619 return NULL;
2616 } 2620 }
2617 2621
2618 /* Extract "<re>{n,m}" to "<re><re>...<re><re>{0,<m-n>}". */ 2622 /* Extract "<re>{n,m}" to "<re><re>...<re><re>{0,<m-n>}". */
2619 if (BE (start > 0, 0)) 2623 if (__glibc_unlikely (start > 0))
2620 { 2624 {
2621 tree = elem; 2625 tree = elem;
2622 for (i = 2; i <= start; ++i) 2626 for (i = 2; i <= start; ++i)
2623 { 2627 {
2624 elem = duplicate_tree (elem, dfa); 2628 elem = duplicate_tree (elem, dfa);
2625 tree = create_tree (dfa, tree, elem, CONCAT); 2629 tree = create_tree (dfa, tree, elem, CONCAT);
2626 if (BE (elem == NULL || tree == NULL, 0)) 2630 if (__glibc_unlikely (elem == NULL || tree == NULL))
2627 goto parse_dup_op_espace; 2631 goto parse_dup_op_espace;
2628 } 2632 }
2629 2633
@@ -2632,7 +2636,7 @@ parse_dup_op (bin_tree_t *elem, re_string_t *regexp, re_dfa_t *dfa,
2632 2636
2633 /* Duplicate ELEM before it is marked optional. */ 2637 /* Duplicate ELEM before it is marked optional. */
2634 elem = duplicate_tree (elem, dfa); 2638 elem = duplicate_tree (elem, dfa);
2635 if (BE (elem == NULL, 0)) 2639 if (__glibc_unlikely (elem == NULL))
2636 goto parse_dup_op_espace; 2640 goto parse_dup_op_espace;
2637 old_tree = tree; 2641 old_tree = tree;
2638 } 2642 }
@@ -2647,7 +2651,7 @@ parse_dup_op (bin_tree_t *elem, re_string_t *regexp, re_dfa_t *dfa,
2647 2651
2648 tree = create_tree (dfa, elem, NULL, 2652 tree = create_tree (dfa, elem, NULL,
2649 (end == -1 ? OP_DUP_ASTERISK : OP_ALT)); 2653 (end == -1 ? OP_DUP_ASTERISK : OP_ALT));
2650 if (BE (tree == NULL, 0)) 2654 if (__glibc_unlikely (tree == NULL))
2651 goto parse_dup_op_espace; 2655 goto parse_dup_op_espace;
2652 2656
2653 /* This loop is actually executed only when end != -1, 2657 /* This loop is actually executed only when end != -1,
@@ -2658,11 +2662,11 @@ parse_dup_op (bin_tree_t *elem, re_string_t *regexp, re_dfa_t *dfa,
2658 { 2662 {
2659 elem = duplicate_tree (elem, dfa); 2663 elem = duplicate_tree (elem, dfa);
2660 tree = create_tree (dfa, tree, elem, CONCAT); 2664 tree = create_tree (dfa, tree, elem, CONCAT);
2661 if (BE (elem == NULL || tree == NULL, 0)) 2665 if (__glibc_unlikely (elem == NULL || tree == NULL))
2662 goto parse_dup_op_espace; 2666 goto parse_dup_op_espace;
2663 2667
2664 tree = create_tree (dfa, tree, NULL, OP_ALT); 2668 tree = create_tree (dfa, tree, NULL, OP_ALT);
2665 if (BE (tree == NULL, 0)) 2669 if (__glibc_unlikely (tree == NULL))
2666 goto parse_dup_op_espace; 2670 goto parse_dup_op_espace;
2667 } 2671 }
2668 2672
@@ -2717,17 +2721,18 @@ build_range_exp (const reg_syntax_t syntax,
2717{ 2721{
2718 unsigned int start_ch, end_ch; 2722 unsigned int start_ch, end_ch;
2719 /* Equivalence Classes and Character Classes can't be a range start/end. */ 2723 /* Equivalence Classes and Character Classes can't be a range start/end. */
2720 if (BE (start_elem->type == EQUIV_CLASS || start_elem->type == CHAR_CLASS 2724 if (__glibc_unlikely (start_elem->type == EQUIV_CLASS
2721 || end_elem->type == EQUIV_CLASS || end_elem->type == CHAR_CLASS, 2725 || start_elem->type == CHAR_CLASS
2722 0)) 2726 || end_elem->type == EQUIV_CLASS
2727 || end_elem->type == CHAR_CLASS))
2723 return REG_ERANGE; 2728 return REG_ERANGE;
2724 2729
2725 /* We can handle no multi character collating elements without libc 2730 /* We can handle no multi character collating elements without libc
2726 support. */ 2731 support. */
2727 if (BE ((start_elem->type == COLL_SYM 2732 if (__glibc_unlikely ((start_elem->type == COLL_SYM
2728 && strlen ((char *) start_elem->opr.name) > 1) 2733 && strlen ((char *) start_elem->opr.name) > 1)
2729 || (end_elem->type == COLL_SYM 2734 || (end_elem->type == COLL_SYM
2730 && strlen ((char *) end_elem->opr.name) > 1), 0)) 2735 && strlen ((char *) end_elem->opr.name) > 1)))
2731 return REG_ECOLLATE; 2736 return REG_ECOLLATE;
2732 2737
2733# ifdef RE_ENABLE_I18N 2738# ifdef RE_ENABLE_I18N
@@ -2748,7 +2753,8 @@ build_range_exp (const reg_syntax_t syntax,
2748 ? parse_byte (end_ch, mbcset) : end_elem->opr.wch); 2753 ? parse_byte (end_ch, mbcset) : end_elem->opr.wch);
2749 if (start_wc == WEOF || end_wc == WEOF) 2754 if (start_wc == WEOF || end_wc == WEOF)
2750 return REG_ECOLLATE; 2755 return REG_ECOLLATE;
2751 else if (BE ((syntax & RE_NO_EMPTY_RANGES) && start_wc > end_wc, 0)) 2756 else if (__glibc_unlikely ((syntax & RE_NO_EMPTY_RANGES)
2757 && start_wc > end_wc))
2752 return REG_ERANGE; 2758 return REG_ERANGE;
2753 2759
2754 /* Got valid collation sequence values, add them as a new entry. 2760 /* Got valid collation sequence values, add them as a new entry.
@@ -2759,7 +2765,7 @@ build_range_exp (const reg_syntax_t syntax,
2759 if (mbcset) 2765 if (mbcset)
2760 { 2766 {
2761 /* Check the space of the arrays. */ 2767 /* Check the space of the arrays. */
2762 if (BE (*range_alloc == mbcset->nranges, 0)) 2768 if (__glibc_unlikely (*range_alloc == mbcset->nranges))
2763 { 2769 {
2764 /* There is not enough space, need realloc. */ 2770 /* There is not enough space, need realloc. */
2765 wchar_t *new_array_start, *new_array_end; 2771 wchar_t *new_array_start, *new_array_end;
@@ -2774,7 +2780,8 @@ build_range_exp (const reg_syntax_t syntax,
2774 new_array_end = re_realloc (mbcset->range_ends, wchar_t, 2780 new_array_end = re_realloc (mbcset->range_ends, wchar_t,
2775 new_nranges); 2781 new_nranges);
2776 2782
2777 if (BE (new_array_start == NULL || new_array_end == NULL, 0)) 2783 if (__glibc_unlikely (new_array_start == NULL
2784 || new_array_end == NULL))
2778 { 2785 {
2779 re_free (new_array_start); 2786 re_free (new_array_start);
2780 re_free (new_array_end); 2787 re_free (new_array_end);
@@ -2834,7 +2841,7 @@ build_collating_symbol (bitset_t sbcset, const unsigned char *name)
2834# endif /* not RE_ENABLE_I18N */ 2841# endif /* not RE_ENABLE_I18N */
2835{ 2842{
2836 size_t name_len = strlen ((const char *) name); 2843 size_t name_len = strlen ((const char *) name);
2837 if (BE (name_len != 1, 0)) 2844 if (__glibc_unlikely (name_len != 1))
2838 return REG_ECOLLATE; 2845 return REG_ECOLLATE;
2839 else 2846 else
2840 { 2847 {
@@ -2969,18 +2976,21 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
2969 2976
2970 /* Equivalence Classes and Character Classes can't be a range 2977 /* Equivalence Classes and Character Classes can't be a range
2971 start/end. */ 2978 start/end. */
2972 if (BE (start_elem->type == EQUIV_CLASS || start_elem->type == CHAR_CLASS 2979 if (__glibc_unlikely (start_elem->type == EQUIV_CLASS
2973 || end_elem->type == EQUIV_CLASS || end_elem->type == CHAR_CLASS, 2980 || start_elem->type == CHAR_CLASS
2974 0)) 2981 || end_elem->type == EQUIV_CLASS
2982 || end_elem->type == CHAR_CLASS))
2975 return REG_ERANGE; 2983 return REG_ERANGE;
2976 2984
2977 /* FIXME: Implement rational ranges here, too. */ 2985 /* FIXME: Implement rational ranges here, too. */
2978 start_collseq = lookup_collation_sequence_value (start_elem); 2986 start_collseq = lookup_collation_sequence_value (start_elem);
2979 end_collseq = lookup_collation_sequence_value (end_elem); 2987 end_collseq = lookup_collation_sequence_value (end_elem);
2980 /* Check start/end collation sequence values. */ 2988 /* Check start/end collation sequence values. */
2981 if (BE (start_collseq == UINT_MAX || end_collseq == UINT_MAX, 0)) 2989 if (__glibc_unlikely (start_collseq == UINT_MAX
2990 || end_collseq == UINT_MAX))
2982 return REG_ECOLLATE; 2991 return REG_ECOLLATE;
2983 if (BE ((syntax & RE_NO_EMPTY_RANGES) && start_collseq > end_collseq, 0)) 2992 if (__glibc_unlikely ((syntax & RE_NO_EMPTY_RANGES)
2993 && start_collseq > end_collseq))
2984 return REG_ERANGE; 2994 return REG_ERANGE;
2985 2995
2986 /* Got valid collation sequence values, add them as a new entry. 2996 /* Got valid collation sequence values, add them as a new entry.
@@ -2990,7 +3000,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
2990 if (nrules > 0 || dfa->mb_cur_max > 1) 3000 if (nrules > 0 || dfa->mb_cur_max > 1)
2991 { 3001 {
2992 /* Check the space of the arrays. */ 3002 /* Check the space of the arrays. */
2993 if (BE (*range_alloc == mbcset->nranges, 0)) 3003 if (__glibc_unlikely (*range_alloc == mbcset->nranges))
2994 { 3004 {
2995 /* There is not enough space, need realloc. */ 3005 /* There is not enough space, need realloc. */
2996 uint32_t *new_array_start; 3006 uint32_t *new_array_start;
@@ -3004,7 +3014,8 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
3004 new_array_end = re_realloc (mbcset->range_ends, uint32_t, 3014 new_array_end = re_realloc (mbcset->range_ends, uint32_t,
3005 new_nranges); 3015 new_nranges);
3006 3016
3007 if (BE (new_array_start == NULL || new_array_end == NULL, 0)) 3017 if (__glibc_unlikely (new_array_start == NULL
3018 || new_array_end == NULL))
3008 return REG_ESPACE; 3019 return REG_ESPACE;
3009 3020
3010 mbcset->range_starts = new_array_start; 3021 mbcset->range_starts = new_array_start;
@@ -3068,7 +3079,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
3068 3079
3069 /* Got valid collation sequence, add it as a new entry. */ 3080 /* Got valid collation sequence, add it as a new entry. */
3070 /* Check the space of the arrays. */ 3081 /* Check the space of the arrays. */
3071 if (BE (*coll_sym_alloc == mbcset->ncoll_syms, 0)) 3082 if (__glibc_unlikely (*coll_sym_alloc == mbcset->ncoll_syms))
3072 { 3083 {
3073 /* Not enough, realloc it. */ 3084 /* Not enough, realloc it. */
3074 /* +1 in case of mbcset->ncoll_syms is 0. */ 3085 /* +1 in case of mbcset->ncoll_syms is 0. */
@@ -3077,7 +3088,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
3077 if *alloc == 0. */ 3088 if *alloc == 0. */
3078 int32_t *new_coll_syms = re_realloc (mbcset->coll_syms, int32_t, 3089 int32_t *new_coll_syms = re_realloc (mbcset->coll_syms, int32_t,
3079 new_coll_sym_alloc); 3090 new_coll_sym_alloc);
3080 if (BE (new_coll_syms == NULL, 0)) 3091 if (__glibc_unlikely (new_coll_syms == NULL))
3081 return REG_ESPACE; 3092 return REG_ESPACE;
3082 mbcset->coll_syms = new_coll_syms; 3093 mbcset->coll_syms = new_coll_syms;
3083 *coll_sym_alloc = new_coll_sym_alloc; 3094 *coll_sym_alloc = new_coll_sym_alloc;
@@ -3087,7 +3098,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
3087 } 3098 }
3088 else 3099 else
3089 { 3100 {
3090 if (BE (name_len != 1, 0)) 3101 if (__glibc_unlikely (name_len != 1))
3091 return REG_ECOLLATE; 3102 return REG_ECOLLATE;
3092 else 3103 else
3093 { 3104 {
@@ -3131,9 +3142,9 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
3131 mbcset = (re_charset_t *) calloc (sizeof (re_charset_t), 1); 3142 mbcset = (re_charset_t *) calloc (sizeof (re_charset_t), 1);
3132#endif /* RE_ENABLE_I18N */ 3143#endif /* RE_ENABLE_I18N */
3133#ifdef RE_ENABLE_I18N 3144#ifdef RE_ENABLE_I18N
3134 if (BE (sbcset == NULL || mbcset == NULL, 0)) 3145 if (__glibc_unlikely (sbcset == NULL || mbcset == NULL))
3135#else 3146#else
3136 if (BE (sbcset == NULL, 0)) 3147 if (__glibc_unlikely (sbcset == NULL))
3137#endif /* RE_ENABLE_I18N */ 3148#endif /* RE_ENABLE_I18N */
3138 { 3149 {
3139 re_free (sbcset); 3150 re_free (sbcset);
@@ -3145,7 +3156,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
3145 } 3156 }
3146 3157
3147 token_len = peek_token_bracket (token, regexp, syntax); 3158 token_len = peek_token_bracket (token, regexp, syntax);
3148 if (BE (token->type == END_OF_RE, 0)) 3159 if (__glibc_unlikely (token->type == END_OF_RE))
3149 { 3160 {
3150 *err = REG_BADPAT; 3161 *err = REG_BADPAT;
3151 goto parse_bracket_exp_free_return; 3162 goto parse_bracket_exp_free_return;
@@ -3160,7 +3171,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
3160 bitset_set (sbcset, '\n'); 3171 bitset_set (sbcset, '\n');
3161 re_string_skip_bytes (regexp, token_len); /* Skip a token. */ 3172 re_string_skip_bytes (regexp, token_len); /* Skip a token. */
3162 token_len = peek_token_bracket (token, regexp, syntax); 3173 token_len = peek_token_bracket (token, regexp, syntax);
3163 if (BE (token->type == END_OF_RE, 0)) 3174 if (__glibc_unlikely (token->type == END_OF_RE))
3164 { 3175 {
3165 *err = REG_BADPAT; 3176 *err = REG_BADPAT;
3166 goto parse_bracket_exp_free_return; 3177 goto parse_bracket_exp_free_return;
@@ -3185,7 +3196,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
3185 start_elem.type = COLL_SYM; 3196 start_elem.type = COLL_SYM;
3186 ret = parse_bracket_element (&start_elem, regexp, token, token_len, dfa, 3197 ret = parse_bracket_element (&start_elem, regexp, token, token_len, dfa,
3187 syntax, first_round); 3198 syntax, first_round);
3188 if (BE (ret != REG_NOERROR, 0)) 3199 if (__glibc_unlikely (ret != REG_NOERROR))
3189 { 3200 {
3190 *err = ret; 3201 *err = ret;
3191 goto parse_bracket_exp_free_return; 3202 goto parse_bracket_exp_free_return;
@@ -3198,7 +3209,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
3198 /* Do not check for ranges if we know they are not allowed. */ 3209 /* Do not check for ranges if we know they are not allowed. */
3199 if (start_elem.type != CHAR_CLASS && start_elem.type != EQUIV_CLASS) 3210 if (start_elem.type != CHAR_CLASS && start_elem.type != EQUIV_CLASS)
3200 { 3211 {
3201 if (BE (token->type == END_OF_RE, 0)) 3212 if (__glibc_unlikely (token->type == END_OF_RE))
3202 { 3213 {
3203 *err = REG_EBRACK; 3214 *err = REG_EBRACK;
3204 goto parse_bracket_exp_free_return; 3215 goto parse_bracket_exp_free_return;
@@ -3207,7 +3218,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
3207 { 3218 {
3208 re_string_skip_bytes (regexp, token_len); /* Skip '-'. */ 3219 re_string_skip_bytes (regexp, token_len); /* Skip '-'. */
3209 token_len2 = peek_token_bracket (&token2, regexp, syntax); 3220 token_len2 = peek_token_bracket (&token2, regexp, syntax);
3210 if (BE (token2.type == END_OF_RE, 0)) 3221 if (__glibc_unlikely (token2.type == END_OF_RE))
3211 { 3222 {
3212 *err = REG_EBRACK; 3223 *err = REG_EBRACK;
3213 goto parse_bracket_exp_free_return; 3224 goto parse_bracket_exp_free_return;
@@ -3229,7 +3240,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
3229 end_elem.type = COLL_SYM; 3240 end_elem.type = COLL_SYM;
3230 ret = parse_bracket_element (&end_elem, regexp, &token2, token_len2, 3241 ret = parse_bracket_element (&end_elem, regexp, &token2, token_len2,
3231 dfa, syntax, true); 3242 dfa, syntax, true);
3232 if (BE (ret != REG_NOERROR, 0)) 3243 if (__glibc_unlikely (ret != REG_NOERROR))
3233 { 3244 {
3234 *err = ret; 3245 *err = ret;
3235 goto parse_bracket_exp_free_return; 3246 goto parse_bracket_exp_free_return;
@@ -3249,7 +3260,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
3249 *err = build_range_exp (syntax, sbcset, &start_elem, &end_elem); 3260 *err = build_range_exp (syntax, sbcset, &start_elem, &end_elem);
3250# endif 3261# endif
3251#endif /* RE_ENABLE_I18N */ 3262#endif /* RE_ENABLE_I18N */
3252 if (BE (*err != REG_NOERROR, 0)) 3263 if (__glibc_unlikely (*err != REG_NOERROR))
3253 goto parse_bracket_exp_free_return; 3264 goto parse_bracket_exp_free_return;
3254 } 3265 }
3255 else 3266 else
@@ -3262,7 +3273,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
3262#ifdef RE_ENABLE_I18N 3273#ifdef RE_ENABLE_I18N
3263 case MB_CHAR: 3274 case MB_CHAR:
3264 /* Check whether the array has enough space. */ 3275 /* Check whether the array has enough space. */
3265 if (BE (mbchar_alloc == mbcset->nmbchars, 0)) 3276 if (__glibc_unlikely (mbchar_alloc == mbcset->nmbchars))
3266 { 3277 {
3267 wchar_t *new_mbchars; 3278 wchar_t *new_mbchars;
3268 /* Not enough, realloc it. */ 3279 /* Not enough, realloc it. */
@@ -3271,7 +3282,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
3271 /* Use realloc since array is NULL if *alloc == 0. */ 3282 /* Use realloc since array is NULL if *alloc == 0. */
3272 new_mbchars = re_realloc (mbcset->mbchars, wchar_t, 3283 new_mbchars = re_realloc (mbcset->mbchars, wchar_t,
3273 mbchar_alloc); 3284 mbchar_alloc);
3274 if (BE (new_mbchars == NULL, 0)) 3285 if (__glibc_unlikely (new_mbchars == NULL))
3275 goto parse_bracket_exp_espace; 3286 goto parse_bracket_exp_espace;
3276 mbcset->mbchars = new_mbchars; 3287 mbcset->mbchars = new_mbchars;
3277 } 3288 }
@@ -3284,7 +3295,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
3284 mbcset, &equiv_class_alloc, 3295 mbcset, &equiv_class_alloc,
3285#endif /* RE_ENABLE_I18N */ 3296#endif /* RE_ENABLE_I18N */
3286 start_elem.opr.name); 3297 start_elem.opr.name);
3287 if (BE (*err != REG_NOERROR, 0)) 3298 if (__glibc_unlikely (*err != REG_NOERROR))
3288 goto parse_bracket_exp_free_return; 3299 goto parse_bracket_exp_free_return;
3289 break; 3300 break;
3290 case COLL_SYM: 3301 case COLL_SYM:
@@ -3293,7 +3304,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
3293 mbcset, &coll_sym_alloc, 3304 mbcset, &coll_sym_alloc,
3294#endif /* RE_ENABLE_I18N */ 3305#endif /* RE_ENABLE_I18N */
3295 start_elem.opr.name); 3306 start_elem.opr.name);
3296 if (BE (*err != REG_NOERROR, 0)) 3307 if (__glibc_unlikely (*err != REG_NOERROR))
3297 goto parse_bracket_exp_free_return; 3308 goto parse_bracket_exp_free_return;
3298 break; 3309 break;
3299 case CHAR_CLASS: 3310 case CHAR_CLASS:
@@ -3303,7 +3314,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
3303#endif /* RE_ENABLE_I18N */ 3314#endif /* RE_ENABLE_I18N */
3304 (const char *) start_elem.opr.name, 3315 (const char *) start_elem.opr.name,
3305 syntax); 3316 syntax);
3306 if (BE (*err != REG_NOERROR, 0)) 3317 if (__glibc_unlikely (*err != REG_NOERROR))
3307 goto parse_bracket_exp_free_return; 3318 goto parse_bracket_exp_free_return;
3308 break; 3319 break;
3309 default: 3320 default:
@@ -3311,7 +3322,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
3311 break; 3322 break;
3312 } 3323 }
3313 } 3324 }
3314 if (BE (token->type == END_OF_RE, 0)) 3325 if (__glibc_unlikely (token->type == END_OF_RE))
3315 { 3326 {
3316 *err = REG_EBRACK; 3327 *err = REG_EBRACK;
3317 goto parse_bracket_exp_free_return; 3328 goto parse_bracket_exp_free_return;
@@ -3342,7 +3353,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
3342 br_token.type = COMPLEX_BRACKET; 3353 br_token.type = COMPLEX_BRACKET;
3343 br_token.opr.mbcset = mbcset; 3354 br_token.opr.mbcset = mbcset;
3344 mbc_tree = create_token_tree (dfa, NULL, NULL, &br_token); 3355 mbc_tree = create_token_tree (dfa, NULL, NULL, &br_token);
3345 if (BE (mbc_tree == NULL, 0)) 3356 if (__glibc_unlikely (mbc_tree == NULL))
3346 goto parse_bracket_exp_espace; 3357 goto parse_bracket_exp_espace;
3347 for (sbc_idx = 0; sbc_idx < BITSET_WORDS; ++sbc_idx) 3358 for (sbc_idx = 0; sbc_idx < BITSET_WORDS; ++sbc_idx)
3348 if (sbcset[sbc_idx]) 3359 if (sbcset[sbc_idx])
@@ -3355,12 +3366,12 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
3355 br_token.type = SIMPLE_BRACKET; 3366 br_token.type = SIMPLE_BRACKET;
3356 br_token.opr.sbcset = sbcset; 3367 br_token.opr.sbcset = sbcset;
3357 work_tree = create_token_tree (dfa, NULL, NULL, &br_token); 3368 work_tree = create_token_tree (dfa, NULL, NULL, &br_token);
3358 if (BE (work_tree == NULL, 0)) 3369 if (__glibc_unlikely (work_tree == NULL))
3359 goto parse_bracket_exp_espace; 3370 goto parse_bracket_exp_espace;
3360 3371
3361 /* Then join them by ALT node. */ 3372 /* Then join them by ALT node. */
3362 work_tree = create_tree (dfa, work_tree, mbc_tree, OP_ALT); 3373 work_tree = create_tree (dfa, work_tree, mbc_tree, OP_ALT);
3363 if (BE (work_tree == NULL, 0)) 3374 if (__glibc_unlikely (work_tree == NULL))
3364 goto parse_bracket_exp_espace; 3375 goto parse_bracket_exp_espace;
3365 } 3376 }
3366 else 3377 else
@@ -3379,7 +3390,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
3379 br_token.type = SIMPLE_BRACKET; 3390 br_token.type = SIMPLE_BRACKET;
3380 br_token.opr.sbcset = sbcset; 3391 br_token.opr.sbcset = sbcset;
3381 work_tree = create_token_tree (dfa, NULL, NULL, &br_token); 3392 work_tree = create_token_tree (dfa, NULL, NULL, &br_token);
3382 if (BE (work_tree == NULL, 0)) 3393 if (__glibc_unlikely (work_tree == NULL))
3383 goto parse_bracket_exp_espace; 3394 goto parse_bracket_exp_espace;
3384 } 3395 }
3385 return work_tree; 3396 return work_tree;
@@ -3416,7 +3427,7 @@ parse_bracket_element (bracket_elem_t *elem, re_string_t *regexp,
3416 if (token->type == OP_OPEN_COLL_ELEM || token->type == OP_OPEN_CHAR_CLASS 3427 if (token->type == OP_OPEN_COLL_ELEM || token->type == OP_OPEN_CHAR_CLASS
3417 || token->type == OP_OPEN_EQUIV_CLASS) 3428 || token->type == OP_OPEN_EQUIV_CLASS)
3418 return parse_bracket_symbol (elem, regexp, token); 3429 return parse_bracket_symbol (elem, regexp, token);
3419 if (BE (token->type == OP_CHARSET_RANGE, 0) && !accept_hyphen) 3430 if (__glibc_unlikely (token->type == OP_CHARSET_RANGE) && !accept_hyphen)
3420 { 3431 {
3421 /* A '-' must only appear as anything but a range indicator before 3432 /* A '-' must only appear as anything but a range indicator before
3422 the closing bracket. Everything else is an error. */ 3433 the closing bracket. Everything else is an error. */
@@ -3511,7 +3522,7 @@ build_equiv_class (bitset_t sbcset, const unsigned char *name)
3511 indirect = (const int32_t *) _NL_CURRENT (LC_COLLATE, 3522 indirect = (const int32_t *) _NL_CURRENT (LC_COLLATE,
3512 _NL_COLLATE_INDIRECTMB); 3523 _NL_COLLATE_INDIRECTMB);
3513 idx1 = findidx (table, indirect, extra, &cp, -1); 3524 idx1 = findidx (table, indirect, extra, &cp, -1);
3514 if (BE (idx1 == 0 || *cp != '\0', 0)) 3525 if (__glibc_unlikely (idx1 == 0 || *cp != '\0'))
3515 /* This isn't a valid character. */ 3526 /* This isn't a valid character. */
3516 return REG_ECOLLATE; 3527 return REG_ECOLLATE;
3517 3528
@@ -3536,7 +3547,7 @@ build_equiv_class (bitset_t sbcset, const unsigned char *name)
3536 bitset_set (sbcset, ch); 3547 bitset_set (sbcset, ch);
3537 } 3548 }
3538 /* Check whether the array has enough space. */ 3549 /* Check whether the array has enough space. */
3539 if (BE (*equiv_class_alloc == mbcset->nequiv_classes, 0)) 3550 if (__glibc_unlikely (*equiv_class_alloc == mbcset->nequiv_classes))
3540 { 3551 {
3541 /* Not enough, realloc it. */ 3552 /* Not enough, realloc it. */
3542 /* +1 in case of mbcset->nequiv_classes is 0. */ 3553 /* +1 in case of mbcset->nequiv_classes is 0. */
@@ -3545,7 +3556,7 @@ build_equiv_class (bitset_t sbcset, const unsigned char *name)
3545 int32_t *new_equiv_classes = re_realloc (mbcset->equiv_classes, 3556 int32_t *new_equiv_classes = re_realloc (mbcset->equiv_classes,
3546 int32_t, 3557 int32_t,
3547 new_equiv_class_alloc); 3558 new_equiv_class_alloc);
3548 if (BE (new_equiv_classes == NULL, 0)) 3559 if (__glibc_unlikely (new_equiv_classes == NULL))
3549 return REG_ESPACE; 3560 return REG_ESPACE;
3550 mbcset->equiv_classes = new_equiv_classes; 3561 mbcset->equiv_classes = new_equiv_classes;
3551 *equiv_class_alloc = new_equiv_class_alloc; 3562 *equiv_class_alloc = new_equiv_class_alloc;
@@ -3555,7 +3566,7 @@ build_equiv_class (bitset_t sbcset, const unsigned char *name)
3555 else 3566 else
3556#endif /* _LIBC */ 3567#endif /* _LIBC */
3557 { 3568 {
3558 if (BE (strlen ((const char *) name) != 1, 0)) 3569 if (__glibc_unlikely (strlen ((const char *) name) != 1))
3559 return REG_ECOLLATE; 3570 return REG_ECOLLATE;
3560 bitset_set (sbcset, *name); 3571 bitset_set (sbcset, *name);
3561 } 3572 }
@@ -3589,7 +3600,7 @@ build_charclass (RE_TRANSLATE_TYPE trans, bitset_t sbcset,
3589 3600
3590#ifdef RE_ENABLE_I18N 3601#ifdef RE_ENABLE_I18N
3591 /* Check the space of the arrays. */ 3602 /* Check the space of the arrays. */
3592 if (BE (*char_class_alloc == mbcset->nchar_classes, 0)) 3603 if (__glibc_unlikely (*char_class_alloc == mbcset->nchar_classes))
3593 { 3604 {
3594 /* Not enough, realloc it. */ 3605 /* Not enough, realloc it. */
3595 /* +1 in case of mbcset->nchar_classes is 0. */ 3606 /* +1 in case of mbcset->nchar_classes is 0. */
@@ -3597,7 +3608,7 @@ build_charclass (RE_TRANSLATE_TYPE trans, bitset_t sbcset,
3597 /* Use realloc since array is NULL if *alloc == 0. */ 3608 /* Use realloc since array is NULL if *alloc == 0. */
3598 wctype_t *new_char_classes = re_realloc (mbcset->char_classes, wctype_t, 3609 wctype_t *new_char_classes = re_realloc (mbcset->char_classes, wctype_t,
3599 new_char_class_alloc); 3610 new_char_class_alloc);
3600 if (BE (new_char_classes == NULL, 0)) 3611 if (__glibc_unlikely (new_char_classes == NULL))
3601 return REG_ESPACE; 3612 return REG_ESPACE;
3602 mbcset->char_classes = new_char_classes; 3613 mbcset->char_classes = new_char_classes;
3603 *char_class_alloc = new_char_class_alloc; 3614 *char_class_alloc = new_char_class_alloc;
@@ -3607,7 +3618,7 @@ build_charclass (RE_TRANSLATE_TYPE trans, bitset_t sbcset,
3607 3618
3608#define BUILD_CHARCLASS_LOOP(ctype_func) \ 3619#define BUILD_CHARCLASS_LOOP(ctype_func) \
3609 do { \ 3620 do { \
3610 if (BE (trans != NULL, 0)) \ 3621 if (__glibc_unlikely (trans != NULL)) \
3611 { \ 3622 { \
3612 for (i = 0; i < SBC_MAX; ++i) \ 3623 for (i = 0; i < SBC_MAX; ++i) \
3613 if (ctype_func (i)) \ 3624 if (ctype_func (i)) \
@@ -3667,14 +3678,14 @@ build_charclass_op (re_dfa_t *dfa, RE_TRANSLATE_TYPE trans,
3667 bin_tree_t *tree; 3678 bin_tree_t *tree;
3668 3679
3669 sbcset = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1); 3680 sbcset = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1);
3670 if (BE (sbcset == NULL, 0)) 3681 if (__glibc_unlikely (sbcset == NULL))
3671 { 3682 {
3672 *err = REG_ESPACE; 3683 *err = REG_ESPACE;
3673 return NULL; 3684 return NULL;
3674 } 3685 }
3675#ifdef RE_ENABLE_I18N 3686#ifdef RE_ENABLE_I18N
3676 mbcset = (re_charset_t *) calloc (sizeof (re_charset_t), 1); 3687 mbcset = (re_charset_t *) calloc (sizeof (re_charset_t), 1);
3677 if (BE (mbcset == NULL, 0)) 3688 if (__glibc_unlikely (mbcset == NULL))
3678 { 3689 {
3679 re_free (sbcset); 3690 re_free (sbcset);
3680 *err = REG_ESPACE; 3691 *err = REG_ESPACE;
@@ -3690,7 +3701,7 @@ build_charclass_op (re_dfa_t *dfa, RE_TRANSLATE_TYPE trans,
3690#endif /* RE_ENABLE_I18N */ 3701#endif /* RE_ENABLE_I18N */
3691 class_name, 0); 3702 class_name, 0);
3692 3703
3693 if (BE (ret != REG_NOERROR, 0)) 3704 if (__glibc_unlikely (ret != REG_NOERROR))
3694 { 3705 {
3695 re_free (sbcset); 3706 re_free (sbcset);
3696#ifdef RE_ENABLE_I18N 3707#ifdef RE_ENABLE_I18N
@@ -3720,7 +3731,7 @@ build_charclass_op (re_dfa_t *dfa, RE_TRANSLATE_TYPE trans,
3720 br_token.type = SIMPLE_BRACKET; 3731 br_token.type = SIMPLE_BRACKET;
3721 br_token.opr.sbcset = sbcset; 3732 br_token.opr.sbcset = sbcset;
3722 tree = create_token_tree (dfa, NULL, NULL, &br_token); 3733 tree = create_token_tree (dfa, NULL, NULL, &br_token);
3723 if (BE (tree == NULL, 0)) 3734 if (__glibc_unlikely (tree == NULL))
3724 goto build_word_op_espace; 3735 goto build_word_op_espace;
3725 3736
3726#ifdef RE_ENABLE_I18N 3737#ifdef RE_ENABLE_I18N
@@ -3732,11 +3743,11 @@ build_charclass_op (re_dfa_t *dfa, RE_TRANSLATE_TYPE trans,
3732 br_token.opr.mbcset = mbcset; 3743 br_token.opr.mbcset = mbcset;
3733 dfa->has_mb_node = 1; 3744 dfa->has_mb_node = 1;
3734 mbc_tree = create_token_tree (dfa, NULL, NULL, &br_token); 3745 mbc_tree = create_token_tree (dfa, NULL, NULL, &br_token);
3735 if (BE (mbc_tree == NULL, 0)) 3746 if (__glibc_unlikely (mbc_tree == NULL))
3736 goto build_word_op_espace; 3747 goto build_word_op_espace;
3737 /* Then join them by ALT node. */ 3748 /* Then join them by ALT node. */
3738 tree = create_tree (dfa, tree, mbc_tree, OP_ALT); 3749 tree = create_tree (dfa, tree, mbc_tree, OP_ALT);
3739 if (BE (mbc_tree != NULL, 1)) 3750 if (__glibc_likely (mbc_tree != NULL))
3740 return tree; 3751 return tree;
3741 } 3752 }
3742 else 3753 else
@@ -3772,7 +3783,7 @@ fetch_number (re_string_t *input, re_token_t *token, reg_syntax_t syntax)
3772 { 3783 {
3773 fetch_token (token, input, syntax); 3784 fetch_token (token, input, syntax);
3774 c = token->opr.c; 3785 c = token->opr.c;
3775 if (BE (token->type == END_OF_RE, 0)) 3786 if (__glibc_unlikely (token->type == END_OF_RE))
3776 return -2; 3787 return -2;
3777 if (token->type == OP_CLOSE_DUP_NUM || c == ',') 3788 if (token->type == OP_CLOSE_DUP_NUM || c == ',')
3778 break; 3789 break;
@@ -3822,7 +3833,7 @@ create_token_tree (re_dfa_t *dfa, bin_tree_t *left, bin_tree_t *right,
3822 const re_token_t *token) 3833 const re_token_t *token)
3823{ 3834{
3824 bin_tree_t *tree; 3835 bin_tree_t *tree;
3825 if (BE (dfa->str_tree_storage_idx == BIN_TREE_STORAGE_SIZE, 0)) 3836 if (__glibc_unlikely (dfa->str_tree_storage_idx == BIN_TREE_STORAGE_SIZE))
3826 { 3837 {
3827 bin_tree_storage_t *storage = re_malloc (bin_tree_storage_t, 1); 3838 bin_tree_storage_t *storage = re_malloc (bin_tree_storage_t, 1);
3828 3839
diff --git a/lib/regex.c b/lib/regex.c
index 499e1f0e035..2a86e107039 100644
--- a/lib/regex.c
+++ b/lib/regex.c
@@ -18,7 +18,7 @@
18 <https://www.gnu.org/licenses/>. */ 18 <https://www.gnu.org/licenses/>. */
19 19
20#ifndef _LIBC 20#ifndef _LIBC
21# include <config.h> 21# include <libc-config.h>
22 22
23# if (__GNUC__ == 4 && 6 <= __GNUC_MINOR__) || 4 < __GNUC__ 23# if (__GNUC__ == 4 && 6 <= __GNUC_MINOR__) || 4 < __GNUC__
24# pragma GCC diagnostic ignored "-Wsuggest-attribute=pure" 24# pragma GCC diagnostic ignored "-Wsuggest-attribute=pure"
diff --git a/lib/regex_internal.c b/lib/regex_internal.c
index e3ce4abfa6b..f13def37bf6 100644
--- a/lib/regex_internal.c
+++ b/lib/regex_internal.c
@@ -59,7 +59,7 @@ re_string_allocate (re_string_t *pstr, const char *str, Idx len, Idx init_len,
59 re_string_construct_common (str, len, pstr, trans, icase, dfa); 59 re_string_construct_common (str, len, pstr, trans, icase, dfa);
60 60
61 ret = re_string_realloc_buffers (pstr, init_buf_len); 61 ret = re_string_realloc_buffers (pstr, init_buf_len);
62 if (BE (ret != REG_NOERROR, 0)) 62 if (__glibc_unlikely (ret != REG_NOERROR))
63 return ret; 63 return ret;
64 64
65 pstr->word_char = dfa->word_char; 65 pstr->word_char = dfa->word_char;
@@ -84,7 +84,7 @@ re_string_construct (re_string_t *pstr, const char *str, Idx len,
84 if (len > 0) 84 if (len > 0)
85 { 85 {
86 ret = re_string_realloc_buffers (pstr, len + 1); 86 ret = re_string_realloc_buffers (pstr, len + 1);
87 if (BE (ret != REG_NOERROR, 0)) 87 if (__glibc_unlikely (ret != REG_NOERROR))
88 return ret; 88 return ret;
89 } 89 }
90 pstr->mbs = pstr->mbs_allocated ? pstr->mbs : (unsigned char *) str; 90 pstr->mbs = pstr->mbs_allocated ? pstr->mbs : (unsigned char *) str;
@@ -97,14 +97,14 @@ re_string_construct (re_string_t *pstr, const char *str, Idx len,
97 while (1) 97 while (1)
98 { 98 {
99 ret = build_wcs_upper_buffer (pstr); 99 ret = build_wcs_upper_buffer (pstr);
100 if (BE (ret != REG_NOERROR, 0)) 100 if (__glibc_unlikely (ret != REG_NOERROR))
101 return ret; 101 return ret;
102 if (pstr->valid_raw_len >= len) 102 if (pstr->valid_raw_len >= len)
103 break; 103 break;
104 if (pstr->bufs_len > pstr->valid_len + dfa->mb_cur_max) 104 if (pstr->bufs_len > pstr->valid_len + dfa->mb_cur_max)
105 break; 105 break;
106 ret = re_string_realloc_buffers (pstr, pstr->bufs_len * 2); 106 ret = re_string_realloc_buffers (pstr, pstr->bufs_len * 2);
107 if (BE (ret != REG_NOERROR, 0)) 107 if (__glibc_unlikely (ret != REG_NOERROR))
108 return ret; 108 return ret;
109 } 109 }
110 } 110 }
@@ -146,17 +146,18 @@ re_string_realloc_buffers (re_string_t *pstr, Idx new_buf_len)
146 146
147 /* Avoid overflow in realloc. */ 147 /* Avoid overflow in realloc. */
148 const size_t max_object_size = MAX (sizeof (wint_t), sizeof (Idx)); 148 const size_t max_object_size = MAX (sizeof (wint_t), sizeof (Idx));
149 if (BE (MIN (IDX_MAX, SIZE_MAX / max_object_size) < new_buf_len, 0)) 149 if (__glibc_unlikely (MIN (IDX_MAX, SIZE_MAX / max_object_size)
150 < new_buf_len))
150 return REG_ESPACE; 151 return REG_ESPACE;
151 152
152 new_wcs = re_realloc (pstr->wcs, wint_t, new_buf_len); 153 new_wcs = re_realloc (pstr->wcs, wint_t, new_buf_len);
153 if (BE (new_wcs == NULL, 0)) 154 if (__glibc_unlikely (new_wcs == NULL))
154 return REG_ESPACE; 155 return REG_ESPACE;
155 pstr->wcs = new_wcs; 156 pstr->wcs = new_wcs;
156 if (pstr->offsets != NULL) 157 if (pstr->offsets != NULL)
157 { 158 {
158 Idx *new_offsets = re_realloc (pstr->offsets, Idx, new_buf_len); 159 Idx *new_offsets = re_realloc (pstr->offsets, Idx, new_buf_len);
159 if (BE (new_offsets == NULL, 0)) 160 if (__glibc_unlikely (new_offsets == NULL))
160 return REG_ESPACE; 161 return REG_ESPACE;
161 pstr->offsets = new_offsets; 162 pstr->offsets = new_offsets;
162 } 163 }
@@ -166,7 +167,7 @@ re_string_realloc_buffers (re_string_t *pstr, Idx new_buf_len)
166 { 167 {
167 unsigned char *new_mbs = re_realloc (pstr->mbs, unsigned char, 168 unsigned char *new_mbs = re_realloc (pstr->mbs, unsigned char,
168 new_buf_len); 169 new_buf_len);
169 if (BE (new_mbs == NULL, 0)) 170 if (__glibc_unlikely (new_mbs == NULL))
170 return REG_ESPACE; 171 return REG_ESPACE;
171 pstr->mbs = new_mbs; 172 pstr->mbs = new_mbs;
172 } 173 }
@@ -230,7 +231,7 @@ build_wcs_buffer (re_string_t *pstr)
230 remain_len = end_idx - byte_idx; 231 remain_len = end_idx - byte_idx;
231 prev_st = pstr->cur_state; 232 prev_st = pstr->cur_state;
232 /* Apply the translation if we need. */ 233 /* Apply the translation if we need. */
233 if (BE (pstr->trans != NULL, 0)) 234 if (__glibc_unlikely (pstr->trans != NULL))
234 { 235 {
235 int i, ch; 236 int i, ch;
236 237
@@ -244,17 +245,18 @@ build_wcs_buffer (re_string_t *pstr)
244 else 245 else
245 p = (const char *) pstr->raw_mbs + pstr->raw_mbs_idx + byte_idx; 246 p = (const char *) pstr->raw_mbs + pstr->raw_mbs_idx + byte_idx;
246 mbclen = __mbrtowc (&wc, p, remain_len, &pstr->cur_state); 247 mbclen = __mbrtowc (&wc, p, remain_len, &pstr->cur_state);
247 if (BE (mbclen == (size_t) -1 || mbclen == 0 248 if (__glibc_unlikely (mbclen == (size_t) -1 || mbclen == 0
248 || (mbclen == (size_t) -2 && pstr->bufs_len >= pstr->len), 0)) 249 || (mbclen == (size_t) -2
250 && pstr->bufs_len >= pstr->len)))
249 { 251 {
250 /* We treat these cases as a singlebyte character. */ 252 /* We treat these cases as a singlebyte character. */
251 mbclen = 1; 253 mbclen = 1;
252 wc = (wchar_t) pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx]; 254 wc = (wchar_t) pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx];
253 if (BE (pstr->trans != NULL, 0)) 255 if (__glibc_unlikely (pstr->trans != NULL))
254 wc = pstr->trans[wc]; 256 wc = pstr->trans[wc];
255 pstr->cur_state = prev_st; 257 pstr->cur_state = prev_st;
256 } 258 }
257 else if (BE (mbclen == (size_t) -2, 0)) 259 else if (__glibc_unlikely (mbclen == (size_t) -2))
258 { 260 {
259 /* The buffer doesn't have enough space, finish to build. */ 261 /* The buffer doesn't have enough space, finish to build. */
260 pstr->cur_state = prev_st; 262 pstr->cur_state = prev_st;
@@ -317,7 +319,7 @@ build_wcs_upper_buffer (re_string_t *pstr)
317 mbclen = __mbrtowc (&wc, 319 mbclen = __mbrtowc (&wc,
318 ((const char *) pstr->raw_mbs + pstr->raw_mbs_idx 320 ((const char *) pstr->raw_mbs + pstr->raw_mbs_idx
319 + byte_idx), remain_len, &pstr->cur_state); 321 + byte_idx), remain_len, &pstr->cur_state);
320 if (BE (0 < mbclen && mbclen < (size_t) -2, 1)) 322 if (__glibc_likely (0 < mbclen && mbclen < (size_t) -2))
321 { 323 {
322 wchar_t wcu = __towupper (wc); 324 wchar_t wcu = __towupper (wc);
323 if (wcu != wc) 325 if (wcu != wc)
@@ -325,7 +327,7 @@ build_wcs_upper_buffer (re_string_t *pstr)
325 size_t mbcdlen; 327 size_t mbcdlen;
326 328
327 mbcdlen = __wcrtomb (buf, wcu, &prev_st); 329 mbcdlen = __wcrtomb (buf, wcu, &prev_st);
328 if (BE (mbclen == mbcdlen, 1)) 330 if (__glibc_likely (mbclen == mbcdlen))
329 memcpy (pstr->mbs + byte_idx, buf, mbclen); 331 memcpy (pstr->mbs + byte_idx, buf, mbclen);
330 else 332 else
331 { 333 {
@@ -350,7 +352,7 @@ build_wcs_upper_buffer (re_string_t *pstr)
350 pstr->mbs[byte_idx] = ch; 352 pstr->mbs[byte_idx] = ch;
351 /* And also cast it to wide char. */ 353 /* And also cast it to wide char. */
352 pstr->wcs[byte_idx++] = (wchar_t) ch; 354 pstr->wcs[byte_idx++] = (wchar_t) ch;
353 if (BE (mbclen == (size_t) -1, 0)) 355 if (__glibc_unlikely (mbclen == (size_t) -1))
354 pstr->cur_state = prev_st; 356 pstr->cur_state = prev_st;
355 } 357 }
356 else 358 else
@@ -372,7 +374,7 @@ build_wcs_upper_buffer (re_string_t *pstr)
372 offsets_needed: 374 offsets_needed:
373 remain_len = end_idx - byte_idx; 375 remain_len = end_idx - byte_idx;
374 prev_st = pstr->cur_state; 376 prev_st = pstr->cur_state;
375 if (BE (pstr->trans != NULL, 0)) 377 if (__glibc_unlikely (pstr->trans != NULL))
376 { 378 {
377 int i, ch; 379 int i, ch;
378 380
@@ -386,7 +388,7 @@ build_wcs_upper_buffer (re_string_t *pstr)
386 else 388 else
387 p = (const char *) pstr->raw_mbs + pstr->raw_mbs_idx + src_idx; 389 p = (const char *) pstr->raw_mbs + pstr->raw_mbs_idx + src_idx;
388 mbclen = __mbrtowc (&wc, p, remain_len, &pstr->cur_state); 390 mbclen = __mbrtowc (&wc, p, remain_len, &pstr->cur_state);
389 if (BE (0 < mbclen && mbclen < (size_t) -2, 1)) 391 if (__glibc_likely (0 < mbclen && mbclen < (size_t) -2))
390 { 392 {
391 wchar_t wcu = __towupper (wc); 393 wchar_t wcu = __towupper (wc);
392 if (wcu != wc) 394 if (wcu != wc)
@@ -394,7 +396,7 @@ build_wcs_upper_buffer (re_string_t *pstr)
394 size_t mbcdlen; 396 size_t mbcdlen;
395 397
396 mbcdlen = __wcrtomb ((char *) buf, wcu, &prev_st); 398 mbcdlen = __wcrtomb ((char *) buf, wcu, &prev_st);
397 if (BE (mbclen == mbcdlen, 1)) 399 if (__glibc_likely (mbclen == mbcdlen))
398 memcpy (pstr->mbs + byte_idx, buf, mbclen); 400 memcpy (pstr->mbs + byte_idx, buf, mbclen);
399 else if (mbcdlen != (size_t) -1) 401 else if (mbcdlen != (size_t) -1)
400 { 402 {
@@ -444,7 +446,7 @@ build_wcs_upper_buffer (re_string_t *pstr)
444 else 446 else
445 memcpy (pstr->mbs + byte_idx, p, mbclen); 447 memcpy (pstr->mbs + byte_idx, p, mbclen);
446 448
447 if (BE (pstr->offsets_needed != 0, 0)) 449 if (__glibc_unlikely (pstr->offsets_needed != 0))
448 { 450 {
449 size_t i; 451 size_t i;
450 for (i = 0; i < mbclen; ++i) 452 for (i = 0; i < mbclen; ++i)
@@ -463,17 +465,17 @@ build_wcs_upper_buffer (re_string_t *pstr)
463 /* It is an invalid character or '\0'. Just use the byte. */ 465 /* It is an invalid character or '\0'. Just use the byte. */
464 int ch = pstr->raw_mbs[pstr->raw_mbs_idx + src_idx]; 466 int ch = pstr->raw_mbs[pstr->raw_mbs_idx + src_idx];
465 467
466 if (BE (pstr->trans != NULL, 0)) 468 if (__glibc_unlikely (pstr->trans != NULL))
467 ch = pstr->trans [ch]; 469 ch = pstr->trans [ch];
468 pstr->mbs[byte_idx] = ch; 470 pstr->mbs[byte_idx] = ch;
469 471
470 if (BE (pstr->offsets_needed != 0, 0)) 472 if (__glibc_unlikely (pstr->offsets_needed != 0))
471 pstr->offsets[byte_idx] = src_idx; 473 pstr->offsets[byte_idx] = src_idx;
472 ++src_idx; 474 ++src_idx;
473 475
474 /* And also cast it to wide char. */ 476 /* And also cast it to wide char. */
475 pstr->wcs[byte_idx++] = (wchar_t) ch; 477 pstr->wcs[byte_idx++] = (wchar_t) ch;
476 if (BE (mbclen == (size_t) -1, 0)) 478 if (__glibc_unlikely (mbclen == (size_t) -1))
477 pstr->cur_state = prev_st; 479 pstr->cur_state = prev_st;
478 } 480 }
479 else 481 else
@@ -508,7 +510,8 @@ re_string_skip_chars (re_string_t *pstr, Idx new_raw_idx, wint_t *last_wc)
508 prev_st = pstr->cur_state; 510 prev_st = pstr->cur_state;
509 mbclen = __mbrtowc (&wc2, (const char *) pstr->raw_mbs + rawbuf_idx, 511 mbclen = __mbrtowc (&wc2, (const char *) pstr->raw_mbs + rawbuf_idx,
510 remain_len, &pstr->cur_state); 512 remain_len, &pstr->cur_state);
511 if (BE (mbclen == (size_t) -2 || mbclen == (size_t) -1 || mbclen == 0, 0)) 513 if (__glibc_unlikely (mbclen == (size_t) -2 || mbclen == (size_t) -1
514 || mbclen == 0))
512 { 515 {
513 /* We treat these cases as a single byte character. */ 516 /* We treat these cases as a single byte character. */
514 if (mbclen == 0 || remain_len == 0) 517 if (mbclen == 0 || remain_len == 0)
@@ -540,7 +543,7 @@ build_upper_buffer (re_string_t *pstr)
540 for (char_idx = pstr->valid_len; char_idx < end_idx; ++char_idx) 543 for (char_idx = pstr->valid_len; char_idx < end_idx; ++char_idx)
541 { 544 {
542 int ch = pstr->raw_mbs[pstr->raw_mbs_idx + char_idx]; 545 int ch = pstr->raw_mbs[pstr->raw_mbs_idx + char_idx];
543 if (BE (pstr->trans != NULL, 0)) 546 if (__glibc_unlikely (pstr->trans != NULL))
544 ch = pstr->trans[ch]; 547 ch = pstr->trans[ch];
545 pstr->mbs[char_idx] = toupper (ch); 548 pstr->mbs[char_idx] = toupper (ch);
546 } 549 }
@@ -576,7 +579,7 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
576{ 579{
577 Idx offset; 580 Idx offset;
578 581
579 if (BE (pstr->raw_mbs_idx <= idx, 0)) 582 if (__glibc_unlikely (pstr->raw_mbs_idx <= idx))
580 offset = idx - pstr->raw_mbs_idx; 583 offset = idx - pstr->raw_mbs_idx;
581 else 584 else
582 { 585 {
@@ -598,14 +601,14 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
598 offset = idx; 601 offset = idx;
599 } 602 }
600 603
601 if (BE (offset != 0, 1)) 604 if (__glibc_likely (offset != 0))
602 { 605 {
603 /* Should the already checked characters be kept? */ 606 /* Should the already checked characters be kept? */
604 if (BE (offset < pstr->valid_raw_len, 1)) 607 if (__glibc_likely (offset < pstr->valid_raw_len))
605 { 608 {
606 /* Yes, move them to the front of the buffer. */ 609 /* Yes, move them to the front of the buffer. */
607#ifdef RE_ENABLE_I18N 610#ifdef RE_ENABLE_I18N
608 if (BE (pstr->offsets_needed, 0)) 611 if (__glibc_unlikely (pstr->offsets_needed))
609 { 612 {
610 Idx low = 0, high = pstr->valid_len, mid; 613 Idx low = 0, high = pstr->valid_len, mid;
611 do 614 do
@@ -677,7 +680,7 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
677 memmove (pstr->wcs, pstr->wcs + offset, 680 memmove (pstr->wcs, pstr->wcs + offset,
678 (pstr->valid_len - offset) * sizeof (wint_t)); 681 (pstr->valid_len - offset) * sizeof (wint_t));
679#endif /* RE_ENABLE_I18N */ 682#endif /* RE_ENABLE_I18N */
680 if (BE (pstr->mbs_allocated, 0)) 683 if (__glibc_unlikely (pstr->mbs_allocated))
681 memmove (pstr->mbs, pstr->mbs + offset, 684 memmove (pstr->mbs, pstr->mbs + offset,
682 pstr->valid_len - offset); 685 pstr->valid_len - offset);
683 pstr->valid_len -= offset; 686 pstr->valid_len -= offset;
@@ -693,7 +696,7 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
693 /* No, skip all characters until IDX. */ 696 /* No, skip all characters until IDX. */
694 Idx prev_valid_len = pstr->valid_len; 697 Idx prev_valid_len = pstr->valid_len;
695 698
696 if (BE (pstr->offsets_needed, 0)) 699 if (__glibc_unlikely (pstr->offsets_needed))
697 { 700 {
698 pstr->len = pstr->raw_len - idx + offset; 701 pstr->len = pstr->raw_len - idx + offset;
699 pstr->stop = pstr->raw_stop - idx + offset; 702 pstr->stop = pstr->raw_stop - idx + offset;
@@ -721,7 +724,7 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
721#ifdef _LIBC 724#ifdef _LIBC
722 /* We know the wchar_t encoding is UCS4, so for the simple 725 /* We know the wchar_t encoding is UCS4, so for the simple
723 case, ASCII characters, skip the conversion step. */ 726 case, ASCII characters, skip the conversion step. */
724 if (isascii (*p) && BE (pstr->trans == NULL, 1)) 727 if (isascii (*p) && __glibc_likely (pstr->trans == NULL))
725 { 728 {
726 memset (&pstr->cur_state, '\0', sizeof (mbstate_t)); 729 memset (&pstr->cur_state, '\0', sizeof (mbstate_t));
727 /* pstr->valid_len = 0; */ 730 /* pstr->valid_len = 0; */
@@ -739,7 +742,7 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
739 size_t mbclen; 742 size_t mbclen;
740 743
741 const unsigned char *pp = p; 744 const unsigned char *pp = p;
742 if (BE (pstr->trans != NULL, 0)) 745 if (__glibc_unlikely (pstr->trans != NULL))
743 { 746 {
744 int i = mlen < 6 ? mlen : 6; 747 int i = mlen < 6 ? mlen : 6;
745 while (--i >= 0) 748 while (--i >= 0)
@@ -769,13 +772,13 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
769 pstr->tip_context 772 pstr->tip_context
770 = re_string_context_at (pstr, prev_valid_len - 1, eflags); 773 = re_string_context_at (pstr, prev_valid_len - 1, eflags);
771 else 774 else
772 pstr->tip_context = ((BE (pstr->word_ops_used != 0, 0) 775 pstr->tip_context = ((__glibc_unlikely (pstr->word_ops_used != 0)
773 && IS_WIDE_WORD_CHAR (wc)) 776 && IS_WIDE_WORD_CHAR (wc))
774 ? CONTEXT_WORD 777 ? CONTEXT_WORD
775 : ((IS_WIDE_NEWLINE (wc) 778 : ((IS_WIDE_NEWLINE (wc)
776 && pstr->newline_anchor) 779 && pstr->newline_anchor)
777 ? CONTEXT_NEWLINE : 0)); 780 ? CONTEXT_NEWLINE : 0));
778 if (BE (pstr->valid_len, 0)) 781 if (__glibc_unlikely (pstr->valid_len))
779 { 782 {
780 for (wcs_idx = 0; wcs_idx < pstr->valid_len; ++wcs_idx) 783 for (wcs_idx = 0; wcs_idx < pstr->valid_len; ++wcs_idx)
781 pstr->wcs[wcs_idx] = WEOF; 784 pstr->wcs[wcs_idx] = WEOF;
@@ -797,7 +800,7 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
797 ? CONTEXT_NEWLINE : 0)); 800 ? CONTEXT_NEWLINE : 0));
798 } 801 }
799 } 802 }
800 if (!BE (pstr->mbs_allocated, 0)) 803 if (!__glibc_unlikely (pstr->mbs_allocated))
801 pstr->mbs += offset; 804 pstr->mbs += offset;
802 } 805 }
803 pstr->raw_mbs_idx = idx; 806 pstr->raw_mbs_idx = idx;
@@ -811,7 +814,7 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
811 if (pstr->icase) 814 if (pstr->icase)
812 { 815 {
813 reg_errcode_t ret = build_wcs_upper_buffer (pstr); 816 reg_errcode_t ret = build_wcs_upper_buffer (pstr);
814 if (BE (ret != REG_NOERROR, 0)) 817 if (__glibc_unlikely (ret != REG_NOERROR))
815 return ret; 818 return ret;
816 } 819 }
817 else 820 else
@@ -819,7 +822,7 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
819 } 822 }
820 else 823 else
821#endif /* RE_ENABLE_I18N */ 824#endif /* RE_ENABLE_I18N */
822 if (BE (pstr->mbs_allocated, 0)) 825 if (__glibc_unlikely (pstr->mbs_allocated))
823 { 826 {
824 if (pstr->icase) 827 if (pstr->icase)
825 build_upper_buffer (pstr); 828 build_upper_buffer (pstr);
@@ -841,7 +844,7 @@ re_string_peek_byte_case (const re_string_t *pstr, Idx idx)
841 Idx off; 844 Idx off;
842 845
843 /* Handle the common (easiest) cases first. */ 846 /* Handle the common (easiest) cases first. */
844 if (BE (!pstr->mbs_allocated, 1)) 847 if (__glibc_likely (!pstr->mbs_allocated))
845 return re_string_peek_byte (pstr, idx); 848 return re_string_peek_byte (pstr, idx);
846 849
847#ifdef RE_ENABLE_I18N 850#ifdef RE_ENABLE_I18N
@@ -873,7 +876,7 @@ re_string_peek_byte_case (const re_string_t *pstr, Idx idx)
873static unsigned char 876static unsigned char
874re_string_fetch_byte_case (re_string_t *pstr) 877re_string_fetch_byte_case (re_string_t *pstr)
875{ 878{
876 if (BE (!pstr->mbs_allocated, 1)) 879 if (__glibc_likely (!pstr->mbs_allocated))
877 return re_string_fetch_byte (pstr); 880 return re_string_fetch_byte (pstr);
878 881
879#ifdef RE_ENABLE_I18N 882#ifdef RE_ENABLE_I18N
@@ -924,11 +927,11 @@ static unsigned int
924re_string_context_at (const re_string_t *input, Idx idx, int eflags) 927re_string_context_at (const re_string_t *input, Idx idx, int eflags)
925{ 928{
926 int c; 929 int c;
927 if (BE (idx < 0, 0)) 930 if (__glibc_unlikely (idx < 0))
928 /* In this case, we use the value stored in input->tip_context, 931 /* In this case, we use the value stored in input->tip_context,
929 since we can't know the character in input->mbs[-1] here. */ 932 since we can't know the character in input->mbs[-1] here. */
930 return input->tip_context; 933 return input->tip_context;
931 if (BE (idx == input->len, 0)) 934 if (__glibc_unlikely (idx == input->len))
932 return ((eflags & REG_NOTEOL) ? CONTEXT_ENDBUF 935 return ((eflags & REG_NOTEOL) ? CONTEXT_ENDBUF
933 : CONTEXT_NEWLINE | CONTEXT_ENDBUF); 936 : CONTEXT_NEWLINE | CONTEXT_ENDBUF);
934#ifdef RE_ENABLE_I18N 937#ifdef RE_ENABLE_I18N
@@ -947,7 +950,8 @@ re_string_context_at (const re_string_t *input, Idx idx, int eflags)
947 return input->tip_context; 950 return input->tip_context;
948 } 951 }
949 wc = input->wcs[wc_idx]; 952 wc = input->wcs[wc_idx];
950 if (BE (input->word_ops_used != 0, 0) && IS_WIDE_WORD_CHAR (wc)) 953 if (__glibc_unlikely (input->word_ops_used != 0)
954 && IS_WIDE_WORD_CHAR (wc))
951 return CONTEXT_WORD; 955 return CONTEXT_WORD;
952 return (IS_WIDE_NEWLINE (wc) && input->newline_anchor 956 return (IS_WIDE_NEWLINE (wc) && input->newline_anchor
953 ? CONTEXT_NEWLINE : 0); 957 ? CONTEXT_NEWLINE : 0);
@@ -971,7 +975,8 @@ re_node_set_alloc (re_node_set *set, Idx size)
971 set->alloc = size; 975 set->alloc = size;
972 set->nelem = 0; 976 set->nelem = 0;
973 set->elems = re_malloc (Idx, size); 977 set->elems = re_malloc (Idx, size);
974 if (BE (set->elems == NULL, 0) && (MALLOC_0_IS_NONNULL || size != 0)) 978 if (__glibc_unlikely (set->elems == NULL)
979 && (MALLOC_0_IS_NONNULL || size != 0))
975 return REG_ESPACE; 980 return REG_ESPACE;
976 return REG_NOERROR; 981 return REG_NOERROR;
977} 982}
@@ -983,7 +988,7 @@ re_node_set_init_1 (re_node_set *set, Idx elem)
983 set->alloc = 1; 988 set->alloc = 1;
984 set->nelem = 1; 989 set->nelem = 1;
985 set->elems = re_malloc (Idx, 1); 990 set->elems = re_malloc (Idx, 1);
986 if (BE (set->elems == NULL, 0)) 991 if (__glibc_unlikely (set->elems == NULL))
987 { 992 {
988 set->alloc = set->nelem = 0; 993 set->alloc = set->nelem = 0;
989 return REG_ESPACE; 994 return REG_ESPACE;
@@ -998,7 +1003,7 @@ re_node_set_init_2 (re_node_set *set, Idx elem1, Idx elem2)
998{ 1003{
999 set->alloc = 2; 1004 set->alloc = 2;
1000 set->elems = re_malloc (Idx, 2); 1005 set->elems = re_malloc (Idx, 2);
1001 if (BE (set->elems == NULL, 0)) 1006 if (__glibc_unlikely (set->elems == NULL))
1002 return REG_ESPACE; 1007 return REG_ESPACE;
1003 if (elem1 == elem2) 1008 if (elem1 == elem2)
1004 { 1009 {
@@ -1031,7 +1036,7 @@ re_node_set_init_copy (re_node_set *dest, const re_node_set *src)
1031 { 1036 {
1032 dest->alloc = dest->nelem; 1037 dest->alloc = dest->nelem;
1033 dest->elems = re_malloc (Idx, dest->alloc); 1038 dest->elems = re_malloc (Idx, dest->alloc);
1034 if (BE (dest->elems == NULL, 0)) 1039 if (__glibc_unlikely (dest->elems == NULL))
1035 { 1040 {
1036 dest->alloc = dest->nelem = 0; 1041 dest->alloc = dest->nelem = 0;
1037 return REG_ESPACE; 1042 return REG_ESPACE;
@@ -1062,7 +1067,7 @@ re_node_set_add_intersect (re_node_set *dest, const re_node_set *src1,
1062 { 1067 {
1063 Idx new_alloc = src1->nelem + src2->nelem + dest->alloc; 1068 Idx new_alloc = src1->nelem + src2->nelem + dest->alloc;
1064 Idx *new_elems = re_realloc (dest->elems, Idx, new_alloc); 1069 Idx *new_elems = re_realloc (dest->elems, Idx, new_alloc);
1065 if (BE (new_elems == NULL, 0)) 1070 if (__glibc_unlikely (new_elems == NULL))
1066 return REG_ESPACE; 1071 return REG_ESPACE;
1067 dest->elems = new_elems; 1072 dest->elems = new_elems;
1068 dest->alloc = new_alloc; 1073 dest->alloc = new_alloc;
@@ -1148,7 +1153,7 @@ re_node_set_init_union (re_node_set *dest, const re_node_set *src1,
1148 { 1153 {
1149 dest->alloc = src1->nelem + src2->nelem; 1154 dest->alloc = src1->nelem + src2->nelem;
1150 dest->elems = re_malloc (Idx, dest->alloc); 1155 dest->elems = re_malloc (Idx, dest->alloc);
1151 if (BE (dest->elems == NULL, 0)) 1156 if (__glibc_unlikely (dest->elems == NULL))
1152 return REG_ESPACE; 1157 return REG_ESPACE;
1153 } 1158 }
1154 else 1159 else
@@ -1202,13 +1207,13 @@ re_node_set_merge (re_node_set *dest, const re_node_set *src)
1202 { 1207 {
1203 Idx new_alloc = 2 * (src->nelem + dest->alloc); 1208 Idx new_alloc = 2 * (src->nelem + dest->alloc);
1204 Idx *new_buffer = re_realloc (dest->elems, Idx, new_alloc); 1209 Idx *new_buffer = re_realloc (dest->elems, Idx, new_alloc);
1205 if (BE (new_buffer == NULL, 0)) 1210 if (__glibc_unlikely (new_buffer == NULL))
1206 return REG_ESPACE; 1211 return REG_ESPACE;
1207 dest->elems = new_buffer; 1212 dest->elems = new_buffer;
1208 dest->alloc = new_alloc; 1213 dest->alloc = new_alloc;
1209 } 1214 }
1210 1215
1211 if (BE (dest->nelem == 0, 0)) 1216 if (__glibc_unlikely (dest->nelem == 0))
1212 { 1217 {
1213 dest->nelem = src->nelem; 1218 dest->nelem = src->nelem;
1214 memcpy (dest->elems, src->elems, src->nelem * sizeof (Idx)); 1219 memcpy (dest->elems, src->elems, src->nelem * sizeof (Idx));
@@ -1281,9 +1286,9 @@ re_node_set_insert (re_node_set *set, Idx elem)
1281 Idx idx; 1286 Idx idx;
1282 /* In case the set is empty. */ 1287 /* In case the set is empty. */
1283 if (set->alloc == 0) 1288 if (set->alloc == 0)
1284 return BE (re_node_set_init_1 (set, elem) == REG_NOERROR, 1); 1289 return __glibc_likely (re_node_set_init_1 (set, elem) == REG_NOERROR);
1285 1290
1286 if (BE (set->nelem, 0) == 0) 1291 if (__glibc_unlikely (set->nelem) == 0)
1287 { 1292 {
1288 /* We already guaranteed above that set->alloc != 0. */ 1293 /* We already guaranteed above that set->alloc != 0. */
1289 set->elems[0] = elem; 1294 set->elems[0] = elem;
@@ -1297,7 +1302,7 @@ re_node_set_insert (re_node_set *set, Idx elem)
1297 Idx *new_elems; 1302 Idx *new_elems;
1298 set->alloc = set->alloc * 2; 1303 set->alloc = set->alloc * 2;
1299 new_elems = re_realloc (set->elems, Idx, set->alloc); 1304 new_elems = re_realloc (set->elems, Idx, set->alloc);
1300 if (BE (new_elems == NULL, 0)) 1305 if (__glibc_unlikely (new_elems == NULL))
1301 return false; 1306 return false;
1302 set->elems = new_elems; 1307 set->elems = new_elems;
1303 } 1308 }
@@ -1336,7 +1341,7 @@ re_node_set_insert_last (re_node_set *set, Idx elem)
1336 Idx *new_elems; 1341 Idx *new_elems;
1337 set->alloc = (set->alloc + 1) * 2; 1342 set->alloc = (set->alloc + 1) * 2;
1338 new_elems = re_realloc (set->elems, Idx, set->alloc); 1343 new_elems = re_realloc (set->elems, Idx, set->alloc);
1339 if (BE (new_elems == NULL, 0)) 1344 if (__glibc_unlikely (new_elems == NULL))
1340 return false; 1345 return false;
1341 set->elems = new_elems; 1346 set->elems = new_elems;
1342 } 1347 }
@@ -1403,7 +1408,7 @@ re_node_set_remove_at (re_node_set *set, Idx idx)
1403static Idx 1408static Idx
1404re_dfa_add_node (re_dfa_t *dfa, re_token_t token) 1409re_dfa_add_node (re_dfa_t *dfa, re_token_t token)
1405{ 1410{
1406 if (BE (dfa->nodes_len >= dfa->nodes_alloc, 0)) 1411 if (__glibc_unlikely (dfa->nodes_len >= dfa->nodes_alloc))
1407 { 1412 {
1408 size_t new_nodes_alloc = dfa->nodes_alloc * 2; 1413 size_t new_nodes_alloc = dfa->nodes_alloc * 2;
1409 Idx *new_nexts, *new_indices; 1414 Idx *new_nexts, *new_indices;
@@ -1414,19 +1419,20 @@ re_dfa_add_node (re_dfa_t *dfa, re_token_t token)
1414 const size_t max_object_size = MAX (sizeof (re_token_t), 1419 const size_t max_object_size = MAX (sizeof (re_token_t),
1415 MAX (sizeof (re_node_set), 1420 MAX (sizeof (re_node_set),
1416 sizeof (Idx))); 1421 sizeof (Idx)));
1417 if (BE (MIN (IDX_MAX, SIZE_MAX / max_object_size) < new_nodes_alloc, 0)) 1422 if (__glibc_unlikely (MIN (IDX_MAX, SIZE_MAX / max_object_size)
1423 < new_nodes_alloc))
1418 return -1; 1424 return -1;
1419 1425
1420 new_nodes = re_realloc (dfa->nodes, re_token_t, new_nodes_alloc); 1426 new_nodes = re_realloc (dfa->nodes, re_token_t, new_nodes_alloc);
1421 if (BE (new_nodes == NULL, 0)) 1427 if (__glibc_unlikely (new_nodes == NULL))
1422 return -1; 1428 return -1;
1423 dfa->nodes = new_nodes; 1429 dfa->nodes = new_nodes;
1424 new_nexts = re_realloc (dfa->nexts, Idx, new_nodes_alloc); 1430 new_nexts = re_realloc (dfa->nexts, Idx, new_nodes_alloc);
1425 new_indices = re_realloc (dfa->org_indices, Idx, new_nodes_alloc); 1431 new_indices = re_realloc (dfa->org_indices, Idx, new_nodes_alloc);
1426 new_edests = re_realloc (dfa->edests, re_node_set, new_nodes_alloc); 1432 new_edests = re_realloc (dfa->edests, re_node_set, new_nodes_alloc);
1427 new_eclosures = re_realloc (dfa->eclosures, re_node_set, new_nodes_alloc); 1433 new_eclosures = re_realloc (dfa->eclosures, re_node_set, new_nodes_alloc);
1428 if (BE (new_nexts == NULL || new_indices == NULL 1434 if (__glibc_unlikely (new_nexts == NULL || new_indices == NULL
1429 || new_edests == NULL || new_eclosures == NULL, 0)) 1435 || new_edests == NULL || new_eclosures == NULL))
1430 { 1436 {
1431 re_free (new_nexts); 1437 re_free (new_nexts);
1432 re_free (new_indices); 1438 re_free (new_indices);
@@ -1485,7 +1491,7 @@ re_acquire_state (reg_errcode_t *err, const re_dfa_t *dfa,
1485 /* Suppress bogus uninitialized-variable warnings. */ 1491 /* Suppress bogus uninitialized-variable warnings. */
1486 *err = REG_NOERROR; 1492 *err = REG_NOERROR;
1487#endif 1493#endif
1488 if (BE (nodes->nelem == 0, 0)) 1494 if (__glibc_unlikely (nodes->nelem == 0))
1489 { 1495 {
1490 *err = REG_NOERROR; 1496 *err = REG_NOERROR;
1491 return NULL; 1497 return NULL;
@@ -1504,7 +1510,7 @@ re_acquire_state (reg_errcode_t *err, const re_dfa_t *dfa,
1504 1510
1505 /* There are no appropriate state in the dfa, create the new one. */ 1511 /* There are no appropriate state in the dfa, create the new one. */
1506 new_state = create_ci_newstate (dfa, nodes, hash); 1512 new_state = create_ci_newstate (dfa, nodes, hash);
1507 if (BE (new_state == NULL, 0)) 1513 if (__glibc_unlikely (new_state == NULL))
1508 *err = REG_ESPACE; 1514 *err = REG_ESPACE;
1509 1515
1510 return new_state; 1516 return new_state;
@@ -1551,7 +1557,7 @@ re_acquire_state_context (reg_errcode_t *err, const re_dfa_t *dfa,
1551 } 1557 }
1552 /* There are no appropriate state in 'dfa', create the new one. */ 1558 /* There are no appropriate state in 'dfa', create the new one. */
1553 new_state = create_cd_newstate (dfa, nodes, context, hash); 1559 new_state = create_cd_newstate (dfa, nodes, context, hash);
1554 if (BE (new_state == NULL, 0)) 1560 if (__glibc_unlikely (new_state == NULL))
1555 *err = REG_ESPACE; 1561 *err = REG_ESPACE;
1556 1562
1557 return new_state; 1563 return new_state;
@@ -1572,7 +1578,7 @@ register_state (const re_dfa_t *dfa, re_dfastate_t *newstate,
1572 1578
1573 newstate->hash = hash; 1579 newstate->hash = hash;
1574 err = re_node_set_alloc (&newstate->non_eps_nodes, newstate->nodes.nelem); 1580 err = re_node_set_alloc (&newstate->non_eps_nodes, newstate->nodes.nelem);
1575 if (BE (err != REG_NOERROR, 0)) 1581 if (__glibc_unlikely (err != REG_NOERROR))
1576 return REG_ESPACE; 1582 return REG_ESPACE;
1577 for (i = 0; i < newstate->nodes.nelem; i++) 1583 for (i = 0; i < newstate->nodes.nelem; i++)
1578 { 1584 {
@@ -1583,12 +1589,12 @@ register_state (const re_dfa_t *dfa, re_dfastate_t *newstate,
1583 } 1589 }
1584 1590
1585 spot = dfa->state_table + (hash & dfa->state_hash_mask); 1591 spot = dfa->state_table + (hash & dfa->state_hash_mask);
1586 if (BE (spot->alloc <= spot->num, 0)) 1592 if (__glibc_unlikely (spot->alloc <= spot->num))
1587 { 1593 {
1588 Idx new_alloc = 2 * spot->num + 2; 1594 Idx new_alloc = 2 * spot->num + 2;
1589 re_dfastate_t **new_array = re_realloc (spot->array, re_dfastate_t *, 1595 re_dfastate_t **new_array = re_realloc (spot->array, re_dfastate_t *,
1590 new_alloc); 1596 new_alloc);
1591 if (BE (new_array == NULL, 0)) 1597 if (__glibc_unlikely (new_array == NULL))
1592 return REG_ESPACE; 1598 return REG_ESPACE;
1593 spot->array = new_array; 1599 spot->array = new_array;
1594 spot->alloc = new_alloc; 1600 spot->alloc = new_alloc;
@@ -1626,10 +1632,10 @@ create_ci_newstate (const re_dfa_t *dfa, const re_node_set *nodes,
1626 re_dfastate_t *newstate; 1632 re_dfastate_t *newstate;
1627 1633
1628 newstate = (re_dfastate_t *) calloc (sizeof (re_dfastate_t), 1); 1634 newstate = (re_dfastate_t *) calloc (sizeof (re_dfastate_t), 1);
1629 if (BE (newstate == NULL, 0)) 1635 if (__glibc_unlikely (newstate == NULL))
1630 return NULL; 1636 return NULL;
1631 err = re_node_set_init_copy (&newstate->nodes, nodes); 1637 err = re_node_set_init_copy (&newstate->nodes, nodes);
1632 if (BE (err != REG_NOERROR, 0)) 1638 if (__glibc_unlikely (err != REG_NOERROR))
1633 { 1639 {
1634 re_free (newstate); 1640 re_free (newstate);
1635 return NULL; 1641 return NULL;
@@ -1655,7 +1661,7 @@ create_ci_newstate (const re_dfa_t *dfa, const re_node_set *nodes,
1655 newstate->has_constraint = 1; 1661 newstate->has_constraint = 1;
1656 } 1662 }
1657 err = register_state (dfa, newstate, hash); 1663 err = register_state (dfa, newstate, hash);
1658 if (BE (err != REG_NOERROR, 0)) 1664 if (__glibc_unlikely (err != REG_NOERROR))
1659 { 1665 {
1660 free_state (newstate); 1666 free_state (newstate);
1661 newstate = NULL; 1667 newstate = NULL;
@@ -1676,10 +1682,10 @@ create_cd_newstate (const re_dfa_t *dfa, const re_node_set *nodes,
1676 re_dfastate_t *newstate; 1682 re_dfastate_t *newstate;
1677 1683
1678 newstate = (re_dfastate_t *) calloc (sizeof (re_dfastate_t), 1); 1684 newstate = (re_dfastate_t *) calloc (sizeof (re_dfastate_t), 1);
1679 if (BE (newstate == NULL, 0)) 1685 if (__glibc_unlikely (newstate == NULL))
1680 return NULL; 1686 return NULL;
1681 err = re_node_set_init_copy (&newstate->nodes, nodes); 1687 err = re_node_set_init_copy (&newstate->nodes, nodes);
1682 if (BE (err != REG_NOERROR, 0)) 1688 if (__glibc_unlikely (err != REG_NOERROR))
1683 { 1689 {
1684 re_free (newstate); 1690 re_free (newstate);
1685 return NULL; 1691 return NULL;
@@ -1711,7 +1717,7 @@ create_cd_newstate (const re_dfa_t *dfa, const re_node_set *nodes,
1711 if (newstate->entrance_nodes == &newstate->nodes) 1717 if (newstate->entrance_nodes == &newstate->nodes)
1712 { 1718 {
1713 newstate->entrance_nodes = re_malloc (re_node_set, 1); 1719 newstate->entrance_nodes = re_malloc (re_node_set, 1);
1714 if (BE (newstate->entrance_nodes == NULL, 0)) 1720 if (__glibc_unlikely (newstate->entrance_nodes == NULL))
1715 { 1721 {
1716 free_state (newstate); 1722 free_state (newstate);
1717 return NULL; 1723 return NULL;
@@ -1731,7 +1737,7 @@ create_cd_newstate (const re_dfa_t *dfa, const re_node_set *nodes,
1731 } 1737 }
1732 } 1738 }
1733 err = register_state (dfa, newstate, hash); 1739 err = register_state (dfa, newstate, hash);
1734 if (BE (err != REG_NOERROR, 0)) 1740 if (__glibc_unlikely (err != REG_NOERROR))
1735 { 1741 {
1736 free_state (newstate); 1742 free_state (newstate);
1737 newstate = NULL; 1743 newstate = NULL;
diff --git a/lib/regex_internal.h b/lib/regex_internal.h
index dd0900b719f..b0e49cd828f 100644
--- a/lib/regex_internal.h
+++ b/lib/regex_internal.h
@@ -33,23 +33,7 @@
33#include <stdbool.h> 33#include <stdbool.h>
34#include <stdint.h> 34#include <stdint.h>
35 35
36/* Properties of integers. Although Gnulib has intprops.h, glibc does 36#include <intprops.h>
37 without for now. */
38#ifndef _LIBC
39# include "intprops.h"
40#else
41/* True if the real type T is signed. */
42# define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
43
44/* True if adding the nonnegative Idx values A and B would overflow.
45 If false, set *R to A + B. A, B, and R may be evaluated more than
46 once, or zero times. Although this is not a full implementation of
47 Gnulib INT_ADD_WRAPV, it is good enough for glibc regex code.
48 FIXME: This implementation is a fragile stopgap, and this file would
49 be simpler and more robust if intprops.h were migrated into glibc. */
50# define INT_ADD_WRAPV(a, b, r) \
51 (IDX_MAX - (a) < (b) ? true : (*(r) = (a) + (b), false))
52#endif
53 37
54#ifdef _LIBC 38#ifdef _LIBC
55# include <libc-lock.h> 39# include <libc-lock.h>
@@ -132,8 +116,6 @@
132# define RE_ENABLE_I18N 116# define RE_ENABLE_I18N
133#endif 117#endif
134 118
135#define BE(expr, val) __builtin_expect (expr, val)
136
137/* Number of ASCII characters. */ 119/* Number of ASCII characters. */
138#define ASCII_CHARS 0x80 120#define ASCII_CHARS 0x80
139 121
diff --git a/lib/regexec.c b/lib/regexec.c
index 65913111644..8b82ea50d44 100644
--- a/lib/regexec.c
+++ b/lib/regexec.c
@@ -328,9 +328,8 @@ re_search_2_stub (struct re_pattern_buffer *bufp, const char *string1,
328 Idx len; 328 Idx len;
329 char *s = NULL; 329 char *s = NULL;
330 330
331 if (BE ((length1 < 0 || length2 < 0 || stop < 0 331 if (__glibc_unlikely ((length1 < 0 || length2 < 0 || stop < 0
332 || INT_ADD_WRAPV (length1, length2, &len)), 332 || INT_ADD_WRAPV (length1, length2, &len))))
333 0))
334 return -2; 333 return -2;
335 334
336 /* Concatenate the strings. */ 335 /* Concatenate the strings. */
@@ -339,7 +338,7 @@ re_search_2_stub (struct re_pattern_buffer *bufp, const char *string1,
339 { 338 {
340 s = re_malloc (char, len); 339 s = re_malloc (char, len);
341 340
342 if (BE (s == NULL, 0)) 341 if (__glibc_unlikely (s == NULL))
343 return -2; 342 return -2;
344#ifdef _LIBC 343#ifdef _LIBC
345 memcpy (__mempcpy (s, string1, length1), string2, length2); 344 memcpy (__mempcpy (s, string1, length1), string2, length2);
@@ -379,11 +378,13 @@ re_search_stub (struct re_pattern_buffer *bufp, const char *string, Idx length,
379 Idx last_start = start + range; 378 Idx last_start = start + range;
380 379
381 /* Check for out-of-range. */ 380 /* Check for out-of-range. */
382 if (BE (start < 0 || start > length, 0)) 381 if (__glibc_unlikely (start < 0 || start > length))
383 return -1; 382 return -1;
384 if (BE (length < last_start || (0 <= range && last_start < start), 0)) 383 if (__glibc_unlikely (length < last_start
384 || (0 <= range && last_start < start)))
385 last_start = length; 385 last_start = length;
386 else if (BE (last_start < 0 || (range < 0 && start <= last_start), 0)) 386 else if (__glibc_unlikely (last_start < 0
387 || (range < 0 && start <= last_start)))
387 last_start = 0; 388 last_start = 0;
388 389
389 lock_lock (dfa->lock); 390 lock_lock (dfa->lock);
@@ -395,17 +396,17 @@ re_search_stub (struct re_pattern_buffer *bufp, const char *string, Idx length,
395 if (start < last_start && bufp->fastmap != NULL && !bufp->fastmap_accurate) 396 if (start < last_start && bufp->fastmap != NULL && !bufp->fastmap_accurate)
396 re_compile_fastmap (bufp); 397 re_compile_fastmap (bufp);
397 398
398 if (BE (bufp->no_sub, 0)) 399 if (__glibc_unlikely (bufp->no_sub))
399 regs = NULL; 400 regs = NULL;
400 401
401 /* We need at least 1 register. */ 402 /* We need at least 1 register. */
402 if (regs == NULL) 403 if (regs == NULL)
403 nregs = 1; 404 nregs = 1;
404 else if (BE (bufp->regs_allocated == REGS_FIXED 405 else if (__glibc_unlikely (bufp->regs_allocated == REGS_FIXED
405 && regs->num_regs <= bufp->re_nsub, 0)) 406 && regs->num_regs <= bufp->re_nsub))
406 { 407 {
407 nregs = regs->num_regs; 408 nregs = regs->num_regs;
408 if (BE (nregs < 1, 0)) 409 if (__glibc_unlikely (nregs < 1))
409 { 410 {
410 /* Nothing can be copied to regs. */ 411 /* Nothing can be copied to regs. */
411 regs = NULL; 412 regs = NULL;
@@ -415,7 +416,7 @@ re_search_stub (struct re_pattern_buffer *bufp, const char *string, Idx length,
415 else 416 else
416 nregs = bufp->re_nsub + 1; 417 nregs = bufp->re_nsub + 1;
417 pmatch = re_malloc (regmatch_t, nregs); 418 pmatch = re_malloc (regmatch_t, nregs);
418 if (BE (pmatch == NULL, 0)) 419 if (__glibc_unlikely (pmatch == NULL))
419 { 420 {
420 rval = -2; 421 rval = -2;
421 goto out; 422 goto out;
@@ -434,11 +435,11 @@ re_search_stub (struct re_pattern_buffer *bufp, const char *string, Idx length,
434 /* If caller wants register contents data back, copy them. */ 435 /* If caller wants register contents data back, copy them. */
435 bufp->regs_allocated = re_copy_regs (regs, pmatch, nregs, 436 bufp->regs_allocated = re_copy_regs (regs, pmatch, nregs,
436 bufp->regs_allocated); 437 bufp->regs_allocated);
437 if (BE (bufp->regs_allocated == REGS_UNALLOCATED, 0)) 438 if (__glibc_unlikely (bufp->regs_allocated == REGS_UNALLOCATED))
438 rval = -2; 439 rval = -2;
439 } 440 }
440 441
441 if (BE (rval == 0, 1)) 442 if (__glibc_likely (rval == 0))
442 { 443 {
443 if (ret_len) 444 if (ret_len)
444 { 445 {
@@ -468,10 +469,10 @@ re_copy_regs (struct re_registers *regs, regmatch_t *pmatch, Idx nregs,
468 if (regs_allocated == REGS_UNALLOCATED) 469 if (regs_allocated == REGS_UNALLOCATED)
469 { /* No. So allocate them with malloc. */ 470 { /* No. So allocate them with malloc. */
470 regs->start = re_malloc (regoff_t, need_regs); 471 regs->start = re_malloc (regoff_t, need_regs);
471 if (BE (regs->start == NULL, 0)) 472 if (__glibc_unlikely (regs->start == NULL))
472 return REGS_UNALLOCATED; 473 return REGS_UNALLOCATED;
473 regs->end = re_malloc (regoff_t, need_regs); 474 regs->end = re_malloc (regoff_t, need_regs);
474 if (BE (regs->end == NULL, 0)) 475 if (__glibc_unlikely (regs->end == NULL))
475 { 476 {
476 re_free (regs->start); 477 re_free (regs->start);
477 return REGS_UNALLOCATED; 478 return REGS_UNALLOCATED;
@@ -482,14 +483,14 @@ re_copy_regs (struct re_registers *regs, regmatch_t *pmatch, Idx nregs,
482 { /* Yes. If we need more elements than were already 483 { /* Yes. If we need more elements than were already
483 allocated, reallocate them. If we need fewer, just 484 allocated, reallocate them. If we need fewer, just
484 leave it alone. */ 485 leave it alone. */
485 if (BE (need_regs > regs->num_regs, 0)) 486 if (__glibc_unlikely (need_regs > regs->num_regs))
486 { 487 {
487 regoff_t *new_start = re_realloc (regs->start, regoff_t, need_regs); 488 regoff_t *new_start = re_realloc (regs->start, regoff_t, need_regs);
488 regoff_t *new_end; 489 regoff_t *new_end;
489 if (BE (new_start == NULL, 0)) 490 if (__glibc_unlikely (new_start == NULL))
490 return REGS_UNALLOCATED; 491 return REGS_UNALLOCATED;
491 new_end = re_realloc (regs->end, regoff_t, need_regs); 492 new_end = re_realloc (regs->end, regoff_t, need_regs);
492 if (BE (new_end == NULL, 0)) 493 if (__glibc_unlikely (new_end == NULL))
493 { 494 {
494 re_free (new_start); 495 re_free (new_start);
495 return REGS_UNALLOCATED; 496 return REGS_UNALLOCATED;
@@ -615,9 +616,10 @@ re_search_internal (const regex_t *preg, const char *string, Idx length,
615 nmatch -= extra_nmatch; 616 nmatch -= extra_nmatch;
616 617
617 /* Check if the DFA haven't been compiled. */ 618 /* Check if the DFA haven't been compiled. */
618 if (BE (preg->used == 0 || dfa->init_state == NULL 619 if (__glibc_unlikely (preg->used == 0 || dfa->init_state == NULL
619 || dfa->init_state_word == NULL || dfa->init_state_nl == NULL 620 || dfa->init_state_word == NULL
620 || dfa->init_state_begbuf == NULL, 0)) 621 || dfa->init_state_nl == NULL
622 || dfa->init_state_begbuf == NULL))
621 return REG_NOMATCH; 623 return REG_NOMATCH;
622 624
623#ifdef DEBUG 625#ifdef DEBUG
@@ -644,14 +646,14 @@ re_search_internal (const regex_t *preg, const char *string, Idx length,
644 err = re_string_allocate (&mctx.input, string, length, dfa->nodes_len + 1, 646 err = re_string_allocate (&mctx.input, string, length, dfa->nodes_len + 1,
645 preg->translate, (preg->syntax & RE_ICASE) != 0, 647 preg->translate, (preg->syntax & RE_ICASE) != 0,
646 dfa); 648 dfa);
647 if (BE (err != REG_NOERROR, 0)) 649 if (__glibc_unlikely (err != REG_NOERROR))
648 goto free_return; 650 goto free_return;
649 mctx.input.stop = stop; 651 mctx.input.stop = stop;
650 mctx.input.raw_stop = stop; 652 mctx.input.raw_stop = stop;
651 mctx.input.newline_anchor = preg->newline_anchor; 653 mctx.input.newline_anchor = preg->newline_anchor;
652 654
653 err = match_ctx_init (&mctx, eflags, dfa->nbackref * 2); 655 err = match_ctx_init (&mctx, eflags, dfa->nbackref * 2);
654 if (BE (err != REG_NOERROR, 0)) 656 if (__glibc_unlikely (err != REG_NOERROR))
655 goto free_return; 657 goto free_return;
656 658
657 /* We will log all the DFA states through which the dfa pass, 659 /* We will log all the DFA states through which the dfa pass,
@@ -661,15 +663,15 @@ re_search_internal (const regex_t *preg, const char *string, Idx length,
661 if (nmatch > 1 || dfa->has_mb_node) 663 if (nmatch > 1 || dfa->has_mb_node)
662 { 664 {
663 /* Avoid overflow. */ 665 /* Avoid overflow. */
664 if (BE ((MIN (IDX_MAX, SIZE_MAX / sizeof (re_dfastate_t *)) 666 if (__glibc_unlikely ((MIN (IDX_MAX, SIZE_MAX / sizeof (re_dfastate_t *))
665 <= mctx.input.bufs_len), 0)) 667 <= mctx.input.bufs_len)))
666 { 668 {
667 err = REG_ESPACE; 669 err = REG_ESPACE;
668 goto free_return; 670 goto free_return;
669 } 671 }
670 672
671 mctx.state_log = re_malloc (re_dfastate_t *, mctx.input.bufs_len + 1); 673 mctx.state_log = re_malloc (re_dfastate_t *, mctx.input.bufs_len + 1);
672 if (BE (mctx.state_log == NULL, 0)) 674 if (__glibc_unlikely (mctx.state_log == NULL))
673 { 675 {
674 err = REG_ESPACE; 676 err = REG_ESPACE;
675 goto free_return; 677 goto free_return;
@@ -713,19 +715,19 @@ re_search_internal (const regex_t *preg, const char *string, Idx length,
713 715
714 case 7: 716 case 7:
715 /* Fastmap with single-byte translation, match forward. */ 717 /* Fastmap with single-byte translation, match forward. */
716 while (BE (match_first < right_lim, 1) 718 while (__glibc_likely (match_first < right_lim)
717 && !fastmap[t[(unsigned char) string[match_first]]]) 719 && !fastmap[t[(unsigned char) string[match_first]]])
718 ++match_first; 720 ++match_first;
719 goto forward_match_found_start_or_reached_end; 721 goto forward_match_found_start_or_reached_end;
720 722
721 case 6: 723 case 6:
722 /* Fastmap without translation, match forward. */ 724 /* Fastmap without translation, match forward. */
723 while (BE (match_first < right_lim, 1) 725 while (__glibc_likely (match_first < right_lim)
724 && !fastmap[(unsigned char) string[match_first]]) 726 && !fastmap[(unsigned char) string[match_first]])
725 ++match_first; 727 ++match_first;
726 728
727 forward_match_found_start_or_reached_end: 729 forward_match_found_start_or_reached_end:
728 if (BE (match_first == right_lim, 0)) 730 if (__glibc_unlikely (match_first == right_lim))
729 { 731 {
730 ch = match_first >= length 732 ch = match_first >= length
731 ? 0 : (unsigned char) string[match_first]; 733 ? 0 : (unsigned char) string[match_first];
@@ -758,11 +760,12 @@ re_search_internal (const regex_t *preg, const char *string, Idx length,
758 /* If MATCH_FIRST is out of the valid range, reconstruct the 760 /* If MATCH_FIRST is out of the valid range, reconstruct the
759 buffers. */ 761 buffers. */
760 __re_size_t offset = match_first - mctx.input.raw_mbs_idx; 762 __re_size_t offset = match_first - mctx.input.raw_mbs_idx;
761 if (BE (offset >= (__re_size_t) mctx.input.valid_raw_len, 0)) 763 if (__glibc_unlikely (offset
764 >= (__re_size_t) mctx.input.valid_raw_len))
762 { 765 {
763 err = re_string_reconstruct (&mctx.input, match_first, 766 err = re_string_reconstruct (&mctx.input, match_first,
764 eflags); 767 eflags);
765 if (BE (err != REG_NOERROR, 0)) 768 if (__glibc_unlikely (err != REG_NOERROR))
766 goto free_return; 769 goto free_return;
767 770
768 offset = match_first - mctx.input.raw_mbs_idx; 771 offset = match_first - mctx.input.raw_mbs_idx;
@@ -786,7 +789,7 @@ re_search_internal (const regex_t *preg, const char *string, Idx length,
786 /* Reconstruct the buffers so that the matcher can assume that 789 /* Reconstruct the buffers so that the matcher can assume that
787 the matching starts from the beginning of the buffer. */ 790 the matching starts from the beginning of the buffer. */
788 err = re_string_reconstruct (&mctx.input, match_first, eflags); 791 err = re_string_reconstruct (&mctx.input, match_first, eflags);
789 if (BE (err != REG_NOERROR, 0)) 792 if (__glibc_unlikely (err != REG_NOERROR))
790 goto free_return; 793 goto free_return;
791 794
792#ifdef RE_ENABLE_I18N 795#ifdef RE_ENABLE_I18N
@@ -803,7 +806,7 @@ re_search_internal (const regex_t *preg, const char *string, Idx length,
803 start <= last_start ? &match_first : NULL); 806 start <= last_start ? &match_first : NULL);
804 if (match_last != -1) 807 if (match_last != -1)
805 { 808 {
806 if (BE (match_last == -2, 0)) 809 if (__glibc_unlikely (match_last == -2))
807 { 810 {
808 err = REG_ESPACE; 811 err = REG_ESPACE;
809 goto free_return; 812 goto free_return;
@@ -823,7 +826,7 @@ re_search_internal (const regex_t *preg, const char *string, Idx length,
823 err = prune_impossible_nodes (&mctx); 826 err = prune_impossible_nodes (&mctx);
824 if (err == REG_NOERROR) 827 if (err == REG_NOERROR)
825 break; 828 break;
826 if (BE (err != REG_NOMATCH, 0)) 829 if (__glibc_unlikely (err != REG_NOMATCH))
827 goto free_return; 830 goto free_return;
828 match_last = -1; 831 match_last = -1;
829 } 832 }
@@ -860,7 +863,7 @@ re_search_internal (const regex_t *preg, const char *string, Idx length,
860 { 863 {
861 err = set_regs (preg, &mctx, nmatch, pmatch, 864 err = set_regs (preg, &mctx, nmatch, pmatch,
862 dfa->has_plural_match && dfa->nbackref > 0); 865 dfa->has_plural_match && dfa->nbackref > 0);
863 if (BE (err != REG_NOERROR, 0)) 866 if (__glibc_unlikely (err != REG_NOERROR))
864 goto free_return; 867 goto free_return;
865 } 868 }
866 869
@@ -871,7 +874,7 @@ re_search_internal (const regex_t *preg, const char *string, Idx length,
871 if (pmatch[reg_idx].rm_so != -1) 874 if (pmatch[reg_idx].rm_so != -1)
872 { 875 {
873#ifdef RE_ENABLE_I18N 876#ifdef RE_ENABLE_I18N
874 if (BE (mctx.input.offsets_needed != 0, 0)) 877 if (__glibc_unlikely (mctx.input.offsets_needed != 0))
875 { 878 {
876 pmatch[reg_idx].rm_so = 879 pmatch[reg_idx].rm_so =
877 (pmatch[reg_idx].rm_so == mctx.input.valid_len 880 (pmatch[reg_idx].rm_so == mctx.input.valid_len
@@ -930,11 +933,12 @@ prune_impossible_nodes (re_match_context_t *mctx)
930 halt_node = mctx->last_node; 933 halt_node = mctx->last_node;
931 934
932 /* Avoid overflow. */ 935 /* Avoid overflow. */
933 if (BE (MIN (IDX_MAX, SIZE_MAX / sizeof (re_dfastate_t *)) <= match_last, 0)) 936 if (__glibc_unlikely (MIN (IDX_MAX, SIZE_MAX / sizeof (re_dfastate_t *))
937 <= match_last))
934 return REG_ESPACE; 938 return REG_ESPACE;
935 939
936 sifted_states = re_malloc (re_dfastate_t *, match_last + 1); 940 sifted_states = re_malloc (re_dfastate_t *, match_last + 1);
937 if (BE (sifted_states == NULL, 0)) 941 if (__glibc_unlikely (sifted_states == NULL))
938 { 942 {
939 ret = REG_ESPACE; 943 ret = REG_ESPACE;
940 goto free_return; 944 goto free_return;
@@ -942,7 +946,7 @@ prune_impossible_nodes (re_match_context_t *mctx)
942 if (dfa->nbackref) 946 if (dfa->nbackref)
943 { 947 {
944 lim_states = re_malloc (re_dfastate_t *, match_last + 1); 948 lim_states = re_malloc (re_dfastate_t *, match_last + 1);
945 if (BE (lim_states == NULL, 0)) 949 if (__glibc_unlikely (lim_states == NULL))
946 { 950 {
947 ret = REG_ESPACE; 951 ret = REG_ESPACE;
948 goto free_return; 952 goto free_return;
@@ -955,7 +959,7 @@ prune_impossible_nodes (re_match_context_t *mctx)
955 match_last); 959 match_last);
956 ret = sift_states_backward (mctx, &sctx); 960 ret = sift_states_backward (mctx, &sctx);
957 re_node_set_free (&sctx.limits); 961 re_node_set_free (&sctx.limits);
958 if (BE (ret != REG_NOERROR, 0)) 962 if (__glibc_unlikely (ret != REG_NOERROR))
959 goto free_return; 963 goto free_return;
960 if (sifted_states[0] != NULL || lim_states[0] != NULL) 964 if (sifted_states[0] != NULL || lim_states[0] != NULL)
961 break; 965 break;
@@ -977,7 +981,7 @@ prune_impossible_nodes (re_match_context_t *mctx)
977 match_last + 1); 981 match_last + 1);
978 re_free (lim_states); 982 re_free (lim_states);
979 lim_states = NULL; 983 lim_states = NULL;
980 if (BE (ret != REG_NOERROR, 0)) 984 if (__glibc_unlikely (ret != REG_NOERROR))
981 goto free_return; 985 goto free_return;
982 } 986 }
983 else 987 else
@@ -985,7 +989,7 @@ prune_impossible_nodes (re_match_context_t *mctx)
985 sift_ctx_init (&sctx, sifted_states, lim_states, halt_node, match_last); 989 sift_ctx_init (&sctx, sifted_states, lim_states, halt_node, match_last);
986 ret = sift_states_backward (mctx, &sctx); 990 ret = sift_states_backward (mctx, &sctx);
987 re_node_set_free (&sctx.limits); 991 re_node_set_free (&sctx.limits);
988 if (BE (ret != REG_NOERROR, 0)) 992 if (__glibc_unlikely (ret != REG_NOERROR))
989 goto free_return; 993 goto free_return;
990 if (sifted_states[0] == NULL) 994 if (sifted_states[0] == NULL)
991 { 995 {
@@ -1068,7 +1072,7 @@ check_matching (re_match_context_t *mctx, bool fl_longest_match,
1068 err = REG_NOERROR; 1072 err = REG_NOERROR;
1069 cur_state = acquire_init_state_context (&err, mctx, cur_str_idx); 1073 cur_state = acquire_init_state_context (&err, mctx, cur_str_idx);
1070 /* An initial state must not be NULL (invalid). */ 1074 /* An initial state must not be NULL (invalid). */
1071 if (BE (cur_state == NULL, 0)) 1075 if (__glibc_unlikely (cur_state == NULL))
1072 { 1076 {
1073 assert (err == REG_ESPACE); 1077 assert (err == REG_ESPACE);
1074 return -2; 1078 return -2;
@@ -1080,24 +1084,24 @@ check_matching (re_match_context_t *mctx, bool fl_longest_match,
1080 1084
1081 /* Check OP_OPEN_SUBEXP in the initial state in case that we use them 1085 /* Check OP_OPEN_SUBEXP in the initial state in case that we use them
1082 later. E.g. Processing back references. */ 1086 later. E.g. Processing back references. */
1083 if (BE (dfa->nbackref, 0)) 1087 if (__glibc_unlikely (dfa->nbackref))
1084 { 1088 {
1085 at_init_state = false; 1089 at_init_state = false;
1086 err = check_subexp_matching_top (mctx, &cur_state->nodes, 0); 1090 err = check_subexp_matching_top (mctx, &cur_state->nodes, 0);
1087 if (BE (err != REG_NOERROR, 0)) 1091 if (__glibc_unlikely (err != REG_NOERROR))
1088 return err; 1092 return err;
1089 1093
1090 if (cur_state->has_backref) 1094 if (cur_state->has_backref)
1091 { 1095 {
1092 err = transit_state_bkref (mctx, &cur_state->nodes); 1096 err = transit_state_bkref (mctx, &cur_state->nodes);
1093 if (BE (err != REG_NOERROR, 0)) 1097 if (__glibc_unlikely (err != REG_NOERROR))
1094 return err; 1098 return err;
1095 } 1099 }
1096 } 1100 }
1097 } 1101 }
1098 1102
1099 /* If the RE accepts NULL string. */ 1103 /* If the RE accepts NULL string. */
1100 if (BE (cur_state->halt, 0)) 1104 if (__glibc_unlikely (cur_state->halt))
1101 { 1105 {
1102 if (!cur_state->has_constraint 1106 if (!cur_state->has_constraint
1103 || check_halt_state_context (mctx, cur_state, cur_str_idx)) 1107 || check_halt_state_context (mctx, cur_state, cur_str_idx))
@@ -1117,13 +1121,13 @@ check_matching (re_match_context_t *mctx, bool fl_longest_match,
1117 re_dfastate_t *old_state = cur_state; 1121 re_dfastate_t *old_state = cur_state;
1118 Idx next_char_idx = re_string_cur_idx (&mctx->input) + 1; 1122 Idx next_char_idx = re_string_cur_idx (&mctx->input) + 1;
1119 1123
1120 if ((BE (next_char_idx >= mctx->input.bufs_len, 0) 1124 if ((__glibc_unlikely (next_char_idx >= mctx->input.bufs_len)
1121 && mctx->input.bufs_len < mctx->input.len) 1125 && mctx->input.bufs_len < mctx->input.len)
1122 || (BE (next_char_idx >= mctx->input.valid_len, 0) 1126 || (__glibc_unlikely (next_char_idx >= mctx->input.valid_len)
1123 && mctx->input.valid_len < mctx->input.len)) 1127 && mctx->input.valid_len < mctx->input.len))
1124 { 1128 {
1125 err = extend_buffers (mctx, next_char_idx + 1); 1129 err = extend_buffers (mctx, next_char_idx + 1);
1126 if (BE (err != REG_NOERROR, 0)) 1130 if (__glibc_unlikely (err != REG_NOERROR))
1127 { 1131 {
1128 assert (err == REG_ESPACE); 1132 assert (err == REG_ESPACE);
1129 return -2; 1133 return -2;
@@ -1139,7 +1143,7 @@ check_matching (re_match_context_t *mctx, bool fl_longest_match,
1139 /* Reached the invalid state or an error. Try to recover a valid 1143 /* Reached the invalid state or an error. Try to recover a valid
1140 state using the state log, if available and if we have not 1144 state using the state log, if available and if we have not
1141 already found a valid (even if not the longest) match. */ 1145 already found a valid (even if not the longest) match. */
1142 if (BE (err != REG_NOERROR, 0)) 1146 if (__glibc_unlikely (err != REG_NOERROR))
1143 return -2; 1147 return -2;
1144 1148
1145 if (mctx->state_log == NULL 1149 if (mctx->state_log == NULL
@@ -1148,7 +1152,7 @@ check_matching (re_match_context_t *mctx, bool fl_longest_match,
1148 break; 1152 break;
1149 } 1153 }
1150 1154
1151 if (BE (at_init_state, 0)) 1155 if (__glibc_unlikely (at_init_state))
1152 { 1156 {
1153 if (old_state == cur_state) 1157 if (old_state == cur_state)
1154 next_start_idx = next_char_idx; 1158 next_start_idx = next_char_idx;
@@ -1237,7 +1241,7 @@ proceed_next_node (const re_match_context_t *mctx, Idx nregs, regmatch_t *regs,
1237 re_node_set *edests = &dfa->edests[node]; 1241 re_node_set *edests = &dfa->edests[node];
1238 Idx dest_node; 1242 Idx dest_node;
1239 ok = re_node_set_insert (eps_via_nodes, node); 1243 ok = re_node_set_insert (eps_via_nodes, node);
1240 if (BE (! ok, 0)) 1244 if (__glibc_unlikely (! ok))
1241 return -2; 1245 return -2;
1242 /* Pick up a valid destination, or return -1 if none 1246 /* Pick up a valid destination, or return -1 if none
1243 is found. */ 1247 is found. */
@@ -1299,7 +1303,7 @@ proceed_next_node (const re_match_context_t *mctx, Idx nregs, regmatch_t *regs,
1299 { 1303 {
1300 Idx dest_node; 1304 Idx dest_node;
1301 ok = re_node_set_insert (eps_via_nodes, node); 1305 ok = re_node_set_insert (eps_via_nodes, node);
1302 if (BE (! ok, 0)) 1306 if (__glibc_unlikely (! ok))
1303 return -2; 1307 return -2;
1304 dest_node = dfa->edests[node].elems[0]; 1308 dest_node = dfa->edests[node].elems[0];
1305 if (re_node_set_contains (&mctx->state_log[*pidx]->nodes, 1309 if (re_node_set_contains (&mctx->state_log[*pidx]->nodes,
@@ -1449,9 +1453,9 @@ set_regs (const regex_t *preg, const re_match_context_t *mctx, size_t nmatch,
1449 cur_node = proceed_next_node (mctx, nmatch, pmatch, &idx, cur_node, 1453 cur_node = proceed_next_node (mctx, nmatch, pmatch, &idx, cur_node,
1450 &eps_via_nodes, fs); 1454 &eps_via_nodes, fs);
1451 1455
1452 if (BE (cur_node < 0, 0)) 1456 if (__glibc_unlikely (cur_node < 0))
1453 { 1457 {
1454 if (BE (cur_node == -2, 0)) 1458 if (__glibc_unlikely (cur_node == -2))
1455 { 1459 {
1456 re_node_set_free (&eps_via_nodes); 1460 re_node_set_free (&eps_via_nodes);
1457 if (prev_idx_match_malloced) 1461 if (prev_idx_match_malloced)
@@ -1579,10 +1583,10 @@ sift_states_backward (const re_match_context_t *mctx, re_sift_context_t *sctx)
1579 /* Build sifted state_log[str_idx]. It has the nodes which can epsilon 1583 /* Build sifted state_log[str_idx]. It has the nodes which can epsilon
1580 transit to the last_node and the last_node itself. */ 1584 transit to the last_node and the last_node itself. */
1581 err = re_node_set_init_1 (&cur_dest, sctx->last_node); 1585 err = re_node_set_init_1 (&cur_dest, sctx->last_node);
1582 if (BE (err != REG_NOERROR, 0)) 1586 if (__glibc_unlikely (err != REG_NOERROR))
1583 return err; 1587 return err;
1584 err = update_cur_sifted_state (mctx, sctx, str_idx, &cur_dest); 1588 err = update_cur_sifted_state (mctx, sctx, str_idx, &cur_dest);
1585 if (BE (err != REG_NOERROR, 0)) 1589 if (__glibc_unlikely (err != REG_NOERROR))
1586 goto free_return; 1590 goto free_return;
1587 1591
1588 /* Then check each states in the state_log. */ 1592 /* Then check each states in the state_log. */
@@ -1603,7 +1607,7 @@ sift_states_backward (const re_match_context_t *mctx, re_sift_context_t *sctx)
1603 if (mctx->state_log[str_idx]) 1607 if (mctx->state_log[str_idx])
1604 { 1608 {
1605 err = build_sifted_states (mctx, sctx, str_idx, &cur_dest); 1609 err = build_sifted_states (mctx, sctx, str_idx, &cur_dest);
1606 if (BE (err != REG_NOERROR, 0)) 1610 if (__glibc_unlikely (err != REG_NOERROR))
1607 goto free_return; 1611 goto free_return;
1608 } 1612 }
1609 1613
@@ -1612,7 +1616,7 @@ sift_states_backward (const re_match_context_t *mctx, re_sift_context_t *sctx)
1612 - It is in CUR_SRC. 1616 - It is in CUR_SRC.
1613 And update state_log. */ 1617 And update state_log. */
1614 err = update_cur_sifted_state (mctx, sctx, str_idx, &cur_dest); 1618 err = update_cur_sifted_state (mctx, sctx, str_idx, &cur_dest);
1615 if (BE (err != REG_NOERROR, 0)) 1619 if (__glibc_unlikely (err != REG_NOERROR))
1616 goto free_return; 1620 goto free_return;
1617 } 1621 }
1618 err = REG_NOERROR; 1622 err = REG_NOERROR;
@@ -1674,7 +1678,7 @@ build_sifted_states (const re_match_context_t *mctx, re_sift_context_t *sctx,
1674 continue; 1678 continue;
1675 } 1679 }
1676 ok = re_node_set_insert (cur_dest, prev_node); 1680 ok = re_node_set_insert (cur_dest, prev_node);
1677 if (BE (! ok, 0)) 1681 if (__glibc_unlikely (! ok))
1678 return REG_ESPACE; 1682 return REG_ESPACE;
1679 } 1683 }
1680 1684
@@ -1695,7 +1699,7 @@ clean_state_log_if_needed (re_match_context_t *mctx, Idx next_state_log_idx)
1695 { 1699 {
1696 reg_errcode_t err; 1700 reg_errcode_t err;
1697 err = extend_buffers (mctx, next_state_log_idx + 1); 1701 err = extend_buffers (mctx, next_state_log_idx + 1);
1698 if (BE (err != REG_NOERROR, 0)) 1702 if (__glibc_unlikely (err != REG_NOERROR))
1699 return err; 1703 return err;
1700 } 1704 }
1701 1705
@@ -1723,11 +1727,11 @@ merge_state_array (const re_dfa_t *dfa, re_dfastate_t **dst,
1723 re_node_set merged_set; 1727 re_node_set merged_set;
1724 err = re_node_set_init_union (&merged_set, &dst[st_idx]->nodes, 1728 err = re_node_set_init_union (&merged_set, &dst[st_idx]->nodes,
1725 &src[st_idx]->nodes); 1729 &src[st_idx]->nodes);
1726 if (BE (err != REG_NOERROR, 0)) 1730 if (__glibc_unlikely (err != REG_NOERROR))
1727 return err; 1731 return err;
1728 dst[st_idx] = re_acquire_state (&err, dfa, &merged_set); 1732 dst[st_idx] = re_acquire_state (&err, dfa, &merged_set);
1729 re_node_set_free (&merged_set); 1733 re_node_set_free (&merged_set);
1730 if (BE (err != REG_NOERROR, 0)) 1734 if (__glibc_unlikely (err != REG_NOERROR))
1731 return err; 1735 return err;
1732 } 1736 }
1733 } 1737 }
@@ -1754,7 +1758,7 @@ update_cur_sifted_state (const re_match_context_t *mctx,
1754 /* At first, add the nodes which can epsilon transit to a node in 1758 /* At first, add the nodes which can epsilon transit to a node in
1755 DEST_NODE. */ 1759 DEST_NODE. */
1756 err = add_epsilon_src_nodes (dfa, dest_nodes, candidates); 1760 err = add_epsilon_src_nodes (dfa, dest_nodes, candidates);
1757 if (BE (err != REG_NOERROR, 0)) 1761 if (__glibc_unlikely (err != REG_NOERROR))
1758 return err; 1762 return err;
1759 1763
1760 /* Then, check the limitations in the current sift_context. */ 1764 /* Then, check the limitations in the current sift_context. */
@@ -1762,20 +1766,20 @@ update_cur_sifted_state (const re_match_context_t *mctx,
1762 { 1766 {
1763 err = check_subexp_limits (dfa, dest_nodes, candidates, &sctx->limits, 1767 err = check_subexp_limits (dfa, dest_nodes, candidates, &sctx->limits,
1764 mctx->bkref_ents, str_idx); 1768 mctx->bkref_ents, str_idx);
1765 if (BE (err != REG_NOERROR, 0)) 1769 if (__glibc_unlikely (err != REG_NOERROR))
1766 return err; 1770 return err;
1767 } 1771 }
1768 } 1772 }
1769 1773
1770 sctx->sifted_states[str_idx] = re_acquire_state (&err, dfa, dest_nodes); 1774 sctx->sifted_states[str_idx] = re_acquire_state (&err, dfa, dest_nodes);
1771 if (BE (err != REG_NOERROR, 0)) 1775 if (__glibc_unlikely (err != REG_NOERROR))
1772 return err; 1776 return err;
1773 } 1777 }
1774 1778
1775 if (candidates && mctx->state_log[str_idx]->has_backref) 1779 if (candidates && mctx->state_log[str_idx]->has_backref)
1776 { 1780 {
1777 err = sift_states_bkref (mctx, sctx, str_idx, candidates); 1781 err = sift_states_bkref (mctx, sctx, str_idx, candidates);
1778 if (BE (err != REG_NOERROR, 0)) 1782 if (__glibc_unlikely (err != REG_NOERROR))
1779 return err; 1783 return err;
1780 } 1784 }
1781 return REG_NOERROR; 1785 return REG_NOERROR;
@@ -1790,19 +1794,19 @@ add_epsilon_src_nodes (const re_dfa_t *dfa, re_node_set *dest_nodes,
1790 Idx i; 1794 Idx i;
1791 1795
1792 re_dfastate_t *state = re_acquire_state (&err, dfa, dest_nodes); 1796 re_dfastate_t *state = re_acquire_state (&err, dfa, dest_nodes);
1793 if (BE (err != REG_NOERROR, 0)) 1797 if (__glibc_unlikely (err != REG_NOERROR))
1794 return err; 1798 return err;
1795 1799
1796 if (!state->inveclosure.alloc) 1800 if (!state->inveclosure.alloc)
1797 { 1801 {
1798 err = re_node_set_alloc (&state->inveclosure, dest_nodes->nelem); 1802 err = re_node_set_alloc (&state->inveclosure, dest_nodes->nelem);
1799 if (BE (err != REG_NOERROR, 0)) 1803 if (__glibc_unlikely (err != REG_NOERROR))
1800 return REG_ESPACE; 1804 return REG_ESPACE;
1801 for (i = 0; i < dest_nodes->nelem; i++) 1805 for (i = 0; i < dest_nodes->nelem; i++)
1802 { 1806 {
1803 err = re_node_set_merge (&state->inveclosure, 1807 err = re_node_set_merge (&state->inveclosure,
1804 dfa->inveclosures + dest_nodes->elems[i]); 1808 dfa->inveclosures + dest_nodes->elems[i]);
1805 if (BE (err != REG_NOERROR, 0)) 1809 if (__glibc_unlikely (err != REG_NOERROR))
1806 return REG_ESPACE; 1810 return REG_ESPACE;
1807 } 1811 }
1808 } 1812 }
@@ -1837,7 +1841,7 @@ sub_epsilon_src_nodes (const re_dfa_t *dfa, Idx node, re_node_set *dest_nodes,
1837 { 1841 {
1838 err = re_node_set_add_intersect (&except_nodes, candidates, 1842 err = re_node_set_add_intersect (&except_nodes, candidates,
1839 dfa->inveclosures + cur_node); 1843 dfa->inveclosures + cur_node);
1840 if (BE (err != REG_NOERROR, 0)) 1844 if (__glibc_unlikely (err != REG_NOERROR))
1841 { 1845 {
1842 re_node_set_free (&except_nodes); 1846 re_node_set_free (&except_nodes);
1843 return err; 1847 return err;
@@ -2043,7 +2047,7 @@ check_subexp_limits (const re_dfa_t *dfa, re_node_set *dest_nodes,
2043 { 2047 {
2044 err = sub_epsilon_src_nodes (dfa, ops_node, dest_nodes, 2048 err = sub_epsilon_src_nodes (dfa, ops_node, dest_nodes,
2045 candidates); 2049 candidates);
2046 if (BE (err != REG_NOERROR, 0)) 2050 if (__glibc_unlikely (err != REG_NOERROR))
2047 return err; 2051 return err;
2048 } 2052 }
2049 2053
@@ -2061,7 +2065,7 @@ check_subexp_limits (const re_dfa_t *dfa, re_node_set *dest_nodes,
2061 Remove it form the current sifted state. */ 2065 Remove it form the current sifted state. */
2062 err = sub_epsilon_src_nodes (dfa, node, dest_nodes, 2066 err = sub_epsilon_src_nodes (dfa, node, dest_nodes,
2063 candidates); 2067 candidates);
2064 if (BE (err != REG_NOERROR, 0)) 2068 if (__glibc_unlikely (err != REG_NOERROR))
2065 return err; 2069 return err;
2066 --node_idx; 2070 --node_idx;
2067 } 2071 }
@@ -2081,7 +2085,7 @@ check_subexp_limits (const re_dfa_t *dfa, re_node_set *dest_nodes,
2081 Remove it form the current sifted state. */ 2085 Remove it form the current sifted state. */
2082 err = sub_epsilon_src_nodes (dfa, node, dest_nodes, 2086 err = sub_epsilon_src_nodes (dfa, node, dest_nodes,
2083 candidates); 2087 candidates);
2084 if (BE (err != REG_NOERROR, 0)) 2088 if (__glibc_unlikely (err != REG_NOERROR))
2085 return err; 2089 return err;
2086 } 2090 }
2087 } 2091 }
@@ -2147,27 +2151,27 @@ sift_states_bkref (const re_match_context_t *mctx, re_sift_context_t *sctx,
2147 { 2151 {
2148 local_sctx = *sctx; 2152 local_sctx = *sctx;
2149 err = re_node_set_init_copy (&local_sctx.limits, &sctx->limits); 2153 err = re_node_set_init_copy (&local_sctx.limits, &sctx->limits);
2150 if (BE (err != REG_NOERROR, 0)) 2154 if (__glibc_unlikely (err != REG_NOERROR))
2151 goto free_return; 2155 goto free_return;
2152 } 2156 }
2153 local_sctx.last_node = node; 2157 local_sctx.last_node = node;
2154 local_sctx.last_str_idx = str_idx; 2158 local_sctx.last_str_idx = str_idx;
2155 ok = re_node_set_insert (&local_sctx.limits, enabled_idx); 2159 ok = re_node_set_insert (&local_sctx.limits, enabled_idx);
2156 if (BE (! ok, 0)) 2160 if (__glibc_unlikely (! ok))
2157 { 2161 {
2158 err = REG_ESPACE; 2162 err = REG_ESPACE;
2159 goto free_return; 2163 goto free_return;
2160 } 2164 }
2161 cur_state = local_sctx.sifted_states[str_idx]; 2165 cur_state = local_sctx.sifted_states[str_idx];
2162 err = sift_states_backward (mctx, &local_sctx); 2166 err = sift_states_backward (mctx, &local_sctx);
2163 if (BE (err != REG_NOERROR, 0)) 2167 if (__glibc_unlikely (err != REG_NOERROR))
2164 goto free_return; 2168 goto free_return;
2165 if (sctx->limited_states != NULL) 2169 if (sctx->limited_states != NULL)
2166 { 2170 {
2167 err = merge_state_array (dfa, sctx->limited_states, 2171 err = merge_state_array (dfa, sctx->limited_states,
2168 local_sctx.sifted_states, 2172 local_sctx.sifted_states,
2169 str_idx + 1); 2173 str_idx + 1);
2170 if (BE (err != REG_NOERROR, 0)) 2174 if (__glibc_unlikely (err != REG_NOERROR))
2171 goto free_return; 2175 goto free_return;
2172 } 2176 }
2173 local_sctx.sifted_states[str_idx] = cur_state; 2177 local_sctx.sifted_states[str_idx] = cur_state;
@@ -2229,10 +2233,10 @@ transit_state (reg_errcode_t *err, re_match_context_t *mctx,
2229 2233
2230#ifdef RE_ENABLE_I18N 2234#ifdef RE_ENABLE_I18N
2231 /* If the current state can accept multibyte. */ 2235 /* If the current state can accept multibyte. */
2232 if (BE (state->accept_mb, 0)) 2236 if (__glibc_unlikely (state->accept_mb))
2233 { 2237 {
2234 *err = transit_state_mb (mctx, state); 2238 *err = transit_state_mb (mctx, state);
2235 if (BE (*err != REG_NOERROR, 0)) 2239 if (__glibc_unlikely (*err != REG_NOERROR))
2236 return NULL; 2240 return NULL;
2237 } 2241 }
2238#endif /* RE_ENABLE_I18N */ 2242#endif /* RE_ENABLE_I18N */
@@ -2249,11 +2253,11 @@ transit_state (reg_errcode_t *err, re_match_context_t *mctx,
2249 for (;;) 2253 for (;;)
2250 { 2254 {
2251 trtable = state->trtable; 2255 trtable = state->trtable;
2252 if (BE (trtable != NULL, 1)) 2256 if (__glibc_likely (trtable != NULL))
2253 return trtable[ch]; 2257 return trtable[ch];
2254 2258
2255 trtable = state->word_trtable; 2259 trtable = state->word_trtable;
2256 if (BE (trtable != NULL, 1)) 2260 if (__glibc_likely (trtable != NULL))
2257 { 2261 {
2258 unsigned int context; 2262 unsigned int context;
2259 context 2263 context
@@ -2309,7 +2313,7 @@ merge_state_with_log (reg_errcode_t *err, re_match_context_t *mctx,
2309 table_nodes = next_state->entrance_nodes; 2313 table_nodes = next_state->entrance_nodes;
2310 *err = re_node_set_init_union (&next_nodes, table_nodes, 2314 *err = re_node_set_init_union (&next_nodes, table_nodes,
2311 log_nodes); 2315 log_nodes);
2312 if (BE (*err != REG_NOERROR, 0)) 2316 if (__glibc_unlikely (*err != REG_NOERROR))
2313 return NULL; 2317 return NULL;
2314 } 2318 }
2315 else 2319 else
@@ -2329,21 +2333,21 @@ merge_state_with_log (reg_errcode_t *err, re_match_context_t *mctx,
2329 re_node_set_free (&next_nodes); 2333 re_node_set_free (&next_nodes);
2330 } 2334 }
2331 2335
2332 if (BE (dfa->nbackref, 0) && next_state != NULL) 2336 if (__glibc_unlikely (dfa->nbackref) && next_state != NULL)
2333 { 2337 {
2334 /* Check OP_OPEN_SUBEXP in the current state in case that we use them 2338 /* Check OP_OPEN_SUBEXP in the current state in case that we use them
2335 later. We must check them here, since the back references in the 2339 later. We must check them here, since the back references in the
2336 next state might use them. */ 2340 next state might use them. */
2337 *err = check_subexp_matching_top (mctx, &next_state->nodes, 2341 *err = check_subexp_matching_top (mctx, &next_state->nodes,
2338 cur_idx); 2342 cur_idx);
2339 if (BE (*err != REG_NOERROR, 0)) 2343 if (__glibc_unlikely (*err != REG_NOERROR))
2340 return NULL; 2344 return NULL;
2341 2345
2342 /* If the next state has back references. */ 2346 /* If the next state has back references. */
2343 if (next_state->has_backref) 2347 if (next_state->has_backref)
2344 { 2348 {
2345 *err = transit_state_bkref (mctx, &next_state->nodes); 2349 *err = transit_state_bkref (mctx, &next_state->nodes);
2346 if (BE (*err != REG_NOERROR, 0)) 2350 if (__glibc_unlikely (*err != REG_NOERROR))
2347 return NULL; 2351 return NULL;
2348 next_state = mctx->state_log[cur_idx]; 2352 next_state = mctx->state_log[cur_idx];
2349 } 2353 }
@@ -2407,7 +2411,7 @@ check_subexp_matching_top (re_match_context_t *mctx, re_node_set *cur_nodes,
2407 & ((bitset_word_t) 1 << dfa->nodes[node].opr.idx))) 2411 & ((bitset_word_t) 1 << dfa->nodes[node].opr.idx)))
2408 { 2412 {
2409 err = match_ctx_add_subtop (mctx, node, str_idx); 2413 err = match_ctx_add_subtop (mctx, node, str_idx);
2410 if (BE (err != REG_NOERROR, 0)) 2414 if (__glibc_unlikely (err != REG_NOERROR))
2411 return err; 2415 return err;
2412 } 2416 }
2413 } 2417 }
@@ -2429,7 +2433,7 @@ transit_state_sb (reg_errcode_t *err, re_match_context_t *mctx,
2429 unsigned int context; 2433 unsigned int context;
2430 2434
2431 *err = re_node_set_alloc (&next_nodes, state->nodes.nelem + 1); 2435 *err = re_node_set_alloc (&next_nodes, state->nodes.nelem + 1);
2432 if (BE (*err != REG_NOERROR, 0)) 2436 if (__glibc_unlikely (*err != REG_NOERROR))
2433 return NULL; 2437 return NULL;
2434 for (node_cnt = 0; node_cnt < state->nodes.nelem; ++node_cnt) 2438 for (node_cnt = 0; node_cnt < state->nodes.nelem; ++node_cnt)
2435 { 2439 {
@@ -2438,7 +2442,7 @@ transit_state_sb (reg_errcode_t *err, re_match_context_t *mctx,
2438 { 2442 {
2439 *err = re_node_set_merge (&next_nodes, 2443 *err = re_node_set_merge (&next_nodes,
2440 dfa->eclosures + dfa->nexts[cur_node]); 2444 dfa->eclosures + dfa->nexts[cur_node]);
2441 if (BE (*err != REG_NOERROR, 0)) 2445 if (__glibc_unlikely (*err != REG_NOERROR))
2442 { 2446 {
2443 re_node_set_free (&next_nodes); 2447 re_node_set_free (&next_nodes);
2444 return NULL; 2448 return NULL;
@@ -2497,7 +2501,7 @@ transit_state_mb (re_match_context_t *mctx, re_dfastate_t *pstate)
2497 mctx->max_mb_elem_len = ((mctx->max_mb_elem_len < naccepted) ? naccepted 2501 mctx->max_mb_elem_len = ((mctx->max_mb_elem_len < naccepted) ? naccepted
2498 : mctx->max_mb_elem_len); 2502 : mctx->max_mb_elem_len);
2499 err = clean_state_log_if_needed (mctx, dest_idx); 2503 err = clean_state_log_if_needed (mctx, dest_idx);
2500 if (BE (err != REG_NOERROR, 0)) 2504 if (__glibc_unlikely (err != REG_NOERROR))
2501 return err; 2505 return err;
2502#ifdef DEBUG 2506#ifdef DEBUG
2503 assert (dfa->nexts[cur_node_idx] != -1); 2507 assert (dfa->nexts[cur_node_idx] != -1);
@@ -2511,7 +2515,7 @@ transit_state_mb (re_match_context_t *mctx, re_dfastate_t *pstate)
2511 { 2515 {
2512 err = re_node_set_init_union (&dest_nodes, 2516 err = re_node_set_init_union (&dest_nodes,
2513 dest_state->entrance_nodes, new_nodes); 2517 dest_state->entrance_nodes, new_nodes);
2514 if (BE (err != REG_NOERROR, 0)) 2518 if (__glibc_unlikely (err != REG_NOERROR))
2515 return err; 2519 return err;
2516 } 2520 }
2517 context = re_string_context_at (&mctx->input, dest_idx - 1, 2521 context = re_string_context_at (&mctx->input, dest_idx - 1,
@@ -2520,7 +2524,8 @@ transit_state_mb (re_match_context_t *mctx, re_dfastate_t *pstate)
2520 = re_acquire_state_context (&err, dfa, &dest_nodes, context); 2524 = re_acquire_state_context (&err, dfa, &dest_nodes, context);
2521 if (dest_state != NULL) 2525 if (dest_state != NULL)
2522 re_node_set_free (&dest_nodes); 2526 re_node_set_free (&dest_nodes);
2523 if (BE (mctx->state_log[dest_idx] == NULL && err != REG_NOERROR, 0)) 2527 if (__glibc_unlikely (mctx->state_log[dest_idx] == NULL
2528 && err != REG_NOERROR))
2524 return err; 2529 return err;
2525 } 2530 }
2526 return REG_NOERROR; 2531 return REG_NOERROR;
@@ -2559,7 +2564,7 @@ transit_state_bkref (re_match_context_t *mctx, const re_node_set *nodes)
2559 Check the substring which the substring matched. */ 2564 Check the substring which the substring matched. */
2560 bkc_idx = mctx->nbkref_ents; 2565 bkc_idx = mctx->nbkref_ents;
2561 err = get_subexp (mctx, node_idx, cur_str_idx); 2566 err = get_subexp (mctx, node_idx, cur_str_idx);
2562 if (BE (err != REG_NOERROR, 0)) 2567 if (__glibc_unlikely (err != REG_NOERROR))
2563 goto free_return; 2568 goto free_return;
2564 2569
2565 /* And add the epsilon closures (which is 'new_dest_nodes') of 2570 /* And add the epsilon closures (which is 'new_dest_nodes') of
@@ -2592,8 +2597,8 @@ transit_state_bkref (re_match_context_t *mctx, const re_node_set *nodes)
2592 mctx->state_log[dest_str_idx] 2597 mctx->state_log[dest_str_idx]
2593 = re_acquire_state_context (&err, dfa, new_dest_nodes, 2598 = re_acquire_state_context (&err, dfa, new_dest_nodes,
2594 context); 2599 context);
2595 if (BE (mctx->state_log[dest_str_idx] == NULL 2600 if (__glibc_unlikely (mctx->state_log[dest_str_idx] == NULL
2596 && err != REG_NOERROR, 0)) 2601 && err != REG_NOERROR))
2597 goto free_return; 2602 goto free_return;
2598 } 2603 }
2599 else 2604 else
@@ -2602,7 +2607,7 @@ transit_state_bkref (re_match_context_t *mctx, const re_node_set *nodes)
2602 err = re_node_set_init_union (&dest_nodes, 2607 err = re_node_set_init_union (&dest_nodes,
2603 dest_state->entrance_nodes, 2608 dest_state->entrance_nodes,
2604 new_dest_nodes); 2609 new_dest_nodes);
2605 if (BE (err != REG_NOERROR, 0)) 2610 if (__glibc_unlikely (err != REG_NOERROR))
2606 { 2611 {
2607 re_node_set_free (&dest_nodes); 2612 re_node_set_free (&dest_nodes);
2608 goto free_return; 2613 goto free_return;
@@ -2610,8 +2615,8 @@ transit_state_bkref (re_match_context_t *mctx, const re_node_set *nodes)
2610 mctx->state_log[dest_str_idx] 2615 mctx->state_log[dest_str_idx]
2611 = re_acquire_state_context (&err, dfa, &dest_nodes, context); 2616 = re_acquire_state_context (&err, dfa, &dest_nodes, context);
2612 re_node_set_free (&dest_nodes); 2617 re_node_set_free (&dest_nodes);
2613 if (BE (mctx->state_log[dest_str_idx] == NULL 2618 if (__glibc_unlikely (mctx->state_log[dest_str_idx] == NULL
2614 && err != REG_NOERROR, 0)) 2619 && err != REG_NOERROR))
2615 goto free_return; 2620 goto free_return;
2616 } 2621 }
2617 /* We need to check recursively if the backreference can epsilon 2622 /* We need to check recursively if the backreference can epsilon
@@ -2621,10 +2626,10 @@ transit_state_bkref (re_match_context_t *mctx, const re_node_set *nodes)
2621 { 2626 {
2622 err = check_subexp_matching_top (mctx, new_dest_nodes, 2627 err = check_subexp_matching_top (mctx, new_dest_nodes,
2623 cur_str_idx); 2628 cur_str_idx);
2624 if (BE (err != REG_NOERROR, 0)) 2629 if (__glibc_unlikely (err != REG_NOERROR))
2625 goto free_return; 2630 goto free_return;
2626 err = transit_state_bkref (mctx, new_dest_nodes); 2631 err = transit_state_bkref (mctx, new_dest_nodes);
2627 if (BE (err != REG_NOERROR, 0)) 2632 if (__glibc_unlikely (err != REG_NOERROR))
2628 goto free_return; 2633 goto free_return;
2629 } 2634 }
2630 } 2635 }
@@ -2685,7 +2690,8 @@ get_subexp (re_match_context_t *mctx, Idx bkref_node, Idx bkref_str_idx)
2685 at the back reference? */ 2690 at the back reference? */
2686 if (sl_str_diff > 0) 2691 if (sl_str_diff > 0)
2687 { 2692 {
2688 if (BE (bkref_str_off + sl_str_diff > mctx->input.valid_len, 0)) 2693 if (__glibc_unlikely (bkref_str_off + sl_str_diff
2694 > mctx->input.valid_len))
2689 { 2695 {
2690 /* Not enough chars for a successful match. */ 2696 /* Not enough chars for a successful match. */
2691 if (bkref_str_off + sl_str_diff > mctx->input.len) 2697 if (bkref_str_off + sl_str_diff > mctx->input.len)
@@ -2694,7 +2700,7 @@ get_subexp (re_match_context_t *mctx, Idx bkref_node, Idx bkref_str_idx)
2694 err = clean_state_log_if_needed (mctx, 2700 err = clean_state_log_if_needed (mctx,
2695 bkref_str_off 2701 bkref_str_off
2696 + sl_str_diff); 2702 + sl_str_diff);
2697 if (BE (err != REG_NOERROR, 0)) 2703 if (__glibc_unlikely (err != REG_NOERROR))
2698 return err; 2704 return err;
2699 buf = (const char *) re_string_get_buffer (&mctx->input); 2705 buf = (const char *) re_string_get_buffer (&mctx->input);
2700 } 2706 }
@@ -2713,7 +2719,7 @@ get_subexp (re_match_context_t *mctx, Idx bkref_node, Idx bkref_str_idx)
2713 2719
2714 if (err == REG_NOMATCH) 2720 if (err == REG_NOMATCH)
2715 continue; 2721 continue;
2716 if (BE (err != REG_NOERROR, 0)) 2722 if (__glibc_unlikely (err != REG_NOERROR))
2717 return err; 2723 return err;
2718 } 2724 }
2719 2725
@@ -2732,14 +2738,14 @@ get_subexp (re_match_context_t *mctx, Idx bkref_node, Idx bkref_str_idx)
2732 at the back reference? */ 2738 at the back reference? */
2733 if (sl_str_off > 0) 2739 if (sl_str_off > 0)
2734 { 2740 {
2735 if (BE (bkref_str_off >= mctx->input.valid_len, 0)) 2741 if (__glibc_unlikely (bkref_str_off >= mctx->input.valid_len))
2736 { 2742 {
2737 /* If we are at the end of the input, we cannot match. */ 2743 /* If we are at the end of the input, we cannot match. */
2738 if (bkref_str_off >= mctx->input.len) 2744 if (bkref_str_off >= mctx->input.len)
2739 break; 2745 break;
2740 2746
2741 err = extend_buffers (mctx, bkref_str_off + 1); 2747 err = extend_buffers (mctx, bkref_str_off + 1);
2742 if (BE (err != REG_NOERROR, 0)) 2748 if (__glibc_unlikely (err != REG_NOERROR))
2743 return err; 2749 return err;
2744 2750
2745 buf = (const char *) re_string_get_buffer (&mctx->input); 2751 buf = (const char *) re_string_get_buffer (&mctx->input);
@@ -2770,10 +2776,10 @@ get_subexp (re_match_context_t *mctx, Idx bkref_node, Idx bkref_str_idx)
2770 OP_CLOSE_SUBEXP); 2776 OP_CLOSE_SUBEXP);
2771 if (err == REG_NOMATCH) 2777 if (err == REG_NOMATCH)
2772 continue; 2778 continue;
2773 if (BE (err != REG_NOERROR, 0)) 2779 if (__glibc_unlikely (err != REG_NOERROR))
2774 return err; 2780 return err;
2775 sub_last = match_ctx_add_sublast (sub_top, cls_node, sl_str); 2781 sub_last = match_ctx_add_sublast (sub_top, cls_node, sl_str);
2776 if (BE (sub_last == NULL, 0)) 2782 if (__glibc_unlikely (sub_last == NULL))
2777 return REG_ESPACE; 2783 return REG_ESPACE;
2778 err = get_subexp_sub (mctx, sub_top, sub_last, bkref_node, 2784 err = get_subexp_sub (mctx, sub_top, sub_last, bkref_node,
2779 bkref_str_idx); 2785 bkref_str_idx);
@@ -2804,7 +2810,7 @@ get_subexp_sub (re_match_context_t *mctx, const re_sub_match_top_t *sub_top,
2804 return err; 2810 return err;
2805 err = match_ctx_add_entry (mctx, bkref_node, bkref_str, sub_top->str_idx, 2811 err = match_ctx_add_entry (mctx, bkref_node, bkref_str, sub_top->str_idx,
2806 sub_last->str_idx); 2812 sub_last->str_idx);
2807 if (BE (err != REG_NOERROR, 0)) 2813 if (__glibc_unlikely (err != REG_NOERROR))
2808 return err; 2814 return err;
2809 to_idx = bkref_str + sub_last->str_idx - sub_top->str_idx; 2815 to_idx = bkref_str + sub_last->str_idx - sub_top->str_idx;
2810 return clean_state_log_if_needed (mctx, to_idx); 2816 return clean_state_log_if_needed (mctx, to_idx);
@@ -2854,19 +2860,19 @@ check_arrival (re_match_context_t *mctx, state_array_t *path, Idx top_node,
2854 2860
2855 subexp_num = dfa->nodes[top_node].opr.idx; 2861 subexp_num = dfa->nodes[top_node].opr.idx;
2856 /* Extend the buffer if we need. */ 2862 /* Extend the buffer if we need. */
2857 if (BE (path->alloc < last_str + mctx->max_mb_elem_len + 1, 0)) 2863 if (__glibc_unlikely (path->alloc < last_str + mctx->max_mb_elem_len + 1))
2858 { 2864 {
2859 re_dfastate_t **new_array; 2865 re_dfastate_t **new_array;
2860 Idx old_alloc = path->alloc; 2866 Idx old_alloc = path->alloc;
2861 Idx incr_alloc = last_str + mctx->max_mb_elem_len + 1; 2867 Idx incr_alloc = last_str + mctx->max_mb_elem_len + 1;
2862 Idx new_alloc; 2868 Idx new_alloc;
2863 if (BE (IDX_MAX - old_alloc < incr_alloc, 0)) 2869 if (__glibc_unlikely (IDX_MAX - old_alloc < incr_alloc))
2864 return REG_ESPACE; 2870 return REG_ESPACE;
2865 new_alloc = old_alloc + incr_alloc; 2871 new_alloc = old_alloc + incr_alloc;
2866 if (BE (SIZE_MAX / sizeof (re_dfastate_t *) < new_alloc, 0)) 2872 if (__glibc_unlikely (SIZE_MAX / sizeof (re_dfastate_t *) < new_alloc))
2867 return REG_ESPACE; 2873 return REG_ESPACE;
2868 new_array = re_realloc (path->array, re_dfastate_t *, new_alloc); 2874 new_array = re_realloc (path->array, re_dfastate_t *, new_alloc);
2869 if (BE (new_array == NULL, 0)) 2875 if (__glibc_unlikely (new_array == NULL))
2870 return REG_ESPACE; 2876 return REG_ESPACE;
2871 path->array = new_array; 2877 path->array = new_array;
2872 path->alloc = new_alloc; 2878 path->alloc = new_alloc;
@@ -2887,10 +2893,10 @@ check_arrival (re_match_context_t *mctx, state_array_t *path, Idx top_node,
2887 if (str_idx == top_str) 2893 if (str_idx == top_str)
2888 { 2894 {
2889 err = re_node_set_init_1 (&next_nodes, top_node); 2895 err = re_node_set_init_1 (&next_nodes, top_node);
2890 if (BE (err != REG_NOERROR, 0)) 2896 if (__glibc_unlikely (err != REG_NOERROR))
2891 return err; 2897 return err;
2892 err = check_arrival_expand_ecl (dfa, &next_nodes, subexp_num, type); 2898 err = check_arrival_expand_ecl (dfa, &next_nodes, subexp_num, type);
2893 if (BE (err != REG_NOERROR, 0)) 2899 if (__glibc_unlikely (err != REG_NOERROR))
2894 { 2900 {
2895 re_node_set_free (&next_nodes); 2901 re_node_set_free (&next_nodes);
2896 return err; 2902 return err;
@@ -2902,7 +2908,7 @@ check_arrival (re_match_context_t *mctx, state_array_t *path, Idx top_node,
2902 if (cur_state && cur_state->has_backref) 2908 if (cur_state && cur_state->has_backref)
2903 { 2909 {
2904 err = re_node_set_init_copy (&next_nodes, &cur_state->nodes); 2910 err = re_node_set_init_copy (&next_nodes, &cur_state->nodes);
2905 if (BE (err != REG_NOERROR, 0)) 2911 if (__glibc_unlikely (err != REG_NOERROR))
2906 return err; 2912 return err;
2907 } 2913 }
2908 else 2914 else
@@ -2914,14 +2920,14 @@ check_arrival (re_match_context_t *mctx, state_array_t *path, Idx top_node,
2914 { 2920 {
2915 err = expand_bkref_cache (mctx, &next_nodes, str_idx, 2921 err = expand_bkref_cache (mctx, &next_nodes, str_idx,
2916 subexp_num, type); 2922 subexp_num, type);
2917 if (BE (err != REG_NOERROR, 0)) 2923 if (__glibc_unlikely (err != REG_NOERROR))
2918 { 2924 {
2919 re_node_set_free (&next_nodes); 2925 re_node_set_free (&next_nodes);
2920 return err; 2926 return err;
2921 } 2927 }
2922 } 2928 }
2923 cur_state = re_acquire_state_context (&err, dfa, &next_nodes, context); 2929 cur_state = re_acquire_state_context (&err, dfa, &next_nodes, context);
2924 if (BE (cur_state == NULL && err != REG_NOERROR, 0)) 2930 if (__glibc_unlikely (cur_state == NULL && err != REG_NOERROR))
2925 { 2931 {
2926 re_node_set_free (&next_nodes); 2932 re_node_set_free (&next_nodes);
2927 return err; 2933 return err;
@@ -2936,7 +2942,7 @@ check_arrival (re_match_context_t *mctx, state_array_t *path, Idx top_node,
2936 { 2942 {
2937 err = re_node_set_merge (&next_nodes, 2943 err = re_node_set_merge (&next_nodes,
2938 &mctx->state_log[str_idx + 1]->nodes); 2944 &mctx->state_log[str_idx + 1]->nodes);
2939 if (BE (err != REG_NOERROR, 0)) 2945 if (__glibc_unlikely (err != REG_NOERROR))
2940 { 2946 {
2941 re_node_set_free (&next_nodes); 2947 re_node_set_free (&next_nodes);
2942 return err; 2948 return err;
@@ -2947,7 +2953,7 @@ check_arrival (re_match_context_t *mctx, state_array_t *path, Idx top_node,
2947 err = check_arrival_add_next_nodes (mctx, str_idx, 2953 err = check_arrival_add_next_nodes (mctx, str_idx,
2948 &cur_state->non_eps_nodes, 2954 &cur_state->non_eps_nodes,
2949 &next_nodes); 2955 &next_nodes);
2950 if (BE (err != REG_NOERROR, 0)) 2956 if (__glibc_unlikely (err != REG_NOERROR))
2951 { 2957 {
2952 re_node_set_free (&next_nodes); 2958 re_node_set_free (&next_nodes);
2953 return err; 2959 return err;
@@ -2957,14 +2963,14 @@ check_arrival (re_match_context_t *mctx, state_array_t *path, Idx top_node,
2957 if (next_nodes.nelem) 2963 if (next_nodes.nelem)
2958 { 2964 {
2959 err = check_arrival_expand_ecl (dfa, &next_nodes, subexp_num, type); 2965 err = check_arrival_expand_ecl (dfa, &next_nodes, subexp_num, type);
2960 if (BE (err != REG_NOERROR, 0)) 2966 if (__glibc_unlikely (err != REG_NOERROR))
2961 { 2967 {
2962 re_node_set_free (&next_nodes); 2968 re_node_set_free (&next_nodes);
2963 return err; 2969 return err;
2964 } 2970 }
2965 err = expand_bkref_cache (mctx, &next_nodes, str_idx, 2971 err = expand_bkref_cache (mctx, &next_nodes, str_idx,
2966 subexp_num, type); 2972 subexp_num, type);
2967 if (BE (err != REG_NOERROR, 0)) 2973 if (__glibc_unlikely (err != REG_NOERROR))
2968 { 2974 {
2969 re_node_set_free (&next_nodes); 2975 re_node_set_free (&next_nodes);
2970 return err; 2976 return err;
@@ -2972,7 +2978,7 @@ check_arrival (re_match_context_t *mctx, state_array_t *path, Idx top_node,
2972 } 2978 }
2973 context = re_string_context_at (&mctx->input, str_idx - 1, mctx->eflags); 2979 context = re_string_context_at (&mctx->input, str_idx - 1, mctx->eflags);
2974 cur_state = re_acquire_state_context (&err, dfa, &next_nodes, context); 2980 cur_state = re_acquire_state_context (&err, dfa, &next_nodes, context);
2975 if (BE (cur_state == NULL && err != REG_NOERROR, 0)) 2981 if (__glibc_unlikely (cur_state == NULL && err != REG_NOERROR))
2976 { 2982 {
2977 re_node_set_free (&next_nodes); 2983 re_node_set_free (&next_nodes);
2978 return err; 2984 return err;
@@ -3041,22 +3047,22 @@ check_arrival_add_next_nodes (re_match_context_t *mctx, Idx str_idx,
3041 if (dest_state) 3047 if (dest_state)
3042 { 3048 {
3043 err = re_node_set_merge (&union_set, &dest_state->nodes); 3049 err = re_node_set_merge (&union_set, &dest_state->nodes);
3044 if (BE (err != REG_NOERROR, 0)) 3050 if (__glibc_unlikely (err != REG_NOERROR))
3045 { 3051 {
3046 re_node_set_free (&union_set); 3052 re_node_set_free (&union_set);
3047 return err; 3053 return err;
3048 } 3054 }
3049 } 3055 }
3050 ok = re_node_set_insert (&union_set, next_node); 3056 ok = re_node_set_insert (&union_set, next_node);
3051 if (BE (! ok, 0)) 3057 if (__glibc_unlikely (! ok))
3052 { 3058 {
3053 re_node_set_free (&union_set); 3059 re_node_set_free (&union_set);
3054 return REG_ESPACE; 3060 return REG_ESPACE;
3055 } 3061 }
3056 mctx->state_log[next_idx] = re_acquire_state (&err, dfa, 3062 mctx->state_log[next_idx] = re_acquire_state (&err, dfa,
3057 &union_set); 3063 &union_set);
3058 if (BE (mctx->state_log[next_idx] == NULL 3064 if (__glibc_unlikely (mctx->state_log[next_idx] == NULL
3059 && err != REG_NOERROR, 0)) 3065 && err != REG_NOERROR))
3060 { 3066 {
3061 re_node_set_free (&union_set); 3067 re_node_set_free (&union_set);
3062 return err; 3068 return err;
@@ -3068,7 +3074,7 @@ check_arrival_add_next_nodes (re_match_context_t *mctx, Idx str_idx,
3068 || check_node_accept (mctx, dfa->nodes + cur_node, str_idx)) 3074 || check_node_accept (mctx, dfa->nodes + cur_node, str_idx))
3069 { 3075 {
3070 ok = re_node_set_insert (next_nodes, dfa->nexts[cur_node]); 3076 ok = re_node_set_insert (next_nodes, dfa->nexts[cur_node]);
3071 if (BE (! ok, 0)) 3077 if (__glibc_unlikely (! ok))
3072 { 3078 {
3073 re_node_set_free (&union_set); 3079 re_node_set_free (&union_set);
3074 return REG_ESPACE; 3080 return REG_ESPACE;
@@ -3096,7 +3102,7 @@ check_arrival_expand_ecl (const re_dfa_t *dfa, re_node_set *cur_nodes,
3096 assert (cur_nodes->nelem); 3102 assert (cur_nodes->nelem);
3097#endif 3103#endif
3098 err = re_node_set_alloc (&new_nodes, cur_nodes->nelem); 3104 err = re_node_set_alloc (&new_nodes, cur_nodes->nelem);
3099 if (BE (err != REG_NOERROR, 0)) 3105 if (__glibc_unlikely (err != REG_NOERROR))
3100 return err; 3106 return err;
3101 /* Create a new node set NEW_NODES with the nodes which are epsilon 3107 /* Create a new node set NEW_NODES with the nodes which are epsilon
3102 closures of the node in CUR_NODES. */ 3108 closures of the node in CUR_NODES. */
@@ -3110,7 +3116,7 @@ check_arrival_expand_ecl (const re_dfa_t *dfa, re_node_set *cur_nodes,
3110 { 3116 {
3111 /* There are no problematic nodes, just merge them. */ 3117 /* There are no problematic nodes, just merge them. */
3112 err = re_node_set_merge (&new_nodes, eclosure); 3118 err = re_node_set_merge (&new_nodes, eclosure);
3113 if (BE (err != REG_NOERROR, 0)) 3119 if (__glibc_unlikely (err != REG_NOERROR))
3114 { 3120 {
3115 re_node_set_free (&new_nodes); 3121 re_node_set_free (&new_nodes);
3116 return err; 3122 return err;
@@ -3121,7 +3127,7 @@ check_arrival_expand_ecl (const re_dfa_t *dfa, re_node_set *cur_nodes,
3121 /* There are problematic nodes, re-calculate incrementally. */ 3127 /* There are problematic nodes, re-calculate incrementally. */
3122 err = check_arrival_expand_ecl_sub (dfa, &new_nodes, cur_node, 3128 err = check_arrival_expand_ecl_sub (dfa, &new_nodes, cur_node,
3123 ex_subexp, type); 3129 ex_subexp, type);
3124 if (BE (err != REG_NOERROR, 0)) 3130 if (__glibc_unlikely (err != REG_NOERROR))
3125 { 3131 {
3126 re_node_set_free (&new_nodes); 3132 re_node_set_free (&new_nodes);
3127 return err; 3133 return err;
@@ -3153,13 +3159,13 @@ check_arrival_expand_ecl_sub (const re_dfa_t *dfa, re_node_set *dst_nodes,
3153 if (type == OP_CLOSE_SUBEXP) 3159 if (type == OP_CLOSE_SUBEXP)
3154 { 3160 {
3155 ok = re_node_set_insert (dst_nodes, cur_node); 3161 ok = re_node_set_insert (dst_nodes, cur_node);
3156 if (BE (! ok, 0)) 3162 if (__glibc_unlikely (! ok))
3157 return REG_ESPACE; 3163 return REG_ESPACE;
3158 } 3164 }
3159 break; 3165 break;
3160 } 3166 }
3161 ok = re_node_set_insert (dst_nodes, cur_node); 3167 ok = re_node_set_insert (dst_nodes, cur_node);
3162 if (BE (! ok, 0)) 3168 if (__glibc_unlikely (! ok))
3163 return REG_ESPACE; 3169 return REG_ESPACE;
3164 if (dfa->edests[cur_node].nelem == 0) 3170 if (dfa->edests[cur_node].nelem == 0)
3165 break; 3171 break;
@@ -3169,7 +3175,7 @@ check_arrival_expand_ecl_sub (const re_dfa_t *dfa, re_node_set *dst_nodes,
3169 err = check_arrival_expand_ecl_sub (dfa, dst_nodes, 3175 err = check_arrival_expand_ecl_sub (dfa, dst_nodes,
3170 dfa->edests[cur_node].elems[1], 3176 dfa->edests[cur_node].elems[1],
3171 ex_subexp, type); 3177 ex_subexp, type);
3172 if (BE (err != REG_NOERROR, 0)) 3178 if (__glibc_unlikely (err != REG_NOERROR))
3173 return err; 3179 return err;
3174 } 3180 }
3175 cur_node = dfa->edests[cur_node].elems[0]; 3181 cur_node = dfa->edests[cur_node].elems[0];
@@ -3221,8 +3227,8 @@ expand_bkref_cache (re_match_context_t *mctx, re_node_set *cur_nodes,
3221 err2 = check_arrival_expand_ecl (dfa, &new_dests, subexp_num, type); 3227 err2 = check_arrival_expand_ecl (dfa, &new_dests, subexp_num, type);
3222 err3 = re_node_set_merge (cur_nodes, &new_dests); 3228 err3 = re_node_set_merge (cur_nodes, &new_dests);
3223 re_node_set_free (&new_dests); 3229 re_node_set_free (&new_dests);
3224 if (BE (err != REG_NOERROR || err2 != REG_NOERROR 3230 if (__glibc_unlikely (err != REG_NOERROR || err2 != REG_NOERROR
3225 || err3 != REG_NOERROR, 0)) 3231 || err3 != REG_NOERROR))
3226 { 3232 {
3227 err = (err != REG_NOERROR ? err 3233 err = (err != REG_NOERROR ? err
3228 : (err2 != REG_NOERROR ? err2 : err3)); 3234 : (err2 != REG_NOERROR ? err2 : err3));
@@ -3244,7 +3250,7 @@ expand_bkref_cache (re_match_context_t *mctx, re_node_set *cur_nodes,
3244 err = re_node_set_init_copy (&union_set, 3250 err = re_node_set_init_copy (&union_set,
3245 &mctx->state_log[to_idx]->nodes); 3251 &mctx->state_log[to_idx]->nodes);
3246 ok = re_node_set_insert (&union_set, next_node); 3252 ok = re_node_set_insert (&union_set, next_node);
3247 if (BE (err != REG_NOERROR || ! ok, 0)) 3253 if (__glibc_unlikely (err != REG_NOERROR || ! ok))
3248 { 3254 {
3249 re_node_set_free (&union_set); 3255 re_node_set_free (&union_set);
3250 err = err != REG_NOERROR ? err : REG_ESPACE; 3256 err = err != REG_NOERROR ? err : REG_ESPACE;
@@ -3254,13 +3260,13 @@ expand_bkref_cache (re_match_context_t *mctx, re_node_set *cur_nodes,
3254 else 3260 else
3255 { 3261 {
3256 err = re_node_set_init_1 (&union_set, next_node); 3262 err = re_node_set_init_1 (&union_set, next_node);
3257 if (BE (err != REG_NOERROR, 0)) 3263 if (__glibc_unlikely (err != REG_NOERROR))
3258 return err; 3264 return err;
3259 } 3265 }
3260 mctx->state_log[to_idx] = re_acquire_state (&err, dfa, &union_set); 3266 mctx->state_log[to_idx] = re_acquire_state (&err, dfa, &union_set);
3261 re_node_set_free (&union_set); 3267 re_node_set_free (&union_set);
3262 if (BE (mctx->state_log[to_idx] == NULL 3268 if (__glibc_unlikely (mctx->state_log[to_idx] == NULL
3263 && err != REG_NOERROR, 0)) 3269 && err != REG_NOERROR))
3264 return err; 3270 return err;
3265 } 3271 }
3266 } 3272 }
@@ -3303,7 +3309,7 @@ build_trtable (const re_dfa_t *dfa, re_dfastate_t *state)
3303 else 3309 else
3304 { 3310 {
3305 dests_alloc = re_malloc (struct dests_alloc, 1); 3311 dests_alloc = re_malloc (struct dests_alloc, 1);
3306 if (BE (dests_alloc == NULL, 0)) 3312 if (__glibc_unlikely (dests_alloc == NULL))
3307 return false; 3313 return false;
3308 dests_node_malloced = true; 3314 dests_node_malloced = true;
3309 } 3315 }
@@ -3316,7 +3322,7 @@ build_trtable (const re_dfa_t *dfa, re_dfastate_t *state)
3316 /* At first, group all nodes belonging to 'state' into several 3322 /* At first, group all nodes belonging to 'state' into several
3317 destinations. */ 3323 destinations. */
3318 ndests = group_nodes_into_DFAstates (dfa, state, dests_node, dests_ch); 3324 ndests = group_nodes_into_DFAstates (dfa, state, dests_node, dests_ch);
3319 if (BE (ndests <= 0, 0)) 3325 if (__glibc_unlikely (ndests <= 0))
3320 { 3326 {
3321 if (dests_node_malloced) 3327 if (dests_node_malloced)
3322 re_free (dests_alloc); 3328 re_free (dests_alloc);
@@ -3325,7 +3331,7 @@ build_trtable (const re_dfa_t *dfa, re_dfastate_t *state)
3325 { 3331 {
3326 state->trtable = (re_dfastate_t **) 3332 state->trtable = (re_dfastate_t **)
3327 calloc (sizeof (re_dfastate_t *), SBC_MAX); 3333 calloc (sizeof (re_dfastate_t *), SBC_MAX);
3328 if (BE (state->trtable == NULL, 0)) 3334 if (__glibc_unlikely (state->trtable == NULL))
3329 return false; 3335 return false;
3330 return true; 3336 return true;
3331 } 3337 }
@@ -3333,14 +3339,14 @@ build_trtable (const re_dfa_t *dfa, re_dfastate_t *state)
3333 } 3339 }
3334 3340
3335 err = re_node_set_alloc (&follows, ndests + 1); 3341 err = re_node_set_alloc (&follows, ndests + 1);
3336 if (BE (err != REG_NOERROR, 0)) 3342 if (__glibc_unlikely (err != REG_NOERROR))
3337 goto out_free; 3343 goto out_free;
3338 3344
3339 /* Avoid arithmetic overflow in size calculation. */ 3345 /* Avoid arithmetic overflow in size calculation. */
3340 if (BE ((((SIZE_MAX - (sizeof (re_node_set) + sizeof (bitset_t)) * SBC_MAX) 3346 size_t ndests_max
3341 / (3 * sizeof (re_dfastate_t *))) 3347 = ((SIZE_MAX - (sizeof (re_node_set) + sizeof (bitset_t)) * SBC_MAX)
3342 < ndests), 3348 / (3 * sizeof (re_dfastate_t *)));
3343 0)) 3349 if (__glibc_unlikely (ndests_max < ndests))
3344 goto out_free; 3350 goto out_free;
3345 3351
3346 if (__libc_use_alloca ((sizeof (re_node_set) + sizeof (bitset_t)) * SBC_MAX 3352 if (__libc_use_alloca ((sizeof (re_node_set) + sizeof (bitset_t)) * SBC_MAX
@@ -3350,7 +3356,7 @@ build_trtable (const re_dfa_t *dfa, re_dfastate_t *state)
3350 else 3356 else
3351 { 3357 {
3352 dest_states = re_malloc (re_dfastate_t *, ndests * 3); 3358 dest_states = re_malloc (re_dfastate_t *, ndests * 3);
3353 if (BE (dest_states == NULL, 0)) 3359 if (__glibc_unlikely (dest_states == NULL))
3354 { 3360 {
3355out_free: 3361out_free:
3356 if (dest_states_malloced) 3362 if (dest_states_malloced)
@@ -3380,12 +3386,12 @@ out_free:
3380 if (next_node != -1) 3386 if (next_node != -1)
3381 { 3387 {
3382 err = re_node_set_merge (&follows, dfa->eclosures + next_node); 3388 err = re_node_set_merge (&follows, dfa->eclosures + next_node);
3383 if (BE (err != REG_NOERROR, 0)) 3389 if (__glibc_unlikely (err != REG_NOERROR))
3384 goto out_free; 3390 goto out_free;
3385 } 3391 }
3386 } 3392 }
3387 dest_states[i] = re_acquire_state_context (&err, dfa, &follows, 0); 3393 dest_states[i] = re_acquire_state_context (&err, dfa, &follows, 0);
3388 if (BE (dest_states[i] == NULL && err != REG_NOERROR, 0)) 3394 if (__glibc_unlikely (dest_states[i] == NULL && err != REG_NOERROR))
3389 goto out_free; 3395 goto out_free;
3390 /* If the new state has context constraint, 3396 /* If the new state has context constraint,
3391 build appropriate states for these contexts. */ 3397 build appropriate states for these contexts. */
@@ -3393,7 +3399,8 @@ out_free:
3393 { 3399 {
3394 dest_states_word[i] = re_acquire_state_context (&err, dfa, &follows, 3400 dest_states_word[i] = re_acquire_state_context (&err, dfa, &follows,
3395 CONTEXT_WORD); 3401 CONTEXT_WORD);
3396 if (BE (dest_states_word[i] == NULL && err != REG_NOERROR, 0)) 3402 if (__glibc_unlikely (dest_states_word[i] == NULL
3403 && err != REG_NOERROR))
3397 goto out_free; 3404 goto out_free;
3398 3405
3399 if (dest_states[i] != dest_states_word[i] && dfa->mb_cur_max > 1) 3406 if (dest_states[i] != dest_states_word[i] && dfa->mb_cur_max > 1)
@@ -3401,7 +3408,7 @@ out_free:
3401 3408
3402 dest_states_nl[i] = re_acquire_state_context (&err, dfa, &follows, 3409 dest_states_nl[i] = re_acquire_state_context (&err, dfa, &follows,
3403 CONTEXT_NEWLINE); 3410 CONTEXT_NEWLINE);
3404 if (BE (dest_states_nl[i] == NULL && err != REG_NOERROR, 0)) 3411 if (__glibc_unlikely (dest_states_nl[i] == NULL && err != REG_NOERROR))
3405 goto out_free; 3412 goto out_free;
3406 } 3413 }
3407 else 3414 else
@@ -3412,7 +3419,7 @@ out_free:
3412 bitset_merge (acceptable, dests_ch[i]); 3419 bitset_merge (acceptable, dests_ch[i]);
3413 } 3420 }
3414 3421
3415 if (!BE (need_word_trtable, 0)) 3422 if (!__glibc_unlikely (need_word_trtable))
3416 { 3423 {
3417 /* We don't care about whether the following character is a word 3424 /* We don't care about whether the following character is a word
3418 character, or we are in a single-byte character set so we can 3425 character, or we are in a single-byte character set so we can
@@ -3420,7 +3427,7 @@ out_free:
3420 256-entry transition table. */ 3427 256-entry transition table. */
3421 trtable = state->trtable = 3428 trtable = state->trtable =
3422 (re_dfastate_t **) calloc (sizeof (re_dfastate_t *), SBC_MAX); 3429 (re_dfastate_t **) calloc (sizeof (re_dfastate_t *), SBC_MAX);
3423 if (BE (trtable == NULL, 0)) 3430 if (__glibc_unlikely (trtable == NULL))
3424 goto out_free; 3431 goto out_free;
3425 3432
3426 /* For all characters ch...: */ 3433 /* For all characters ch...: */
@@ -3428,7 +3435,7 @@ out_free:
3428 for (ch = i * BITSET_WORD_BITS, elem = acceptable[i], mask = 1; 3435 for (ch = i * BITSET_WORD_BITS, elem = acceptable[i], mask = 1;
3429 elem; 3436 elem;
3430 mask <<= 1, elem >>= 1, ++ch) 3437 mask <<= 1, elem >>= 1, ++ch)
3431 if (BE (elem & 1, 0)) 3438 if (__glibc_unlikely (elem & 1))
3432 { 3439 {
3433 /* There must be exactly one destination which accepts 3440 /* There must be exactly one destination which accepts
3434 character ch. See group_nodes_into_DFAstates. */ 3441 character ch. See group_nodes_into_DFAstates. */
@@ -3451,7 +3458,7 @@ out_free:
3451 starting at trtable[SBC_MAX]. */ 3458 starting at trtable[SBC_MAX]. */
3452 trtable = state->word_trtable = 3459 trtable = state->word_trtable =
3453 (re_dfastate_t **) calloc (sizeof (re_dfastate_t *), 2 * SBC_MAX); 3460 (re_dfastate_t **) calloc (sizeof (re_dfastate_t *), 2 * SBC_MAX);
3454 if (BE (trtable == NULL, 0)) 3461 if (__glibc_unlikely (trtable == NULL))
3455 goto out_free; 3462 goto out_free;
3456 3463
3457 /* For all characters ch...: */ 3464 /* For all characters ch...: */
@@ -3459,7 +3466,7 @@ out_free:
3459 for (ch = i * BITSET_WORD_BITS, elem = acceptable[i], mask = 1; 3466 for (ch = i * BITSET_WORD_BITS, elem = acceptable[i], mask = 1;
3460 elem; 3467 elem;
3461 mask <<= 1, elem >>= 1, ++ch) 3468 mask <<= 1, elem >>= 1, ++ch)
3462 if (BE (elem & 1, 0)) 3469 if (__glibc_unlikely (elem & 1))
3463 { 3470 {
3464 /* There must be exactly one destination which accepts 3471 /* There must be exactly one destination which accepts
3465 character ch. See group_nodes_into_DFAstates. */ 3472 character ch. See group_nodes_into_DFAstates. */
@@ -3658,14 +3665,14 @@ group_nodes_into_DFAstates (const re_dfa_t *dfa, const re_dfastate_t *state,
3658 bitset_copy (dests_ch[ndests], remains); 3665 bitset_copy (dests_ch[ndests], remains);
3659 bitset_copy (dests_ch[j], intersec); 3666 bitset_copy (dests_ch[j], intersec);
3660 err = re_node_set_init_copy (dests_node + ndests, &dests_node[j]); 3667 err = re_node_set_init_copy (dests_node + ndests, &dests_node[j]);
3661 if (BE (err != REG_NOERROR, 0)) 3668 if (__glibc_unlikely (err != REG_NOERROR))
3662 goto error_return; 3669 goto error_return;
3663 ++ndests; 3670 ++ndests;
3664 } 3671 }
3665 3672
3666 /* Put the position in the current group. */ 3673 /* Put the position in the current group. */
3667 ok = re_node_set_insert (&dests_node[j], cur_nodes->elems[i]); 3674 ok = re_node_set_insert (&dests_node[j], cur_nodes->elems[i]);
3668 if (BE (! ok, 0)) 3675 if (__glibc_unlikely (! ok))
3669 goto error_return; 3676 goto error_return;
3670 3677
3671 /* If all characters are consumed, go to next node. */ 3678 /* If all characters are consumed, go to next node. */
@@ -3677,7 +3684,7 @@ group_nodes_into_DFAstates (const re_dfa_t *dfa, const re_dfastate_t *state,
3677 { 3684 {
3678 bitset_copy (dests_ch[ndests], accepts); 3685 bitset_copy (dests_ch[ndests], accepts);
3679 err = re_node_set_init_1 (dests_node + ndests, cur_nodes->elems[i]); 3686 err = re_node_set_init_1 (dests_node + ndests, cur_nodes->elems[i]);
3680 if (BE (err != REG_NOERROR, 0)) 3687 if (__glibc_unlikely (err != REG_NOERROR))
3681 goto error_return; 3688 goto error_return;
3682 ++ndests; 3689 ++ndests;
3683 bitset_empty (accepts); 3690 bitset_empty (accepts);
@@ -3711,10 +3718,10 @@ check_node_accept_bytes (const re_dfa_t *dfa, Idx node_idx,
3711 int char_len, elem_len; 3718 int char_len, elem_len;
3712 Idx i; 3719 Idx i;
3713 3720
3714 if (BE (node->type == OP_UTF8_PERIOD, 0)) 3721 if (__glibc_unlikely (node->type == OP_UTF8_PERIOD))
3715 { 3722 {
3716 unsigned char c = re_string_byte_at (input, str_idx), d; 3723 unsigned char c = re_string_byte_at (input, str_idx), d;
3717 if (BE (c < 0xc2, 1)) 3724 if (__glibc_likely (c < 0xc2))
3718 return 0; 3725 return 0;
3719 3726
3720 if (str_idx + 2 > input->len) 3727 if (str_idx + 2 > input->len)
@@ -4049,15 +4056,15 @@ extend_buffers (re_match_context_t *mctx, int min_len)
4049 re_string_t *pstr = &mctx->input; 4056 re_string_t *pstr = &mctx->input;
4050 4057
4051 /* Avoid overflow. */ 4058 /* Avoid overflow. */
4052 if (BE (MIN (IDX_MAX, SIZE_MAX / sizeof (re_dfastate_t *)) / 2 4059 if (__glibc_unlikely (MIN (IDX_MAX, SIZE_MAX / sizeof (re_dfastate_t *)) / 2
4053 <= pstr->bufs_len, 0)) 4060 <= pstr->bufs_len))
4054 return REG_ESPACE; 4061 return REG_ESPACE;
4055 4062
4056 /* Double the lengths of the buffers, but allocate at least MIN_LEN. */ 4063 /* Double the lengths of the buffers, but allocate at least MIN_LEN. */
4057 ret = re_string_realloc_buffers (pstr, 4064 ret = re_string_realloc_buffers (pstr,
4058 MAX (min_len, 4065 MAX (min_len,
4059 MIN (pstr->len, pstr->bufs_len * 2))); 4066 MIN (pstr->len, pstr->bufs_len * 2)));
4060 if (BE (ret != REG_NOERROR, 0)) 4067 if (__glibc_unlikely (ret != REG_NOERROR))
4061 return ret; 4068 return ret;
4062 4069
4063 if (mctx->state_log != NULL) 4070 if (mctx->state_log != NULL)
@@ -4068,7 +4075,7 @@ extend_buffers (re_match_context_t *mctx, int min_len)
4068 does not have the right size. */ 4075 does not have the right size. */
4069 re_dfastate_t **new_array = re_realloc (mctx->state_log, re_dfastate_t *, 4076 re_dfastate_t **new_array = re_realloc (mctx->state_log, re_dfastate_t *,
4070 pstr->bufs_len + 1); 4077 pstr->bufs_len + 1);
4071 if (BE (new_array == NULL, 0)) 4078 if (__glibc_unlikely (new_array == NULL))
4072 return REG_ESPACE; 4079 return REG_ESPACE;
4073 mctx->state_log = new_array; 4080 mctx->state_log = new_array;
4074 } 4081 }
@@ -4080,7 +4087,7 @@ extend_buffers (re_match_context_t *mctx, int min_len)
4080 if (pstr->mb_cur_max > 1) 4087 if (pstr->mb_cur_max > 1)
4081 { 4088 {
4082 ret = build_wcs_upper_buffer (pstr); 4089 ret = build_wcs_upper_buffer (pstr);
4083 if (BE (ret != REG_NOERROR, 0)) 4090 if (__glibc_unlikely (ret != REG_NOERROR))
4084 return ret; 4091 return ret;
4085 } 4092 }
4086 else 4093 else
@@ -4119,12 +4126,12 @@ match_ctx_init (re_match_context_t *mctx, int eflags, Idx n)
4119 size_t max_object_size = 4126 size_t max_object_size =
4120 MAX (sizeof (struct re_backref_cache_entry), 4127 MAX (sizeof (struct re_backref_cache_entry),
4121 sizeof (re_sub_match_top_t *)); 4128 sizeof (re_sub_match_top_t *));
4122 if (BE (MIN (IDX_MAX, SIZE_MAX / max_object_size) < n, 0)) 4129 if (__glibc_unlikely (MIN (IDX_MAX, SIZE_MAX / max_object_size) < n))
4123 return REG_ESPACE; 4130 return REG_ESPACE;
4124 4131
4125 mctx->bkref_ents = re_malloc (struct re_backref_cache_entry, n); 4132 mctx->bkref_ents = re_malloc (struct re_backref_cache_entry, n);
4126 mctx->sub_tops = re_malloc (re_sub_match_top_t *, n); 4133 mctx->sub_tops = re_malloc (re_sub_match_top_t *, n);
4127 if (BE (mctx->bkref_ents == NULL || mctx->sub_tops == NULL, 0)) 4134 if (__glibc_unlikely (mctx->bkref_ents == NULL || mctx->sub_tops == NULL))
4128 return REG_ESPACE; 4135 return REG_ESPACE;
4129 } 4136 }
4130 /* Already zero-ed by the caller. 4137 /* Already zero-ed by the caller.
@@ -4195,7 +4202,7 @@ match_ctx_add_entry (re_match_context_t *mctx, Idx node, Idx str_idx, Idx from,
4195 struct re_backref_cache_entry* new_entry; 4202 struct re_backref_cache_entry* new_entry;
4196 new_entry = re_realloc (mctx->bkref_ents, struct re_backref_cache_entry, 4203 new_entry = re_realloc (mctx->bkref_ents, struct re_backref_cache_entry,
4197 mctx->abkref_ents * 2); 4204 mctx->abkref_ents * 2);
4198 if (BE (new_entry == NULL, 0)) 4205 if (__glibc_unlikely (new_entry == NULL))
4199 { 4206 {
4200 re_free (mctx->bkref_ents); 4207 re_free (mctx->bkref_ents);
4201 return REG_ESPACE; 4208 return REG_ESPACE;
@@ -4264,19 +4271,19 @@ match_ctx_add_subtop (re_match_context_t *mctx, Idx node, Idx str_idx)
4264 assert (mctx->sub_tops != NULL); 4271 assert (mctx->sub_tops != NULL);
4265 assert (mctx->asub_tops > 0); 4272 assert (mctx->asub_tops > 0);
4266#endif 4273#endif
4267 if (BE (mctx->nsub_tops == mctx->asub_tops, 0)) 4274 if (__glibc_unlikely (mctx->nsub_tops == mctx->asub_tops))
4268 { 4275 {
4269 Idx new_asub_tops = mctx->asub_tops * 2; 4276 Idx new_asub_tops = mctx->asub_tops * 2;
4270 re_sub_match_top_t **new_array = re_realloc (mctx->sub_tops, 4277 re_sub_match_top_t **new_array = re_realloc (mctx->sub_tops,
4271 re_sub_match_top_t *, 4278 re_sub_match_top_t *,
4272 new_asub_tops); 4279 new_asub_tops);
4273 if (BE (new_array == NULL, 0)) 4280 if (__glibc_unlikely (new_array == NULL))
4274 return REG_ESPACE; 4281 return REG_ESPACE;
4275 mctx->sub_tops = new_array; 4282 mctx->sub_tops = new_array;
4276 mctx->asub_tops = new_asub_tops; 4283 mctx->asub_tops = new_asub_tops;
4277 } 4284 }
4278 mctx->sub_tops[mctx->nsub_tops] = calloc (1, sizeof (re_sub_match_top_t)); 4285 mctx->sub_tops[mctx->nsub_tops] = calloc (1, sizeof (re_sub_match_top_t));
4279 if (BE (mctx->sub_tops[mctx->nsub_tops] == NULL, 0)) 4286 if (__glibc_unlikely (mctx->sub_tops[mctx->nsub_tops] == NULL))
4280 return REG_ESPACE; 4287 return REG_ESPACE;
4281 mctx->sub_tops[mctx->nsub_tops]->node = node; 4288 mctx->sub_tops[mctx->nsub_tops]->node = node;
4282 mctx->sub_tops[mctx->nsub_tops++]->str_idx = str_idx; 4289 mctx->sub_tops[mctx->nsub_tops++]->str_idx = str_idx;
@@ -4290,19 +4297,19 @@ static re_sub_match_last_t *
4290match_ctx_add_sublast (re_sub_match_top_t *subtop, Idx node, Idx str_idx) 4297match_ctx_add_sublast (re_sub_match_top_t *subtop, Idx node, Idx str_idx)
4291{ 4298{
4292 re_sub_match_last_t *new_entry; 4299 re_sub_match_last_t *new_entry;
4293 if (BE (subtop->nlasts == subtop->alasts, 0)) 4300 if (__glibc_unlikely (subtop->nlasts == subtop->alasts))
4294 { 4301 {
4295 Idx new_alasts = 2 * subtop->alasts + 1; 4302 Idx new_alasts = 2 * subtop->alasts + 1;
4296 re_sub_match_last_t **new_array = re_realloc (subtop->lasts, 4303 re_sub_match_last_t **new_array = re_realloc (subtop->lasts,
4297 re_sub_match_last_t *, 4304 re_sub_match_last_t *,
4298 new_alasts); 4305 new_alasts);
4299 if (BE (new_array == NULL, 0)) 4306 if (__glibc_unlikely (new_array == NULL))
4300 return NULL; 4307 return NULL;
4301 subtop->lasts = new_array; 4308 subtop->lasts = new_array;
4302 subtop->alasts = new_alasts; 4309 subtop->alasts = new_alasts;
4303 } 4310 }
4304 new_entry = calloc (1, sizeof (re_sub_match_last_t)); 4311 new_entry = calloc (1, sizeof (re_sub_match_last_t));
4305 if (BE (new_entry != NULL, 1)) 4312 if (__glibc_likely (new_entry != NULL))
4306 { 4313 {
4307 subtop->lasts[subtop->nlasts] = new_entry; 4314 subtop->lasts[subtop->nlasts] = new_entry;
4308 new_entry->node = node; 4315 new_entry->node = node;
diff --git a/m4/__inline.m4 b/m4/__inline.m4
new file mode 100644
index 00000000000..3d0c4798997
--- /dev/null
+++ b/m4/__inline.m4
@@ -0,0 +1,22 @@
1# Test for __inline keyword
2dnl Copyright 2017-2018 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl___INLINE],
8[
9 AC_CACHE_CHECK([whether the compiler supports the __inline keyword],
10 [gl_cv_c___inline],
11 [AC_COMPILE_IFELSE(
12 [AC_LANG_PROGRAM(
13 [[typedef int foo_t;
14 static __inline foo_t foo (void) { return 0; }]],
15 [[return foo ();]])],
16 [gl_cv_c___inline=yes],
17 [gl_cv_c___inline=no])])
18 if test $gl_cv_c___inline = yes; then
19 AC_DEFINE([HAVE___INLINE], [1],
20 [Define to 1 if the compiler supports the keyword '__inline'.])
21 fi
22])
diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4
index 61aabaa3427..74f28178ffc 100644
--- a/m4/gnulib-comp.m4
+++ b/m4/gnulib-comp.m4
@@ -109,6 +109,7 @@ AC_DEFUN([gl_EARLY],
109 # Code from module inttypes-incomplete: 109 # Code from module inttypes-incomplete:
110 # Code from module largefile: 110 # Code from module largefile:
111 AC_REQUIRE([AC_SYS_LARGEFILE]) 111 AC_REQUIRE([AC_SYS_LARGEFILE])
112 # Code from module libc-config:
112 # Code from module limits-h: 113 # Code from module limits-h:
113 # Code from module localtime-buffer: 114 # Code from module localtime-buffer:
114 # Code from module lstat: 115 # Code from module lstat:
@@ -441,6 +442,7 @@ AC_DEFUN([gl_INIT],
441 gl_gnulib_enabled_getgroups=false 442 gl_gnulib_enabled_getgroups=false
442 gl_gnulib_enabled_be453cec5eecf5731a274f2de7f2db36=false 443 gl_gnulib_enabled_be453cec5eecf5731a274f2de7f2db36=false
443 gl_gnulib_enabled_a9786850e999ae65a836a6041e8e5ed1=false 444 gl_gnulib_enabled_a9786850e999ae65a836a6041e8e5ed1=false
445 gl_gnulib_enabled_21ee726a3540c09237a8e70c0baf7467=false
444 gl_gnulib_enabled_2049e887c7e5308faad27b3f894bb8c9=false 446 gl_gnulib_enabled_2049e887c7e5308faad27b3f894bb8c9=false
445 gl_gnulib_enabled_5264294aa0a5557541b53c8c741f7f31=false 447 gl_gnulib_enabled_5264294aa0a5557541b53c8c741f7f31=false
446 gl_gnulib_enabled_open=false 448 gl_gnulib_enabled_open=false
@@ -554,6 +556,13 @@ AC_DEFUN([gl_INIT],
554 fi 556 fi
555 fi 557 fi
556 } 558 }
559 func_gl_gnulib_m4code_21ee726a3540c09237a8e70c0baf7467 ()
560 {
561 if ! $gl_gnulib_enabled_21ee726a3540c09237a8e70c0baf7467; then
562 gl___INLINE
563 gl_gnulib_enabled_21ee726a3540c09237a8e70c0baf7467=true
564 fi
565 }
557 func_gl_gnulib_m4code_2049e887c7e5308faad27b3f894bb8c9 () 566 func_gl_gnulib_m4code_2049e887c7e5308faad27b3f894bb8c9 ()
558 { 567 {
559 if ! $gl_gnulib_enabled_2049e887c7e5308faad27b3f894bb8c9; then 568 if ! $gl_gnulib_enabled_2049e887c7e5308faad27b3f894bb8c9; then
@@ -669,6 +678,9 @@ AC_DEFUN([gl_INIT],
669 if test $ac_use_included_regex = yes; then 678 if test $ac_use_included_regex = yes; then
670 func_gl_gnulib_m4code_37f71b604aa9c54446783d80f42fe547 679 func_gl_gnulib_m4code_37f71b604aa9c54446783d80f42fe547
671 fi 680 fi
681 if test $ac_use_included_regex = yes; then
682 func_gl_gnulib_m4code_21ee726a3540c09237a8e70c0baf7467
683 fi
672 if { test $HAVE_DECL_STRTOIMAX = 0 || test $REPLACE_STRTOIMAX = 1; } && test $ac_cv_type_long_long_int = yes; then 684 if { test $HAVE_DECL_STRTOIMAX = 0 || test $REPLACE_STRTOIMAX = 1; } && test $ac_cv_type_long_long_int = yes; then
673 func_gl_gnulib_m4code_strtoll 685 func_gl_gnulib_m4code_strtoll
674 fi 686 fi
@@ -686,6 +698,7 @@ AC_DEFUN([gl_INIT],
686 AM_CONDITIONAL([gl_GNULIB_ENABLED_getgroups], [$gl_gnulib_enabled_getgroups]) 698 AM_CONDITIONAL([gl_GNULIB_ENABLED_getgroups], [$gl_gnulib_enabled_getgroups])
687 AM_CONDITIONAL([gl_GNULIB_ENABLED_be453cec5eecf5731a274f2de7f2db36], [$gl_gnulib_enabled_be453cec5eecf5731a274f2de7f2db36]) 699 AM_CONDITIONAL([gl_GNULIB_ENABLED_be453cec5eecf5731a274f2de7f2db36], [$gl_gnulib_enabled_be453cec5eecf5731a274f2de7f2db36])
688 AM_CONDITIONAL([gl_GNULIB_ENABLED_a9786850e999ae65a836a6041e8e5ed1], [$gl_gnulib_enabled_a9786850e999ae65a836a6041e8e5ed1]) 700 AM_CONDITIONAL([gl_GNULIB_ENABLED_a9786850e999ae65a836a6041e8e5ed1], [$gl_gnulib_enabled_a9786850e999ae65a836a6041e8e5ed1])
701 AM_CONDITIONAL([gl_GNULIB_ENABLED_21ee726a3540c09237a8e70c0baf7467], [$gl_gnulib_enabled_21ee726a3540c09237a8e70c0baf7467])
689 AM_CONDITIONAL([gl_GNULIB_ENABLED_2049e887c7e5308faad27b3f894bb8c9], [$gl_gnulib_enabled_2049e887c7e5308faad27b3f894bb8c9]) 702 AM_CONDITIONAL([gl_GNULIB_ENABLED_2049e887c7e5308faad27b3f894bb8c9], [$gl_gnulib_enabled_2049e887c7e5308faad27b3f894bb8c9])
690 AM_CONDITIONAL([gl_GNULIB_ENABLED_5264294aa0a5557541b53c8c741f7f31], [$gl_gnulib_enabled_5264294aa0a5557541b53c8c741f7f31]) 703 AM_CONDITIONAL([gl_GNULIB_ENABLED_5264294aa0a5557541b53c8c741f7f31], [$gl_gnulib_enabled_5264294aa0a5557541b53c8c741f7f31])
691 AM_CONDITIONAL([gl_GNULIB_ENABLED_open], [$gl_gnulib_enabled_open]) 704 AM_CONDITIONAL([gl_GNULIB_ENABLED_open], [$gl_gnulib_enabled_open])
@@ -858,6 +871,7 @@ AC_DEFUN([gl_FILE_LIST], [
858 lib/c-strncasecmp.c 871 lib/c-strncasecmp.c
859 lib/careadlinkat.c 872 lib/careadlinkat.c
860 lib/careadlinkat.h 873 lib/careadlinkat.h
874 lib/cdefs.h
861 lib/cloexec.c 875 lib/cloexec.c
862 lib/cloexec.h 876 lib/cloexec.h
863 lib/close-stream.c 877 lib/close-stream.c
@@ -920,6 +934,7 @@ AC_DEFUN([gl_FILE_LIST], [
920 lib/ignore-value.h 934 lib/ignore-value.h
921 lib/intprops.h 935 lib/intprops.h
922 lib/inttypes.in.h 936 lib/inttypes.in.h
937 lib/libc-config.h
923 lib/limits.in.h 938 lib/limits.in.h
924 lib/localtime-buffer.c 939 lib/localtime-buffer.c
925 lib/localtime-buffer.h 940 lib/localtime-buffer.h
@@ -1002,6 +1017,7 @@ AC_DEFUN([gl_FILE_LIST], [
1002 lib/warn-on-use.h 1017 lib/warn-on-use.h
1003 lib/xalloc-oversized.h 1018 lib/xalloc-oversized.h
1004 m4/00gnulib.m4 1019 m4/00gnulib.m4
1020 m4/__inline.m4
1005 m4/absolute-header.m4 1021 m4/absolute-header.m4
1006 m4/acl.m4 1022 m4/acl.m4
1007 m4/alloca.m4 1023 m4/alloca.m4