*.in-h
_*
!lib/_Noreturn.h
+!m4/_*.m4
/bin/
/BIN/
/data/
--- /dev/null
+/* Copyright (C) 1992-2018 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either
+ version 3 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#ifndef _SYS_CDEFS_H
+#define _SYS_CDEFS_H 1
+
+/* We are almost always included from features.h. */
+#ifndef _FEATURES_H
+# include <features.h>
+#endif
+
+/* The GNU libc does not support any K&R compilers or the traditional mode
+ of ISO C compilers anymore. Check for some of the combinations not
+ anymore supported. */
+#if defined __GNUC__ && !defined __STDC__
+# error "You need a ISO C conforming compiler to use the glibc headers"
+#endif
+
+/* Some user header file might have defined this before. */
+#undef __P
+#undef __PMT
+
+#ifdef __GNUC__
+
+/* All functions, except those with callbacks or those that
+ synchronize memory, are leaf functions. */
+# if __GNUC_PREREQ (4, 6) && !defined _LIBC
+# define __LEAF , __leaf__
+# define __LEAF_ATTR __attribute__ ((__leaf__))
+# else
+# define __LEAF
+# define __LEAF_ATTR
+# endif
+
+/* GCC can always grok prototypes. For C++ programs we add throw()
+ to help it optimize the function calls. But this works only with
+ gcc 2.8.x and egcs. For gcc 3.2 and up we even mark C functions
+ as non-throwing using a function attribute since programs can use
+ the -fexceptions options for C code as well. */
+# if !defined __cplusplus && __GNUC_PREREQ (3, 3)
+# define __THROW __attribute__ ((__nothrow__ __LEAF))
+# define __THROWNL __attribute__ ((__nothrow__))
+# define __NTH(fct) __attribute__ ((__nothrow__ __LEAF)) fct
+# define __NTHNL(fct) __attribute__ ((__nothrow__)) fct
+# else
+# if defined __cplusplus && __GNUC_PREREQ (2,8)
+# define __THROW throw ()
+# define __THROWNL throw ()
+# define __NTH(fct) __LEAF_ATTR fct throw ()
+# define __NTHNL(fct) fct throw ()
+# else
+# define __THROW
+# define __THROWNL
+# define __NTH(fct) fct
+# define __NTHNL(fct) fct
+# endif
+# endif
+
+#else /* Not GCC. */
+
+# if (defined __cplusplus \
+ || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L))
+# define __inline inline
+# else
+# define __inline /* No inline functions. */
+# endif
+
+# define __THROW
+# define __THROWNL
+# define __NTH(fct) fct
+
+#endif /* GCC. */
+
+/* Compilers that are not clang may object to
+ #if defined __clang__ && __has_extension(...)
+ even though they do not need to evaluate the right-hand side of the &&. */
+#if defined __clang__ && defined __has_extension
+# define __glibc_clang_has_extension(ext) __has_extension (ext)
+#else
+# define __glibc_clang_has_extension(ext) 0
+#endif
+
+/* These two macros are not used in glibc anymore. They are kept here
+ only because some other projects expect the macros to be defined. */
+#define __P(args) args
+#define __PMT(args) args
+
+/* For these things, GCC behaves the ANSI way normally,
+ and the non-ANSI way under -traditional. */
+
+#define __CONCAT(x,y) x ## y
+#define __STRING(x) #x
+
+/* This is not a typedef so `const __ptr_t' does the right thing. */
+#define __ptr_t void *
+
+
+/* C++ needs to know that types and declarations are C, not C++. */
+#ifdef __cplusplus
+# define __BEGIN_DECLS extern "C" {
+# define __END_DECLS }
+#else
+# define __BEGIN_DECLS
+# define __END_DECLS
+#endif
+
+
+/* Fortify support. */
+#define __bos(ptr) __builtin_object_size (ptr, __USE_FORTIFY_LEVEL > 1)
+#define __bos0(ptr) __builtin_object_size (ptr, 0)
+
+#if __GNUC_PREREQ (4,3)
+# define __warndecl(name, msg) \
+ extern void name (void) __attribute__((__warning__ (msg)))
+# define __warnattr(msg) __attribute__((__warning__ (msg)))
+# define __errordecl(name, msg) \
+ extern void name (void) __attribute__((__error__ (msg)))
+#else
+# define __warndecl(name, msg) extern void name (void)
+# define __warnattr(msg)
+# define __errordecl(name, msg) extern void name (void)
+#endif
+
+/* Support for flexible arrays.
+ Headers that should use flexible arrays only if they're "real"
+ (e.g. only if they won't affect sizeof()) should test
+ #if __glibc_c99_flexarr_available. */
+#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
+# define __flexarr []
+# define __glibc_c99_flexarr_available 1
+#elif __GNUC_PREREQ (2,97)
+/* GCC 2.97 supports C99 flexible array members as an extension,
+ even when in C89 mode or compiling C++ (any version). */
+# define __flexarr []
+# define __glibc_c99_flexarr_available 1
+#elif defined __GNUC__
+/* Pre-2.97 GCC did not support C99 flexible arrays but did have
+ an equivalent extension with slightly different notation. */
+# define __flexarr [0]
+# define __glibc_c99_flexarr_available 1
+#else
+/* Some other non-C99 compiler. Approximate with [1]. */
+# define __flexarr [1]
+# define __glibc_c99_flexarr_available 0
+#endif
+
+
+/* __asm__ ("xyz") is used throughout the headers to rename functions
+ at the assembly language level. This is wrapped by the __REDIRECT
+ macro, in order to support compilers that can do this some other
+ way. When compilers don't support asm-names at all, we have to do
+ preprocessor tricks instead (which don't have exactly the right
+ semantics, but it's the best we can do).
+
+ Example:
+ int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); */
+
+#if defined __GNUC__ && __GNUC__ >= 2
+
+# define __REDIRECT(name, proto, alias) name proto __asm__ (__ASMNAME (#alias))
+# ifdef __cplusplus
+# define __REDIRECT_NTH(name, proto, alias) \
+ name proto __THROW __asm__ (__ASMNAME (#alias))
+# define __REDIRECT_NTHNL(name, proto, alias) \
+ name proto __THROWNL __asm__ (__ASMNAME (#alias))
+# else
+# define __REDIRECT_NTH(name, proto, alias) \
+ name proto __asm__ (__ASMNAME (#alias)) __THROW
+# define __REDIRECT_NTHNL(name, proto, alias) \
+ name proto __asm__ (__ASMNAME (#alias)) __THROWNL
+# endif
+# define __ASMNAME(cname) __ASMNAME2 (__USER_LABEL_PREFIX__, cname)
+# define __ASMNAME2(prefix, cname) __STRING (prefix) cname
+
+/*
+#elif __SOME_OTHER_COMPILER__
+
+# define __REDIRECT(name, proto, alias) name proto; \
+ _Pragma("let " #name " = " #alias)
+*/
+#endif
+
+/* GCC has various useful declarations that can be made with the
+ `__attribute__' syntax. All of the ways we use this do fine if
+ they are omitted for compilers that don't understand it. */
+#if !defined __GNUC__ || __GNUC__ < 2
+# define __attribute__(xyz) /* Ignore */
+#endif
+
+/* At some point during the gcc 2.96 development the `malloc' attribute
+ for functions was introduced. We don't want to use it unconditionally
+ (although this would be possible) since it generates warnings. */
+#if __GNUC_PREREQ (2,96)
+# define __attribute_malloc__ __attribute__ ((__malloc__))
+#else
+# define __attribute_malloc__ /* Ignore */
+#endif
+
+/* Tell the compiler which arguments to an allocation function
+ indicate the size of the allocation. */
+#if __GNUC_PREREQ (4, 3)
+# define __attribute_alloc_size__(params) \
+ __attribute__ ((__alloc_size__ params))
+#else
+# define __attribute_alloc_size__(params) /* Ignore. */
+#endif
+
+/* At some point during the gcc 2.96 development the `pure' attribute
+ for functions was introduced. We don't want to use it unconditionally
+ (although this would be possible) since it generates warnings. */
+#if __GNUC_PREREQ (2,96)
+# define __attribute_pure__ __attribute__ ((__pure__))
+#else
+# define __attribute_pure__ /* Ignore */
+#endif
+
+/* This declaration tells the compiler that the value is constant. */
+#if __GNUC_PREREQ (2,5)
+# define __attribute_const__ __attribute__ ((__const__))
+#else
+# define __attribute_const__ /* Ignore */
+#endif
+
+/* At some point during the gcc 3.1 development the `used' attribute
+ for functions was introduced. We don't want to use it unconditionally
+ (although this would be possible) since it generates warnings. */
+#if __GNUC_PREREQ (3,1)
+# define __attribute_used__ __attribute__ ((__used__))
+# define __attribute_noinline__ __attribute__ ((__noinline__))
+#else
+# define __attribute_used__ __attribute__ ((__unused__))
+# define __attribute_noinline__ /* Ignore */
+#endif
+
+/* Since version 3.2, gcc allows marking deprecated functions. */
+#if __GNUC_PREREQ (3,2)
+# define __attribute_deprecated__ __attribute__ ((__deprecated__))
+#else
+# define __attribute_deprecated__ /* Ignore */
+#endif
+
+/* Since version 4.5, gcc also allows one to specify the message printed
+ when a deprecated function is used. clang claims to be gcc 4.2, but
+ may also support this feature. */
+#if __GNUC_PREREQ (4,5) || \
+ __glibc_clang_has_extension (__attribute_deprecated_with_message__)
+# define __attribute_deprecated_msg__(msg) \
+ __attribute__ ((__deprecated__ (msg)))
+#else
+# define __attribute_deprecated_msg__(msg) __attribute_deprecated__
+#endif
+
+/* At some point during the gcc 2.8 development the `format_arg' attribute
+ for functions was introduced. We don't want to use it unconditionally
+ (although this would be possible) since it generates warnings.
+ If several `format_arg' attributes are given for the same function, in
+ gcc-3.0 and older, all but the last one are ignored. In newer gccs,
+ all designated arguments are considered. */
+#if __GNUC_PREREQ (2,8)
+# define __attribute_format_arg__(x) __attribute__ ((__format_arg__ (x)))
+#else
+# define __attribute_format_arg__(x) /* Ignore */
+#endif
+
+/* At some point during the gcc 2.97 development the `strfmon' format
+ attribute for functions was introduced. We don't want to use it
+ unconditionally (although this would be possible) since it
+ generates warnings. */
+#if __GNUC_PREREQ (2,97)
+# define __attribute_format_strfmon__(a,b) \
+ __attribute__ ((__format__ (__strfmon__, a, b)))
+#else
+# define __attribute_format_strfmon__(a,b) /* Ignore */
+#endif
+
+/* The nonnull function attribute marks pointer parameters that
+ must not be NULL. Do not define __nonnull if it is already defined,
+ for portability when this file is used in Gnulib. */
+#ifndef __nonnull
+# if __GNUC_PREREQ (3,3)
+# define __nonnull(params) __attribute__ ((__nonnull__ params))
+# else
+# define __nonnull(params)
+# endif
+#endif
+
+/* If fortification mode, we warn about unused results of certain
+ function calls which can lead to problems. */
+#if __GNUC_PREREQ (3,4)
+# define __attribute_warn_unused_result__ \
+ __attribute__ ((__warn_unused_result__))
+# if defined __USE_FORTIFY_LEVEL && __USE_FORTIFY_LEVEL > 0
+# define __wur __attribute_warn_unused_result__
+# endif
+#else
+# define __attribute_warn_unused_result__ /* empty */
+#endif
+#ifndef __wur
+# define __wur /* Ignore */
+#endif
+
+/* Forces a function to be always inlined. */
+#if __GNUC_PREREQ (3,2)
+/* The Linux kernel defines __always_inline in stddef.h (283d7573), and
+ it conflicts with this definition. Therefore undefine it first to
+ allow either header to be included first. */
+# undef __always_inline
+# define __always_inline __inline __attribute__ ((__always_inline__))
+#else
+# undef __always_inline
+# define __always_inline __inline
+#endif
+
+/* Associate error messages with the source location of the call site rather
+ than with the source location inside the function. */
+#if __GNUC_PREREQ (4,3)
+# define __attribute_artificial__ __attribute__ ((__artificial__))
+#else
+# define __attribute_artificial__ /* Ignore */
+#endif
+
+/* GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99
+ inline semantics, unless -fgnu89-inline is used. Using __GNUC_STDC_INLINE__
+ or __GNUC_GNU_INLINE is not a good enough check for gcc because gcc versions
+ older than 4.3 may define these macros and still not guarantee GNU inlining
+ semantics.
+
+ clang++ identifies itself as gcc-4.2, but has support for GNU inlining
+ semantics, that can be checked fot by using the __GNUC_STDC_INLINE_ and
+ __GNUC_GNU_INLINE__ macro definitions. */
+#if (!defined __cplusplus || __GNUC_PREREQ (4,3) \
+ || (defined __clang__ && (defined __GNUC_STDC_INLINE__ \
+ || defined __GNUC_GNU_INLINE__)))
+# if defined __GNUC_STDC_INLINE__ || defined __cplusplus
+# define __extern_inline extern __inline __attribute__ ((__gnu_inline__))
+# define __extern_always_inline \
+ extern __always_inline __attribute__ ((__gnu_inline__))
+# else
+# define __extern_inline extern __inline
+# define __extern_always_inline extern __always_inline
+# endif
+#endif
+
+#ifdef __extern_always_inline
+# define __fortify_function __extern_always_inline __attribute_artificial__
+#endif
+
+/* GCC 4.3 and above allow passing all anonymous arguments of an
+ __extern_always_inline function to some other vararg function. */
+#if __GNUC_PREREQ (4,3)
+# define __va_arg_pack() __builtin_va_arg_pack ()
+# define __va_arg_pack_len() __builtin_va_arg_pack_len ()
+#endif
+
+/* It is possible to compile containing GCC extensions even if GCC is
+ run in pedantic mode if the uses are carefully marked using the
+ `__extension__' keyword. But this is not generally available before
+ version 2.8. */
+#if !__GNUC_PREREQ (2,8)
+# define __extension__ /* Ignore */
+#endif
+
+/* __restrict is known in EGCS 1.2 and above. */
+#if !__GNUC_PREREQ (2,92)
+# if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
+# define __restrict restrict
+# else
+# define __restrict /* Ignore */
+# endif
+#endif
+
+/* ISO C99 also allows to declare arrays as non-overlapping. The syntax is
+ array_name[restrict]
+ GCC 3.1 supports this. */
+#if __GNUC_PREREQ (3,1) && !defined __GNUG__
+# define __restrict_arr __restrict
+#else
+# ifdef __GNUC__
+# define __restrict_arr /* Not supported in old GCC. */
+# else
+# if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
+# define __restrict_arr restrict
+# else
+/* Some other non-C99 compiler. */
+# define __restrict_arr /* Not supported. */
+# endif
+# endif
+#endif
+
+#if __GNUC__ >= 3
+# define __glibc_unlikely(cond) __builtin_expect ((cond), 0)
+# define __glibc_likely(cond) __builtin_expect ((cond), 1)
+#else
+# define __glibc_unlikely(cond) (cond)
+# define __glibc_likely(cond) (cond)
+#endif
+
+#ifdef __has_attribute
+# define __glibc_has_attribute(attr) __has_attribute (attr)
+#else
+# define __glibc_has_attribute(attr) 0
+#endif
+
+#if (!defined _Noreturn \
+ && (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 201112 \
+ && !__GNUC_PREREQ (4,7))
+# if __GNUC_PREREQ (2,8)
+# define _Noreturn __attribute__ ((__noreturn__))
+# else
+# define _Noreturn
+# endif
+#endif
+
+#if __GNUC_PREREQ (8, 0)
+/* Describes a char array whose address can safely be passed as the first
+ argument to strncpy and strncat, as the char array is not necessarily
+ a NUL-terminated string. */
+# define __attribute_nonstring__ __attribute__ ((__nonstring__))
+#else
+# define __attribute_nonstring__
+#endif
+
+#if (!defined _Static_assert && !defined __cplusplus \
+ && (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 201112 \
+ && (!__GNUC_PREREQ (4, 6) || defined __STRICT_ANSI__))
+# define _Static_assert(expr, diagnostic) \
+ extern int (*__Static_assert_function (void)) \
+ [!!sizeof (struct { int __error_if_negative: (expr) ? 2 : -1; })]
+#endif
+
+/* The #ifndef lets Gnulib avoid including these on non-glibc
+ platforms, where the includes typically do not exist. */
+#ifndef __WORDSIZE
+# include <bits/wordsize.h>
+# include <bits/long-double.h>
+#endif
+
+#if defined __LONG_DOUBLE_MATH_OPTIONAL && defined __NO_LONG_DOUBLE_MATH
+# define __LDBL_COMPAT 1
+# ifdef __REDIRECT
+# define __LDBL_REDIR1(name, proto, alias) __REDIRECT (name, proto, alias)
+# define __LDBL_REDIR(name, proto) \
+ __LDBL_REDIR1 (name, proto, __nldbl_##name)
+# define __LDBL_REDIR1_NTH(name, proto, alias) __REDIRECT_NTH (name, proto, alias)
+# define __LDBL_REDIR_NTH(name, proto) \
+ __LDBL_REDIR1_NTH (name, proto, __nldbl_##name)
+# define __LDBL_REDIR1_DECL(name, alias) \
+ extern __typeof (name) name __asm (__ASMNAME (#alias));
+# define __LDBL_REDIR_DECL(name) \
+ extern __typeof (name) name __asm (__ASMNAME ("__nldbl_" #name));
+# define __REDIRECT_LDBL(name, proto, alias) \
+ __LDBL_REDIR1 (name, proto, __nldbl_##alias)
+# define __REDIRECT_NTH_LDBL(name, proto, alias) \
+ __LDBL_REDIR1_NTH (name, proto, __nldbl_##alias)
+# endif
+#endif
+#if !defined __LDBL_COMPAT || !defined __REDIRECT
+# define __LDBL_REDIR1(name, proto, alias) name proto
+# define __LDBL_REDIR(name, proto) name proto
+# define __LDBL_REDIR1_NTH(name, proto, alias) name proto __THROW
+# define __LDBL_REDIR_NTH(name, proto) name proto __THROW
+# define __LDBL_REDIR_DECL(name)
+# ifdef __REDIRECT
+# define __REDIRECT_LDBL(name, proto, alias) __REDIRECT (name, proto, alias)
+# define __REDIRECT_NTH_LDBL(name, proto, alias) \
+ __REDIRECT_NTH (name, proto, alias)
+# endif
+#endif
+
+/* __glibc_macro_warning (MESSAGE) issues warning MESSAGE. This is
+ intended for use in preprocessor macros.
+
+ Note: MESSAGE must be a _single_ string; concatenation of string
+ literals is not supported. */
+#if __GNUC_PREREQ (4,8) || __glibc_clang_prereq (3,5)
+# define __glibc_macro_warning1(message) _Pragma (#message)
+# define __glibc_macro_warning(message) \
+ __glibc_macro_warning1 (GCC warning message)
+#else
+# define __glibc_macro_warning(msg)
+#endif
+
+/* Generic selection (ISO C11) is a C-only feature, available in GCC
+ since version 4.9. Previous versions do not provide generic
+ selection, even though they might set __STDC_VERSION__ to 201112L,
+ when in -std=c11 mode. Thus, we must check for !defined __GNUC__
+ when testing __STDC_VERSION__ for generic selection support.
+ On the other hand, Clang also defines __GNUC__, so a clang-specific
+ check is required to enable the use of generic selection. */
+#if !defined __cplusplus \
+ && (__GNUC_PREREQ (4, 9) \
+ || __glibc_clang_has_extension (c_generic_selections) \
+ || (!defined __GNUC__ && defined __STDC_VERSION__ \
+ && __STDC_VERSION__ >= 201112L))
+# define __HAVE_GENERIC_SELECTION 1
+#else
+# define __HAVE_GENERIC_SELECTION 0
+#endif
+
+#endif /* sys/cdefs.h */
gameuser = @gameuser@
gl_GNULIB_ENABLED_03e0aaad4cb89ca757653bd367a6ccb7 = @gl_GNULIB_ENABLED_03e0aaad4cb89ca757653bd367a6ccb7@
gl_GNULIB_ENABLED_2049e887c7e5308faad27b3f894bb8c9 = @gl_GNULIB_ENABLED_2049e887c7e5308faad27b3f894bb8c9@
+gl_GNULIB_ENABLED_21ee726a3540c09237a8e70c0baf7467 = @gl_GNULIB_ENABLED_21ee726a3540c09237a8e70c0baf7467@
gl_GNULIB_ENABLED_260941c0e5dc67ec9e87d1fb321c300b = @gl_GNULIB_ENABLED_260941c0e5dc67ec9e87d1fb321c300b@
gl_GNULIB_ENABLED_37f71b604aa9c54446783d80f42fe547 = @gl_GNULIB_ENABLED_37f71b604aa9c54446783d80f42fe547@
gl_GNULIB_ENABLED_5264294aa0a5557541b53c8c741f7f31 = @gl_GNULIB_ENABLED_5264294aa0a5557541b53c8c741f7f31@
endif
## end gnulib module inttypes-incomplete
+## begin gnulib module libc-config
+ifeq (,$(OMIT_GNULIB_MODULE_libc-config))
+
+ifneq (,$(gl_GNULIB_ENABLED_21ee726a3540c09237a8e70c0baf7467))
+
+endif
+EXTRA_DIST += cdefs.h libc-config.h
+
+endif
+## end gnulib module libc-config
+
## begin gnulib module limits-h
ifeq (,$(OMIT_GNULIB_MODULE_limits-h))
--- /dev/null
+/* System definitions for code taken from the GNU C Library
+
+ Copyright 2017-2018 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either
+ version 3 of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public
+ License along with this program; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+/* Written by Paul Eggert. */
+
+/* This is intended to be a good-enough substitute for glibc system
+ macros like those defined in <sys/cdefs.h>, so that Gnulib code
+ shared with glibc can do this as the first #include:
+
+ #ifndef _LIBC
+ # include <libc-config.h>
+ #endif
+
+ When compiled as part of glibc this is a no-op; when compiled as
+ part of Gnulib this includes Gnulib's <config.h> and defines macros
+ that glibc library code would normally assume. */
+
+#include <config.h>
+
+/* On glibc this includes <features.h> and <sys/cdefs.h> and #defines
+ _FEATURES_H, __WORDSIZE, and __set_errno. On FreeBSD 11 it
+ includes <sys/cdefs.h> which defines __nonnull. Elsewhere it
+ is harmless. */
+#include <errno.h>
+
+/* From glibc <errno.h>. */
+#ifndef __set_errno
+# define __set_errno(val) (errno = (val))
+#endif
+
+/* From glibc <features.h>. */
+
+#ifndef __GNUC_PREREQ
+# if defined __GNUC__ && defined __GNUC_MINOR__
+# define __GNUC_PREREQ(maj, min) ((maj) < __GNUC__ + ((min) <= __GNUC_MINOR__))
+# else
+# define __GNUC_PREREQ(maj, min) 0
+# endif
+#endif
+
+#ifndef __glibc_clang_prereq
+# if defined __clang_major__ && defined __clang_minor__
+# define __glibc_clang_prereq(maj, min) \
+ ((maj) < __clang_major__ + ((min) <= __clang_minor__))
+# else
+# define __glibc_clang_prereq(maj, min) 0
+# endif
+#endif
+
+
+/* Prepare to include <cdefs.h>, which is our copy of glibc
+ <sys/cdefs.h>. */
+
+/* Define _FEATURES_H so that <cdefs.h> does not include <features.h>. */
+#ifndef _FEATURES_H
+# define _FEATURES_H 1
+#endif
+/* Define __WORDSIZE so that <cdefs.h> does not attempt to include
+ nonexistent files. Make it a syntax error, since Gnulib does not
+ use __WORDSIZE now, and if Gnulib uses it later the syntax error
+ will let us know that __WORDSIZE needs configuring. */
+#ifndef __WORDSIZE
+# define __WORDSIZE %%%
+#endif
+/* Undef the macros unconditionally defined by our copy of glibc
+ <sys/cdefs.h>, so that they do not clash with any system-defined
+ versions. */
+#undef _SYS_CDEFS_H
+#undef __ASMNAME
+#undef __ASMNAME2
+#undef __BEGIN_DECLS
+#undef __CONCAT
+#undef __END_DECLS
+#undef __HAVE_GENERIC_SELECTION
+#undef __LDBL_COMPAT
+#undef __LDBL_REDIR
+#undef __LDBL_REDIR1
+#undef __LDBL_REDIR1_DECL
+#undef __LDBL_REDIR1_NTH
+#undef __LDBL_REDIR_DECL
+#undef __LDBL_REDIR_NTH
+#undef __LEAF
+#undef __LEAF_ATTR
+#undef __NTH
+#undef __NTHNL
+#undef __P
+#undef __PMT
+#undef __REDIRECT
+#undef __REDIRECT_LDBL
+#undef __REDIRECT_NTH
+#undef __REDIRECT_NTHNL
+#undef __REDIRECT_NTH_LDBL
+#undef __STRING
+#undef __THROW
+#undef __THROWNL
+#undef __always_inline
+#undef __attribute__
+#undef __attribute_alloc_size__
+#undef __attribute_artificial__
+#undef __attribute_const__
+#undef __attribute_deprecated__
+#undef __attribute_deprecated_msg__
+#undef __attribute_format_arg__
+#undef __attribute_format_strfmon__
+#undef __attribute_malloc__
+#undef __attribute_noinline__
+#undef __attribute_nonstring__
+#undef __attribute_pure__
+#undef __attribute_used__
+#undef __attribute_warn_unused_result__
+#undef __bos
+#undef __bos0
+#undef __errordecl
+#undef __extension__
+#undef __extern_always_inline
+#undef __extern_inline
+#undef __flexarr
+#undef __fortify_function
+#undef __glibc_c99_flexarr_available
+#undef __glibc_clang_has_extension
+#undef __glibc_likely
+#undef __glibc_macro_warning
+#undef __glibc_macro_warning1
+#undef __glibc_unlikely
+#undef __inline
+#undef __ptr_t
+#undef __restrict
+#undef __restrict_arr
+#undef __va_arg_pack
+#undef __va_arg_pack_len
+#undef __warnattr
+#undef __warndecl
+
+/* Include our copy of glibc <sys/cdefs.h>. */
+#include <cdefs.h>
+
+/* <cdefs.h> __inline is too pessimistic for non-GCC. */
+#undef __inline
+#ifndef HAVE___INLINE
+# if 199901 <= __STDC_VERSION__ || defined inline
+# define __inline inline
+# else
+# define __inline
+# endif
+#endif
+
+
+/* A substitute for glibc <libc-symbols.h>, good enough for Gnulib. */
+#define attribute_hidden
+#define libc_hidden_proto(name, ...)
+#define libc_hidden_def(name)
+#define libc_hidden_weak(name)
+#define libc_hidden_ver(local, name)
+#define strong_alias(name, aliasname)
+#define weak_alias(name, aliasname)
+
+/* A substitute for glibc <shlib-compat.h>, good enough for Gnulib. */
+#define SHLIB_COMPAT(lib, introduced, obsoleted) 0
+#define versioned_symbol(lib, local, symbol, version)
/* Try to allocate space for the fastmap. */
preg->fastmap = re_malloc (char, SBC_MAX);
- if (BE (preg->fastmap == NULL, 0))
+ if (__glibc_unlikely (preg->fastmap == NULL))
return REG_ESPACE;
syntax |= (cflags & REG_ICASE) ? RE_ICASE : 0;
ret = REG_EPAREN;
/* We have already checked preg->fastmap != NULL. */
- if (BE (ret == REG_NOERROR, 1))
+ if (__glibc_likely (ret == REG_NOERROR))
/* Compute the fastmap now, since regexec cannot modify the pattern
buffer. This function never fails in this implementation. */
(void) re_compile_fastmap (preg);
{
const char *msg;
size_t msg_size;
+ int nerrcodes = sizeof __re_error_msgid_idx / sizeof __re_error_msgid_idx[0];
- if (BE (errcode < 0
- || errcode >= (int) (sizeof (__re_error_msgid_idx)
- / sizeof (__re_error_msgid_idx[0])), 0))
+ if (__glibc_unlikely (errcode < 0 || errcode >= nerrcodes))
/* Only error codes returned by the rest of the code should be passed
to this routine. If we are given anything else, or if other regex
code generates an invalid error code, then the program has a bug.
msg_size = strlen (msg) + 1; /* Includes the null. */
- if (BE (errbuf_size != 0, 1))
+ if (__glibc_likely (errbuf_size != 0))
{
size_t cpy_size = msg_size;
- if (BE (msg_size > errbuf_size, 0))
+ if (__glibc_unlikely (msg_size > errbuf_size))
{
cpy_size = errbuf_size - 1;
errbuf[cpy_size] = '\0';
regfree (regex_t *preg)
{
re_dfa_t *dfa = preg->buffer;
- if (BE (dfa != NULL, 1))
+ if (__glibc_likely (dfa != NULL))
{
lock_fini (dfa->lock);
free_dfa_content (dfa);
/* Initialize the dfa. */
dfa = preg->buffer;
- if (BE (preg->allocated < sizeof (re_dfa_t), 0))
+ if (__glibc_unlikely (preg->allocated < sizeof (re_dfa_t)))
{
/* If zero allocated, but buffer is non-null, try to realloc
enough space. This loses if buffer's address is bogus, but
preg->used = sizeof (re_dfa_t);
err = init_dfa (dfa, length);
- if (BE (err == REG_NOERROR && lock_init (dfa->lock) != 0, 0))
+ if (__glibc_unlikely (err == REG_NOERROR && lock_init (dfa->lock) != 0))
err = REG_ESPACE;
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
{
free_dfa_content (dfa);
preg->buffer = NULL;
err = re_string_construct (®exp, pattern, length, preg->translate,
(syntax & RE_ICASE) != 0, dfa);
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
{
re_compile_internal_free_return:
free_workarea_compile (preg);
/* Parse the regular expression, and build a structure tree. */
preg->re_nsub = 0;
dfa->str_tree = parse (®exp, preg, syntax, &err);
- if (BE (dfa->str_tree == NULL, 0))
+ if (__glibc_unlikely (dfa->str_tree == NULL))
goto re_compile_internal_free_return;
/* Analyze the tree and create the nfa. */
err = analyze (preg);
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
goto re_compile_internal_free_return;
#ifdef RE_ENABLE_I18N
free_workarea_compile (preg);
re_string_destruct (®exp);
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
{
lock_fini (dfa->lock);
free_dfa_content (dfa);
calculation below, and for similar doubling calculations
elsewhere. And it's <= rather than <, because some of the
doubling calculations add 1 afterwards. */
- if (BE (MIN (IDX_MAX, SIZE_MAX / max_object_size) / 2 <= pat_len, 0))
+ if (__glibc_unlikely (MIN (IDX_MAX, SIZE_MAX / max_object_size) / 2
+ <= pat_len))
return REG_ESPACE;
dfa->nodes_alloc = pat_len + 1;
int i, j, ch;
dfa->sb_char = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1);
- if (BE (dfa->sb_char == NULL, 0))
+ if (__glibc_unlikely (dfa->sb_char == NULL))
return REG_ESPACE;
/* Set the bits corresponding to single byte chars. */
}
#endif
- if (BE (dfa->nodes == NULL || dfa->state_table == NULL, 0))
+ if (__glibc_unlikely (dfa->nodes == NULL || dfa->state_table == NULL))
return REG_ESPACE;
return REG_NOERROR;
}
int j;
int ch = 0;
dfa->word_ops_used = 1;
- if (BE (dfa->map_notascii == 0, 1))
+ if (__glibc_likely (dfa->map_notascii == 0))
{
/* Avoid uint32_t and uint64_t as some non-GCC platforms lack
them, an issue when this code is used in Gnulib. */
goto general_case;
ch = 128;
- if (BE (dfa->is_utf8, 1))
+ if (__glibc_likely (dfa->is_utf8))
{
memset (&dfa->word_char[i], '\0', (SBC_MAX - ch) / 8);
return;
first = dfa->str_tree->first->node_idx;
dfa->init_node = first;
err = re_node_set_init_copy (&init_nodes, dfa->eclosures + first);
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
return err;
/* The back-references which are in initial states can epsilon transit,
/* It must be the first time to invoke acquire_state. */
dfa->init_state = re_acquire_state_context (&err, dfa, &init_nodes, 0);
/* We don't check ERR here, since the initial state must not be NULL. */
- if (BE (dfa->init_state == NULL, 0))
+ if (__glibc_unlikely (dfa->init_state == NULL))
return err;
if (dfa->init_state->has_constraint)
{
&init_nodes,
CONTEXT_NEWLINE
| CONTEXT_BEGBUF);
- if (BE (dfa->init_state_word == NULL || dfa->init_state_nl == NULL
- || dfa->init_state_begbuf == NULL, 0))
+ if (__glibc_unlikely (dfa->init_state_word == NULL
+ || dfa->init_state_nl == NULL
+ || dfa->init_state_begbuf == NULL))
return err;
}
else
dfa->org_indices = re_malloc (Idx, dfa->nodes_alloc);
dfa->edests = re_malloc (re_node_set, dfa->nodes_alloc);
dfa->eclosures = re_malloc (re_node_set, dfa->nodes_alloc);
- if (BE (dfa->nexts == NULL || dfa->org_indices == NULL || dfa->edests == NULL
- || dfa->eclosures == NULL, 0))
+ if (__glibc_unlikely (dfa->nexts == NULL || dfa->org_indices == NULL
+ || dfa->edests == NULL || dfa->eclosures == NULL))
return REG_ESPACE;
dfa->subexp_map = re_malloc (Idx, preg->re_nsub);
}
ret = postorder (dfa->str_tree, lower_subexps, preg);
- if (BE (ret != REG_NOERROR, 0))
+ if (__glibc_unlikely (ret != REG_NOERROR))
return ret;
ret = postorder (dfa->str_tree, calc_first, dfa);
- if (BE (ret != REG_NOERROR, 0))
+ if (__glibc_unlikely (ret != REG_NOERROR))
return ret;
preorder (dfa->str_tree, calc_next, dfa);
ret = preorder (dfa->str_tree, link_nfa_nodes, dfa);
- if (BE (ret != REG_NOERROR, 0))
+ if (__glibc_unlikely (ret != REG_NOERROR))
return ret;
ret = calc_eclosure (dfa);
- if (BE (ret != REG_NOERROR, 0))
+ if (__glibc_unlikely (ret != REG_NOERROR))
return ret;
/* We only need this during the prune_impossible_nodes pass in regexec.c;
|| dfa->nbackref)
{
dfa->inveclosures = re_malloc (re_node_set, dfa->nodes_len);
- if (BE (dfa->inveclosures == NULL, 0))
+ if (__glibc_unlikely (dfa->inveclosures == NULL))
return REG_ESPACE;
ret = calc_inveclosure (dfa);
}
do
{
reg_errcode_t err = fn (extra, node);
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
return err;
if (node->parent == NULL)
return REG_NOERROR;
for (node = root; ; )
{
reg_errcode_t err = fn (extra, node);
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
return err;
/* Go to the left node, or up and to the right. */
cls = create_tree (dfa, NULL, NULL, OP_CLOSE_SUBEXP);
tree1 = body ? create_tree (dfa, body, cls, CONCAT) : cls;
tree = create_tree (dfa, op, tree1, CONCAT);
- if (BE (tree == NULL || tree1 == NULL || op == NULL || cls == NULL, 0))
+ if (__glibc_unlikely (tree == NULL || tree1 == NULL
+ || op == NULL || cls == NULL))
{
*err = REG_ESPACE;
return NULL;
{
node->first = node;
node->node_idx = re_dfa_add_node (dfa, node->token);
- if (BE (node->node_idx == -1, 0))
+ if (__glibc_unlikely (node->node_idx == -1))
return REG_ESPACE;
if (node->token.type == ANCHOR)
dfa->nodes[node->node_idx].constraint = node->token.opr.ctx_type;
org_dest = dfa->nexts[org_node];
re_node_set_empty (dfa->edests + clone_node);
clone_dest = duplicate_node (dfa, org_dest, constraint);
- if (BE (clone_dest == -1, 0))
+ if (__glibc_unlikely (clone_dest == -1))
return REG_ESPACE;
dfa->nexts[clone_node] = dfa->nexts[org_node];
ok = re_node_set_insert (dfa->edests + clone_node, clone_dest);
- if (BE (! ok, 0))
+ if (__glibc_unlikely (! ok))
return REG_ESPACE;
}
else if (dfa->edests[org_node].nelem == 0)
if (org_node == root_node && clone_node != org_node)
{
ok = re_node_set_insert (dfa->edests + clone_node, org_dest);
- if (BE (! ok, 0))
+ if (__glibc_unlikely (! ok))
return REG_ESPACE;
break;
}
/* In case the node has another constraint, append it. */
constraint |= dfa->nodes[org_node].constraint;
clone_dest = duplicate_node (dfa, org_dest, constraint);
- if (BE (clone_dest == -1, 0))
+ if (__glibc_unlikely (clone_dest == -1))
return REG_ESPACE;
ok = re_node_set_insert (dfa->edests + clone_node, clone_dest);
- if (BE (! ok, 0))
+ if (__glibc_unlikely (! ok))
return REG_ESPACE;
}
else /* dfa->edests[org_node].nelem == 2 */
/* There is no such duplicated node, create a new one. */
reg_errcode_t err;
clone_dest = duplicate_node (dfa, org_dest, constraint);
- if (BE (clone_dest == -1, 0))
+ if (__glibc_unlikely (clone_dest == -1))
return REG_ESPACE;
ok = re_node_set_insert (dfa->edests + clone_node, clone_dest);
- if (BE (! ok, 0))
+ if (__glibc_unlikely (! ok))
return REG_ESPACE;
err = duplicate_node_closure (dfa, org_dest, clone_dest,
root_node, constraint);
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
return err;
}
else
/* There is a duplicated node which satisfies the constraint,
use it to avoid infinite loop. */
ok = re_node_set_insert (dfa->edests + clone_node, clone_dest);
- if (BE (! ok, 0))
+ if (__glibc_unlikely (! ok))
return REG_ESPACE;
}
org_dest = dfa->edests[org_node].elems[1];
clone_dest = duplicate_node (dfa, org_dest, constraint);
- if (BE (clone_dest == -1, 0))
+ if (__glibc_unlikely (clone_dest == -1))
return REG_ESPACE;
ok = re_node_set_insert (dfa->edests + clone_node, clone_dest);
- if (BE (! ok, 0))
+ if (__glibc_unlikely (! ok))
return REG_ESPACE;
}
org_node = org_dest;
duplicate_node (re_dfa_t *dfa, Idx org_idx, unsigned int constraint)
{
Idx dup_idx = re_dfa_add_node (dfa, dfa->nodes[org_idx]);
- if (BE (dup_idx != -1, 1))
+ if (__glibc_likely (dup_idx != -1))
{
dfa->nodes[dup_idx].constraint = constraint;
dfa->nodes[dup_idx].constraint |= dfa->nodes[org_idx].constraint;
for (idx = 0; idx < dfa->eclosures[src].nelem; ++idx)
{
ok = re_node_set_insert_last (dfa->inveclosures + elems[idx], src);
- if (BE (! ok, 0))
+ if (__glibc_unlikely (! ok))
return REG_ESPACE;
}
}
continue;
/* Calculate epsilon closure of 'node_idx'. */
err = calc_eclosure_iter (&eclosure_elem, dfa, node_idx, true);
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
return err;
if (dfa->eclosures[node_idx].nelem == 0)
bool ok;
bool incomplete = false;
err = re_node_set_alloc (&eclosure, dfa->edests[node].nelem + 1);
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
return err;
/* This indicates that we are calculating this node now.
{
err = duplicate_node_closure (dfa, node, node, node,
dfa->nodes[node].constraint);
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
return err;
}
if (dfa->eclosures[edest].nelem == 0)
{
err = calc_eclosure_iter (&eclosure_elem, dfa, edest, false);
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
return err;
}
else
eclosure_elem = dfa->eclosures[edest];
/* Merge the epsilon closure of 'edest'. */
err = re_node_set_merge (&eclosure, &eclosure_elem);
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
return err;
/* If the epsilon closure of 'edest' is incomplete,
the epsilon closure of this node is also incomplete. */
/* An epsilon closure includes itself. */
ok = re_node_set_insert (&eclosure, node);
- if (BE (! ok, 0))
+ if (__glibc_unlikely (! ok))
return REG_ESPACE;
if (incomplete && !root)
dfa->eclosures[node].nelem = 0;
dfa->syntax = syntax;
fetch_token (¤t_token, regexp, syntax | RE_CARET_ANCHORS_HERE);
tree = parse_reg_exp (regexp, preg, ¤t_token, syntax, 0, err);
- if (BE (*err != REG_NOERROR && tree == NULL, 0))
+ if (__glibc_unlikely (*err != REG_NOERROR && tree == NULL))
return NULL;
eor = create_tree (dfa, NULL, NULL, END_OF_RE);
if (tree != NULL)
root = create_tree (dfa, tree, eor, CONCAT);
else
root = eor;
- if (BE (eor == NULL || root == NULL, 0))
+ if (__glibc_unlikely (eor == NULL || root == NULL))
{
*err = REG_ESPACE;
return NULL;
bin_tree_t *tree, *branch = NULL;
bitset_word_t initial_bkref_map = dfa->completed_bkref_map;
tree = parse_branch (regexp, preg, token, syntax, nest, err);
- if (BE (*err != REG_NOERROR && tree == NULL, 0))
+ if (__glibc_unlikely (*err != REG_NOERROR && tree == NULL))
return NULL;
while (token->type == OP_ALT)
bitset_word_t accumulated_bkref_map = dfa->completed_bkref_map;
dfa->completed_bkref_map = initial_bkref_map;
branch = parse_branch (regexp, preg, token, syntax, nest, err);
- if (BE (*err != REG_NOERROR && branch == NULL, 0))
+ if (__glibc_unlikely (*err != REG_NOERROR && branch == NULL))
{
if (tree != NULL)
postorder (tree, free_tree, NULL);
else
branch = NULL;
tree = create_tree (dfa, tree, branch, OP_ALT);
- if (BE (tree == NULL, 0))
+ if (__glibc_unlikely (tree == NULL))
{
*err = REG_ESPACE;
return NULL;
bin_tree_t *tree, *expr;
re_dfa_t *dfa = preg->buffer;
tree = parse_expression (regexp, preg, token, syntax, nest, err);
- if (BE (*err != REG_NOERROR && tree == NULL, 0))
+ if (__glibc_unlikely (*err != REG_NOERROR && tree == NULL))
return NULL;
while (token->type != OP_ALT && token->type != END_OF_RE
&& (nest == 0 || token->type != OP_CLOSE_SUBEXP))
{
expr = parse_expression (regexp, preg, token, syntax, nest, err);
- if (BE (*err != REG_NOERROR && expr == NULL, 0))
+ if (__glibc_unlikely (*err != REG_NOERROR && expr == NULL))
{
if (tree != NULL)
postorder (tree, free_tree, NULL);
{
case CHARACTER:
tree = create_token_tree (dfa, NULL, NULL, token);
- if (BE (tree == NULL, 0))
+ if (__glibc_unlikely (tree == NULL))
{
*err = REG_ESPACE;
return NULL;
fetch_token (token, regexp, syntax);
mbc_remain = create_token_tree (dfa, NULL, NULL, token);
tree = create_tree (dfa, tree, mbc_remain, CONCAT);
- if (BE (mbc_remain == NULL || tree == NULL, 0))
+ if (__glibc_unlikely (mbc_remain == NULL || tree == NULL))
{
*err = REG_ESPACE;
return NULL;
case OP_OPEN_SUBEXP:
tree = parse_sub_exp (regexp, preg, token, syntax, nest + 1, err);
- if (BE (*err != REG_NOERROR && tree == NULL, 0))
+ if (__glibc_unlikely (*err != REG_NOERROR && tree == NULL))
return NULL;
break;
case OP_OPEN_BRACKET:
tree = parse_bracket_exp (regexp, dfa, token, syntax, err);
- if (BE (*err != REG_NOERROR && tree == NULL, 0))
+ if (__glibc_unlikely (*err != REG_NOERROR && tree == NULL))
return NULL;
break;
case OP_BACK_REF:
- if (!BE (dfa->completed_bkref_map & (1 << token->opr.idx), 1))
+ if (!__glibc_likely (dfa->completed_bkref_map & (1 << token->opr.idx)))
{
*err = REG_ESUBREG;
return NULL;
}
dfa->used_bkref_map |= 1 << token->opr.idx;
tree = create_token_tree (dfa, NULL, NULL, token);
- if (BE (tree == NULL, 0))
+ if (__glibc_unlikely (tree == NULL))
{
*err = REG_ESPACE;
return NULL;
/* mb_partial and word_char bits should be initialized already
by peek_token. */
tree = create_token_tree (dfa, NULL, NULL, token);
- if (BE (tree == NULL, 0))
+ if (__glibc_unlikely (tree == NULL))
{
*err = REG_ESPACE;
return NULL;
}
tree_last = create_token_tree (dfa, NULL, NULL, token);
tree = create_tree (dfa, tree_first, tree_last, OP_ALT);
- if (BE (tree_first == NULL || tree_last == NULL || tree == NULL, 0))
+ if (__glibc_unlikely (tree_first == NULL || tree_last == NULL
+ || tree == NULL))
{
*err = REG_ESPACE;
return NULL;
else
{
tree = create_token_tree (dfa, NULL, NULL, token);
- if (BE (tree == NULL, 0))
+ if (__glibc_unlikely (tree == NULL))
{
*err = REG_ESPACE;
return NULL;
case OP_PERIOD:
tree = create_token_tree (dfa, NULL, NULL, token);
- if (BE (tree == NULL, 0))
+ if (__glibc_unlikely (tree == NULL))
{
*err = REG_ESPACE;
return NULL;
"alnum",
"_",
token->type == OP_NOTWORD, err);
- if (BE (*err != REG_NOERROR && tree == NULL, 0))
+ if (__glibc_unlikely (*err != REG_NOERROR && tree == NULL))
return NULL;
break;
"space",
"",
token->type == OP_NOTSPACE, err);
- if (BE (*err != REG_NOERROR && tree == NULL, 0))
+ if (__glibc_unlikely (*err != REG_NOERROR && tree == NULL))
return NULL;
break;
{
bin_tree_t *dup_tree = parse_dup_op (tree, regexp, dfa, token,
syntax, err);
- if (BE (*err != REG_NOERROR && dup_tree == NULL, 0))
+ if (__glibc_unlikely (*err != REG_NOERROR && dup_tree == NULL))
{
if (tree != NULL)
postorder (tree, free_tree, NULL);
else
{
tree = parse_reg_exp (regexp, preg, token, syntax, nest, err);
- if (BE (*err == REG_NOERROR && token->type != OP_CLOSE_SUBEXP, 0))
+ if (__glibc_unlikely (*err == REG_NOERROR
+ && token->type != OP_CLOSE_SUBEXP))
{
if (tree != NULL)
postorder (tree, free_tree, NULL);
*err = REG_EPAREN;
}
- if (BE (*err != REG_NOERROR, 0))
+ if (__glibc_unlikely (*err != REG_NOERROR))
return NULL;
}
dfa->completed_bkref_map |= 1 << cur_nsub;
tree = create_tree (dfa, tree, NULL, SUBEXP);
- if (BE (tree == NULL, 0))
+ if (__glibc_unlikely (tree == NULL))
{
*err = REG_ESPACE;
return NULL;
return NULL;
}
}
- if (BE (start != -2, 1))
+ if (__glibc_likely (start != -2))
{
/* We treat "{n}" as "{n,n}". */
end = ((token->type == OP_CLOSE_DUP_NUM) ? start
: ((token->type == CHARACTER && token->opr.c == ',')
? fetch_number (regexp, token, syntax) : -2));
}
- if (BE (start == -2 || end == -2, 0))
+ if (__glibc_unlikely (start == -2 || end == -2))
{
/* Invalid sequence. */
- if (BE (!(syntax & RE_INVALID_INTERVAL_ORD), 0))
+ if (__glibc_unlikely (!(syntax & RE_INVALID_INTERVAL_ORD)))
{
if (token->type == END_OF_RE)
*err = REG_EBRACE;
return elem;
}
- if (BE ((end != -1 && start > end)
- || token->type != OP_CLOSE_DUP_NUM, 0))
+ if (__glibc_unlikely ((end != -1 && start > end)
+ || token->type != OP_CLOSE_DUP_NUM))
{
/* First number greater than second. */
*err = REG_BADBR;
return NULL;
}
- if (BE (RE_DUP_MAX < (end == -1 ? start : end), 0))
+ if (__glibc_unlikely (RE_DUP_MAX < (end == -1 ? start : end)))
{
*err = REG_ESIZE;
return NULL;
fetch_token (token, regexp, syntax);
- if (BE (elem == NULL, 0))
+ if (__glibc_unlikely (elem == NULL))
return NULL;
- if (BE (start == 0 && end == 0, 0))
+ if (__glibc_unlikely (start == 0 && end == 0))
{
postorder (elem, free_tree, NULL);
return NULL;
}
/* Extract "<re>{n,m}" to "<re><re>...<re><re>{0,<m-n>}". */
- if (BE (start > 0, 0))
+ if (__glibc_unlikely (start > 0))
{
tree = elem;
for (i = 2; i <= start; ++i)
{
elem = duplicate_tree (elem, dfa);
tree = create_tree (dfa, tree, elem, CONCAT);
- if (BE (elem == NULL || tree == NULL, 0))
+ if (__glibc_unlikely (elem == NULL || tree == NULL))
goto parse_dup_op_espace;
}
/* Duplicate ELEM before it is marked optional. */
elem = duplicate_tree (elem, dfa);
- if (BE (elem == NULL, 0))
+ if (__glibc_unlikely (elem == NULL))
goto parse_dup_op_espace;
old_tree = tree;
}
tree = create_tree (dfa, elem, NULL,
(end == -1 ? OP_DUP_ASTERISK : OP_ALT));
- if (BE (tree == NULL, 0))
+ if (__glibc_unlikely (tree == NULL))
goto parse_dup_op_espace;
/* This loop is actually executed only when end != -1,
{
elem = duplicate_tree (elem, dfa);
tree = create_tree (dfa, tree, elem, CONCAT);
- if (BE (elem == NULL || tree == NULL, 0))
+ if (__glibc_unlikely (elem == NULL || tree == NULL))
goto parse_dup_op_espace;
tree = create_tree (dfa, tree, NULL, OP_ALT);
- if (BE (tree == NULL, 0))
+ if (__glibc_unlikely (tree == NULL))
goto parse_dup_op_espace;
}
{
unsigned int start_ch, end_ch;
/* Equivalence Classes and Character Classes can't be a range start/end. */
- if (BE (start_elem->type == EQUIV_CLASS || start_elem->type == CHAR_CLASS
- || end_elem->type == EQUIV_CLASS || end_elem->type == CHAR_CLASS,
- 0))
+ if (__glibc_unlikely (start_elem->type == EQUIV_CLASS
+ || start_elem->type == CHAR_CLASS
+ || end_elem->type == EQUIV_CLASS
+ || end_elem->type == CHAR_CLASS))
return REG_ERANGE;
/* We can handle no multi character collating elements without libc
support. */
- if (BE ((start_elem->type == COLL_SYM
- && strlen ((char *) start_elem->opr.name) > 1)
- || (end_elem->type == COLL_SYM
- && strlen ((char *) end_elem->opr.name) > 1), 0))
+ if (__glibc_unlikely ((start_elem->type == COLL_SYM
+ && strlen ((char *) start_elem->opr.name) > 1)
+ || (end_elem->type == COLL_SYM
+ && strlen ((char *) end_elem->opr.name) > 1)))
return REG_ECOLLATE;
# ifdef RE_ENABLE_I18N
? parse_byte (end_ch, mbcset) : end_elem->opr.wch);
if (start_wc == WEOF || end_wc == WEOF)
return REG_ECOLLATE;
- else if (BE ((syntax & RE_NO_EMPTY_RANGES) && start_wc > end_wc, 0))
+ else if (__glibc_unlikely ((syntax & RE_NO_EMPTY_RANGES)
+ && start_wc > end_wc))
return REG_ERANGE;
/* Got valid collation sequence values, add them as a new entry.
if (mbcset)
{
/* Check the space of the arrays. */
- if (BE (*range_alloc == mbcset->nranges, 0))
+ if (__glibc_unlikely (*range_alloc == mbcset->nranges))
{
/* There is not enough space, need realloc. */
wchar_t *new_array_start, *new_array_end;
new_array_end = re_realloc (mbcset->range_ends, wchar_t,
new_nranges);
- if (BE (new_array_start == NULL || new_array_end == NULL, 0))
+ if (__glibc_unlikely (new_array_start == NULL
+ || new_array_end == NULL))
{
re_free (new_array_start);
re_free (new_array_end);
# endif /* not RE_ENABLE_I18N */
{
size_t name_len = strlen ((const char *) name);
- if (BE (name_len != 1, 0))
+ if (__glibc_unlikely (name_len != 1))
return REG_ECOLLATE;
else
{
/* Equivalence Classes and Character Classes can't be a range
start/end. */
- if (BE (start_elem->type == EQUIV_CLASS || start_elem->type == CHAR_CLASS
- || end_elem->type == EQUIV_CLASS || end_elem->type == CHAR_CLASS,
- 0))
+ if (__glibc_unlikely (start_elem->type == EQUIV_CLASS
+ || start_elem->type == CHAR_CLASS
+ || end_elem->type == EQUIV_CLASS
+ || end_elem->type == CHAR_CLASS))
return REG_ERANGE;
/* FIXME: Implement rational ranges here, too. */
start_collseq = lookup_collation_sequence_value (start_elem);
end_collseq = lookup_collation_sequence_value (end_elem);
/* Check start/end collation sequence values. */
- if (BE (start_collseq == UINT_MAX || end_collseq == UINT_MAX, 0))
+ if (__glibc_unlikely (start_collseq == UINT_MAX
+ || end_collseq == UINT_MAX))
return REG_ECOLLATE;
- if (BE ((syntax & RE_NO_EMPTY_RANGES) && start_collseq > end_collseq, 0))
+ if (__glibc_unlikely ((syntax & RE_NO_EMPTY_RANGES)
+ && start_collseq > end_collseq))
return REG_ERANGE;
/* Got valid collation sequence values, add them as a new entry.
if (nrules > 0 || dfa->mb_cur_max > 1)
{
/* Check the space of the arrays. */
- if (BE (*range_alloc == mbcset->nranges, 0))
+ if (__glibc_unlikely (*range_alloc == mbcset->nranges))
{
/* There is not enough space, need realloc. */
uint32_t *new_array_start;
new_array_end = re_realloc (mbcset->range_ends, uint32_t,
new_nranges);
- if (BE (new_array_start == NULL || new_array_end == NULL, 0))
+ if (__glibc_unlikely (new_array_start == NULL
+ || new_array_end == NULL))
return REG_ESPACE;
mbcset->range_starts = new_array_start;
/* Got valid collation sequence, add it as a new entry. */
/* Check the space of the arrays. */
- if (BE (*coll_sym_alloc == mbcset->ncoll_syms, 0))
+ if (__glibc_unlikely (*coll_sym_alloc == mbcset->ncoll_syms))
{
/* Not enough, realloc it. */
/* +1 in case of mbcset->ncoll_syms is 0. */
if *alloc == 0. */
int32_t *new_coll_syms = re_realloc (mbcset->coll_syms, int32_t,
new_coll_sym_alloc);
- if (BE (new_coll_syms == NULL, 0))
+ if (__glibc_unlikely (new_coll_syms == NULL))
return REG_ESPACE;
mbcset->coll_syms = new_coll_syms;
*coll_sym_alloc = new_coll_sym_alloc;
}
else
{
- if (BE (name_len != 1, 0))
+ if (__glibc_unlikely (name_len != 1))
return REG_ECOLLATE;
else
{
mbcset = (re_charset_t *) calloc (sizeof (re_charset_t), 1);
#endif /* RE_ENABLE_I18N */
#ifdef RE_ENABLE_I18N
- if (BE (sbcset == NULL || mbcset == NULL, 0))
+ if (__glibc_unlikely (sbcset == NULL || mbcset == NULL))
#else
- if (BE (sbcset == NULL, 0))
+ if (__glibc_unlikely (sbcset == NULL))
#endif /* RE_ENABLE_I18N */
{
re_free (sbcset);
}
token_len = peek_token_bracket (token, regexp, syntax);
- if (BE (token->type == END_OF_RE, 0))
+ if (__glibc_unlikely (token->type == END_OF_RE))
{
*err = REG_BADPAT;
goto parse_bracket_exp_free_return;
bitset_set (sbcset, '\n');
re_string_skip_bytes (regexp, token_len); /* Skip a token. */
token_len = peek_token_bracket (token, regexp, syntax);
- if (BE (token->type == END_OF_RE, 0))
+ if (__glibc_unlikely (token->type == END_OF_RE))
{
*err = REG_BADPAT;
goto parse_bracket_exp_free_return;
start_elem.type = COLL_SYM;
ret = parse_bracket_element (&start_elem, regexp, token, token_len, dfa,
syntax, first_round);
- if (BE (ret != REG_NOERROR, 0))
+ if (__glibc_unlikely (ret != REG_NOERROR))
{
*err = ret;
goto parse_bracket_exp_free_return;
/* Do not check for ranges if we know they are not allowed. */
if (start_elem.type != CHAR_CLASS && start_elem.type != EQUIV_CLASS)
{
- if (BE (token->type == END_OF_RE, 0))
+ if (__glibc_unlikely (token->type == END_OF_RE))
{
*err = REG_EBRACK;
goto parse_bracket_exp_free_return;
{
re_string_skip_bytes (regexp, token_len); /* Skip '-'. */
token_len2 = peek_token_bracket (&token2, regexp, syntax);
- if (BE (token2.type == END_OF_RE, 0))
+ if (__glibc_unlikely (token2.type == END_OF_RE))
{
*err = REG_EBRACK;
goto parse_bracket_exp_free_return;
end_elem.type = COLL_SYM;
ret = parse_bracket_element (&end_elem, regexp, &token2, token_len2,
dfa, syntax, true);
- if (BE (ret != REG_NOERROR, 0))
+ if (__glibc_unlikely (ret != REG_NOERROR))
{
*err = ret;
goto parse_bracket_exp_free_return;
*err = build_range_exp (syntax, sbcset, &start_elem, &end_elem);
# endif
#endif /* RE_ENABLE_I18N */
- if (BE (*err != REG_NOERROR, 0))
+ if (__glibc_unlikely (*err != REG_NOERROR))
goto parse_bracket_exp_free_return;
}
else
#ifdef RE_ENABLE_I18N
case MB_CHAR:
/* Check whether the array has enough space. */
- if (BE (mbchar_alloc == mbcset->nmbchars, 0))
+ if (__glibc_unlikely (mbchar_alloc == mbcset->nmbchars))
{
wchar_t *new_mbchars;
/* Not enough, realloc it. */
/* Use realloc since array is NULL if *alloc == 0. */
new_mbchars = re_realloc (mbcset->mbchars, wchar_t,
mbchar_alloc);
- if (BE (new_mbchars == NULL, 0))
+ if (__glibc_unlikely (new_mbchars == NULL))
goto parse_bracket_exp_espace;
mbcset->mbchars = new_mbchars;
}
mbcset, &equiv_class_alloc,
#endif /* RE_ENABLE_I18N */
start_elem.opr.name);
- if (BE (*err != REG_NOERROR, 0))
+ if (__glibc_unlikely (*err != REG_NOERROR))
goto parse_bracket_exp_free_return;
break;
case COLL_SYM:
mbcset, &coll_sym_alloc,
#endif /* RE_ENABLE_I18N */
start_elem.opr.name);
- if (BE (*err != REG_NOERROR, 0))
+ if (__glibc_unlikely (*err != REG_NOERROR))
goto parse_bracket_exp_free_return;
break;
case CHAR_CLASS:
#endif /* RE_ENABLE_I18N */
(const char *) start_elem.opr.name,
syntax);
- if (BE (*err != REG_NOERROR, 0))
+ if (__glibc_unlikely (*err != REG_NOERROR))
goto parse_bracket_exp_free_return;
break;
default:
break;
}
}
- if (BE (token->type == END_OF_RE, 0))
+ if (__glibc_unlikely (token->type == END_OF_RE))
{
*err = REG_EBRACK;
goto parse_bracket_exp_free_return;
br_token.type = COMPLEX_BRACKET;
br_token.opr.mbcset = mbcset;
mbc_tree = create_token_tree (dfa, NULL, NULL, &br_token);
- if (BE (mbc_tree == NULL, 0))
+ if (__glibc_unlikely (mbc_tree == NULL))
goto parse_bracket_exp_espace;
for (sbc_idx = 0; sbc_idx < BITSET_WORDS; ++sbc_idx)
if (sbcset[sbc_idx])
br_token.type = SIMPLE_BRACKET;
br_token.opr.sbcset = sbcset;
work_tree = create_token_tree (dfa, NULL, NULL, &br_token);
- if (BE (work_tree == NULL, 0))
+ if (__glibc_unlikely (work_tree == NULL))
goto parse_bracket_exp_espace;
/* Then join them by ALT node. */
work_tree = create_tree (dfa, work_tree, mbc_tree, OP_ALT);
- if (BE (work_tree == NULL, 0))
+ if (__glibc_unlikely (work_tree == NULL))
goto parse_bracket_exp_espace;
}
else
br_token.type = SIMPLE_BRACKET;
br_token.opr.sbcset = sbcset;
work_tree = create_token_tree (dfa, NULL, NULL, &br_token);
- if (BE (work_tree == NULL, 0))
+ if (__glibc_unlikely (work_tree == NULL))
goto parse_bracket_exp_espace;
}
return work_tree;
if (token->type == OP_OPEN_COLL_ELEM || token->type == OP_OPEN_CHAR_CLASS
|| token->type == OP_OPEN_EQUIV_CLASS)
return parse_bracket_symbol (elem, regexp, token);
- if (BE (token->type == OP_CHARSET_RANGE, 0) && !accept_hyphen)
+ if (__glibc_unlikely (token->type == OP_CHARSET_RANGE) && !accept_hyphen)
{
/* A '-' must only appear as anything but a range indicator before
the closing bracket. Everything else is an error. */
indirect = (const int32_t *) _NL_CURRENT (LC_COLLATE,
_NL_COLLATE_INDIRECTMB);
idx1 = findidx (table, indirect, extra, &cp, -1);
- if (BE (idx1 == 0 || *cp != '\0', 0))
+ if (__glibc_unlikely (idx1 == 0 || *cp != '\0'))
/* This isn't a valid character. */
return REG_ECOLLATE;
bitset_set (sbcset, ch);
}
/* Check whether the array has enough space. */
- if (BE (*equiv_class_alloc == mbcset->nequiv_classes, 0))
+ if (__glibc_unlikely (*equiv_class_alloc == mbcset->nequiv_classes))
{
/* Not enough, realloc it. */
/* +1 in case of mbcset->nequiv_classes is 0. */
int32_t *new_equiv_classes = re_realloc (mbcset->equiv_classes,
int32_t,
new_equiv_class_alloc);
- if (BE (new_equiv_classes == NULL, 0))
+ if (__glibc_unlikely (new_equiv_classes == NULL))
return REG_ESPACE;
mbcset->equiv_classes = new_equiv_classes;
*equiv_class_alloc = new_equiv_class_alloc;
else
#endif /* _LIBC */
{
- if (BE (strlen ((const char *) name) != 1, 0))
+ if (__glibc_unlikely (strlen ((const char *) name) != 1))
return REG_ECOLLATE;
bitset_set (sbcset, *name);
}
#ifdef RE_ENABLE_I18N
/* Check the space of the arrays. */
- if (BE (*char_class_alloc == mbcset->nchar_classes, 0))
+ if (__glibc_unlikely (*char_class_alloc == mbcset->nchar_classes))
{
/* Not enough, realloc it. */
/* +1 in case of mbcset->nchar_classes is 0. */
/* Use realloc since array is NULL if *alloc == 0. */
wctype_t *new_char_classes = re_realloc (mbcset->char_classes, wctype_t,
new_char_class_alloc);
- if (BE (new_char_classes == NULL, 0))
+ if (__glibc_unlikely (new_char_classes == NULL))
return REG_ESPACE;
mbcset->char_classes = new_char_classes;
*char_class_alloc = new_char_class_alloc;
#define BUILD_CHARCLASS_LOOP(ctype_func) \
do { \
- if (BE (trans != NULL, 0)) \
+ if (__glibc_unlikely (trans != NULL)) \
{ \
for (i = 0; i < SBC_MAX; ++i) \
if (ctype_func (i)) \
bin_tree_t *tree;
sbcset = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1);
- if (BE (sbcset == NULL, 0))
+ if (__glibc_unlikely (sbcset == NULL))
{
*err = REG_ESPACE;
return NULL;
}
#ifdef RE_ENABLE_I18N
mbcset = (re_charset_t *) calloc (sizeof (re_charset_t), 1);
- if (BE (mbcset == NULL, 0))
+ if (__glibc_unlikely (mbcset == NULL))
{
re_free (sbcset);
*err = REG_ESPACE;
#endif /* RE_ENABLE_I18N */
class_name, 0);
- if (BE (ret != REG_NOERROR, 0))
+ if (__glibc_unlikely (ret != REG_NOERROR))
{
re_free (sbcset);
#ifdef RE_ENABLE_I18N
br_token.type = SIMPLE_BRACKET;
br_token.opr.sbcset = sbcset;
tree = create_token_tree (dfa, NULL, NULL, &br_token);
- if (BE (tree == NULL, 0))
+ if (__glibc_unlikely (tree == NULL))
goto build_word_op_espace;
#ifdef RE_ENABLE_I18N
br_token.opr.mbcset = mbcset;
dfa->has_mb_node = 1;
mbc_tree = create_token_tree (dfa, NULL, NULL, &br_token);
- if (BE (mbc_tree == NULL, 0))
+ if (__glibc_unlikely (mbc_tree == NULL))
goto build_word_op_espace;
/* Then join them by ALT node. */
tree = create_tree (dfa, tree, mbc_tree, OP_ALT);
- if (BE (mbc_tree != NULL, 1))
+ if (__glibc_likely (mbc_tree != NULL))
return tree;
}
else
{
fetch_token (token, input, syntax);
c = token->opr.c;
- if (BE (token->type == END_OF_RE, 0))
+ if (__glibc_unlikely (token->type == END_OF_RE))
return -2;
if (token->type == OP_CLOSE_DUP_NUM || c == ',')
break;
const re_token_t *token)
{
bin_tree_t *tree;
- if (BE (dfa->str_tree_storage_idx == BIN_TREE_STORAGE_SIZE, 0))
+ if (__glibc_unlikely (dfa->str_tree_storage_idx == BIN_TREE_STORAGE_SIZE))
{
bin_tree_storage_t *storage = re_malloc (bin_tree_storage_t, 1);
<https://www.gnu.org/licenses/>. */
#ifndef _LIBC
-# include <config.h>
+# include <libc-config.h>
# if (__GNUC__ == 4 && 6 <= __GNUC_MINOR__) || 4 < __GNUC__
# pragma GCC diagnostic ignored "-Wsuggest-attribute=pure"
re_string_construct_common (str, len, pstr, trans, icase, dfa);
ret = re_string_realloc_buffers (pstr, init_buf_len);
- if (BE (ret != REG_NOERROR, 0))
+ if (__glibc_unlikely (ret != REG_NOERROR))
return ret;
pstr->word_char = dfa->word_char;
if (len > 0)
{
ret = re_string_realloc_buffers (pstr, len + 1);
- if (BE (ret != REG_NOERROR, 0))
+ if (__glibc_unlikely (ret != REG_NOERROR))
return ret;
}
pstr->mbs = pstr->mbs_allocated ? pstr->mbs : (unsigned char *) str;
while (1)
{
ret = build_wcs_upper_buffer (pstr);
- if (BE (ret != REG_NOERROR, 0))
+ if (__glibc_unlikely (ret != REG_NOERROR))
return ret;
if (pstr->valid_raw_len >= len)
break;
if (pstr->bufs_len > pstr->valid_len + dfa->mb_cur_max)
break;
ret = re_string_realloc_buffers (pstr, pstr->bufs_len * 2);
- if (BE (ret != REG_NOERROR, 0))
+ if (__glibc_unlikely (ret != REG_NOERROR))
return ret;
}
}
/* Avoid overflow in realloc. */
const size_t max_object_size = MAX (sizeof (wint_t), sizeof (Idx));
- if (BE (MIN (IDX_MAX, SIZE_MAX / max_object_size) < new_buf_len, 0))
+ if (__glibc_unlikely (MIN (IDX_MAX, SIZE_MAX / max_object_size)
+ < new_buf_len))
return REG_ESPACE;
new_wcs = re_realloc (pstr->wcs, wint_t, new_buf_len);
- if (BE (new_wcs == NULL, 0))
+ if (__glibc_unlikely (new_wcs == NULL))
return REG_ESPACE;
pstr->wcs = new_wcs;
if (pstr->offsets != NULL)
{
Idx *new_offsets = re_realloc (pstr->offsets, Idx, new_buf_len);
- if (BE (new_offsets == NULL, 0))
+ if (__glibc_unlikely (new_offsets == NULL))
return REG_ESPACE;
pstr->offsets = new_offsets;
}
{
unsigned char *new_mbs = re_realloc (pstr->mbs, unsigned char,
new_buf_len);
- if (BE (new_mbs == NULL, 0))
+ if (__glibc_unlikely (new_mbs == NULL))
return REG_ESPACE;
pstr->mbs = new_mbs;
}
remain_len = end_idx - byte_idx;
prev_st = pstr->cur_state;
/* Apply the translation if we need. */
- if (BE (pstr->trans != NULL, 0))
+ if (__glibc_unlikely (pstr->trans != NULL))
{
int i, ch;
else
p = (const char *) pstr->raw_mbs + pstr->raw_mbs_idx + byte_idx;
mbclen = __mbrtowc (&wc, p, remain_len, &pstr->cur_state);
- if (BE (mbclen == (size_t) -1 || mbclen == 0
- || (mbclen == (size_t) -2 && pstr->bufs_len >= pstr->len), 0))
+ if (__glibc_unlikely (mbclen == (size_t) -1 || mbclen == 0
+ || (mbclen == (size_t) -2
+ && pstr->bufs_len >= pstr->len)))
{
/* We treat these cases as a singlebyte character. */
mbclen = 1;
wc = (wchar_t) pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx];
- if (BE (pstr->trans != NULL, 0))
+ if (__glibc_unlikely (pstr->trans != NULL))
wc = pstr->trans[wc];
pstr->cur_state = prev_st;
}
- else if (BE (mbclen == (size_t) -2, 0))
+ else if (__glibc_unlikely (mbclen == (size_t) -2))
{
/* The buffer doesn't have enough space, finish to build. */
pstr->cur_state = prev_st;
mbclen = __mbrtowc (&wc,
((const char *) pstr->raw_mbs + pstr->raw_mbs_idx
+ byte_idx), remain_len, &pstr->cur_state);
- if (BE (0 < mbclen && mbclen < (size_t) -2, 1))
+ if (__glibc_likely (0 < mbclen && mbclen < (size_t) -2))
{
wchar_t wcu = __towupper (wc);
if (wcu != wc)
size_t mbcdlen;
mbcdlen = __wcrtomb (buf, wcu, &prev_st);
- if (BE (mbclen == mbcdlen, 1))
+ if (__glibc_likely (mbclen == mbcdlen))
memcpy (pstr->mbs + byte_idx, buf, mbclen);
else
{
pstr->mbs[byte_idx] = ch;
/* And also cast it to wide char. */
pstr->wcs[byte_idx++] = (wchar_t) ch;
- if (BE (mbclen == (size_t) -1, 0))
+ if (__glibc_unlikely (mbclen == (size_t) -1))
pstr->cur_state = prev_st;
}
else
offsets_needed:
remain_len = end_idx - byte_idx;
prev_st = pstr->cur_state;
- if (BE (pstr->trans != NULL, 0))
+ if (__glibc_unlikely (pstr->trans != NULL))
{
int i, ch;
else
p = (const char *) pstr->raw_mbs + pstr->raw_mbs_idx + src_idx;
mbclen = __mbrtowc (&wc, p, remain_len, &pstr->cur_state);
- if (BE (0 < mbclen && mbclen < (size_t) -2, 1))
+ if (__glibc_likely (0 < mbclen && mbclen < (size_t) -2))
{
wchar_t wcu = __towupper (wc);
if (wcu != wc)
size_t mbcdlen;
mbcdlen = __wcrtomb ((char *) buf, wcu, &prev_st);
- if (BE (mbclen == mbcdlen, 1))
+ if (__glibc_likely (mbclen == mbcdlen))
memcpy (pstr->mbs + byte_idx, buf, mbclen);
else if (mbcdlen != (size_t) -1)
{
else
memcpy (pstr->mbs + byte_idx, p, mbclen);
- if (BE (pstr->offsets_needed != 0, 0))
+ if (__glibc_unlikely (pstr->offsets_needed != 0))
{
size_t i;
for (i = 0; i < mbclen; ++i)
/* It is an invalid character or '\0'. Just use the byte. */
int ch = pstr->raw_mbs[pstr->raw_mbs_idx + src_idx];
- if (BE (pstr->trans != NULL, 0))
+ if (__glibc_unlikely (pstr->trans != NULL))
ch = pstr->trans [ch];
pstr->mbs[byte_idx] = ch;
- if (BE (pstr->offsets_needed != 0, 0))
+ if (__glibc_unlikely (pstr->offsets_needed != 0))
pstr->offsets[byte_idx] = src_idx;
++src_idx;
/* And also cast it to wide char. */
pstr->wcs[byte_idx++] = (wchar_t) ch;
- if (BE (mbclen == (size_t) -1, 0))
+ if (__glibc_unlikely (mbclen == (size_t) -1))
pstr->cur_state = prev_st;
}
else
prev_st = pstr->cur_state;
mbclen = __mbrtowc (&wc2, (const char *) pstr->raw_mbs + rawbuf_idx,
remain_len, &pstr->cur_state);
- if (BE (mbclen == (size_t) -2 || mbclen == (size_t) -1 || mbclen == 0, 0))
+ if (__glibc_unlikely (mbclen == (size_t) -2 || mbclen == (size_t) -1
+ || mbclen == 0))
{
/* We treat these cases as a single byte character. */
if (mbclen == 0 || remain_len == 0)
for (char_idx = pstr->valid_len; char_idx < end_idx; ++char_idx)
{
int ch = pstr->raw_mbs[pstr->raw_mbs_idx + char_idx];
- if (BE (pstr->trans != NULL, 0))
+ if (__glibc_unlikely (pstr->trans != NULL))
ch = pstr->trans[ch];
pstr->mbs[char_idx] = toupper (ch);
}
{
Idx offset;
- if (BE (pstr->raw_mbs_idx <= idx, 0))
+ if (__glibc_unlikely (pstr->raw_mbs_idx <= idx))
offset = idx - pstr->raw_mbs_idx;
else
{
offset = idx;
}
- if (BE (offset != 0, 1))
+ if (__glibc_likely (offset != 0))
{
/* Should the already checked characters be kept? */
- if (BE (offset < pstr->valid_raw_len, 1))
+ if (__glibc_likely (offset < pstr->valid_raw_len))
{
/* Yes, move them to the front of the buffer. */
#ifdef RE_ENABLE_I18N
- if (BE (pstr->offsets_needed, 0))
+ if (__glibc_unlikely (pstr->offsets_needed))
{
Idx low = 0, high = pstr->valid_len, mid;
do
memmove (pstr->wcs, pstr->wcs + offset,
(pstr->valid_len - offset) * sizeof (wint_t));
#endif /* RE_ENABLE_I18N */
- if (BE (pstr->mbs_allocated, 0))
+ if (__glibc_unlikely (pstr->mbs_allocated))
memmove (pstr->mbs, pstr->mbs + offset,
pstr->valid_len - offset);
pstr->valid_len -= offset;
/* No, skip all characters until IDX. */
Idx prev_valid_len = pstr->valid_len;
- if (BE (pstr->offsets_needed, 0))
+ if (__glibc_unlikely (pstr->offsets_needed))
{
pstr->len = pstr->raw_len - idx + offset;
pstr->stop = pstr->raw_stop - idx + offset;
#ifdef _LIBC
/* We know the wchar_t encoding is UCS4, so for the simple
case, ASCII characters, skip the conversion step. */
- if (isascii (*p) && BE (pstr->trans == NULL, 1))
+ if (isascii (*p) && __glibc_likely (pstr->trans == NULL))
{
memset (&pstr->cur_state, '\0', sizeof (mbstate_t));
/* pstr->valid_len = 0; */
size_t mbclen;
const unsigned char *pp = p;
- if (BE (pstr->trans != NULL, 0))
+ if (__glibc_unlikely (pstr->trans != NULL))
{
int i = mlen < 6 ? mlen : 6;
while (--i >= 0)
pstr->tip_context
= re_string_context_at (pstr, prev_valid_len - 1, eflags);
else
- pstr->tip_context = ((BE (pstr->word_ops_used != 0, 0)
+ pstr->tip_context = ((__glibc_unlikely (pstr->word_ops_used != 0)
&& IS_WIDE_WORD_CHAR (wc))
? CONTEXT_WORD
: ((IS_WIDE_NEWLINE (wc)
&& pstr->newline_anchor)
? CONTEXT_NEWLINE : 0));
- if (BE (pstr->valid_len, 0))
+ if (__glibc_unlikely (pstr->valid_len))
{
for (wcs_idx = 0; wcs_idx < pstr->valid_len; ++wcs_idx)
pstr->wcs[wcs_idx] = WEOF;
? CONTEXT_NEWLINE : 0));
}
}
- if (!BE (pstr->mbs_allocated, 0))
+ if (!__glibc_unlikely (pstr->mbs_allocated))
pstr->mbs += offset;
}
pstr->raw_mbs_idx = idx;
if (pstr->icase)
{
reg_errcode_t ret = build_wcs_upper_buffer (pstr);
- if (BE (ret != REG_NOERROR, 0))
+ if (__glibc_unlikely (ret != REG_NOERROR))
return ret;
}
else
}
else
#endif /* RE_ENABLE_I18N */
- if (BE (pstr->mbs_allocated, 0))
+ if (__glibc_unlikely (pstr->mbs_allocated))
{
if (pstr->icase)
build_upper_buffer (pstr);
Idx off;
/* Handle the common (easiest) cases first. */
- if (BE (!pstr->mbs_allocated, 1))
+ if (__glibc_likely (!pstr->mbs_allocated))
return re_string_peek_byte (pstr, idx);
#ifdef RE_ENABLE_I18N
static unsigned char
re_string_fetch_byte_case (re_string_t *pstr)
{
- if (BE (!pstr->mbs_allocated, 1))
+ if (__glibc_likely (!pstr->mbs_allocated))
return re_string_fetch_byte (pstr);
#ifdef RE_ENABLE_I18N
re_string_context_at (const re_string_t *input, Idx idx, int eflags)
{
int c;
- if (BE (idx < 0, 0))
+ if (__glibc_unlikely (idx < 0))
/* In this case, we use the value stored in input->tip_context,
since we can't know the character in input->mbs[-1] here. */
return input->tip_context;
- if (BE (idx == input->len, 0))
+ if (__glibc_unlikely (idx == input->len))
return ((eflags & REG_NOTEOL) ? CONTEXT_ENDBUF
: CONTEXT_NEWLINE | CONTEXT_ENDBUF);
#ifdef RE_ENABLE_I18N
return input->tip_context;
}
wc = input->wcs[wc_idx];
- if (BE (input->word_ops_used != 0, 0) && IS_WIDE_WORD_CHAR (wc))
+ if (__glibc_unlikely (input->word_ops_used != 0)
+ && IS_WIDE_WORD_CHAR (wc))
return CONTEXT_WORD;
return (IS_WIDE_NEWLINE (wc) && input->newline_anchor
? CONTEXT_NEWLINE : 0);
set->alloc = size;
set->nelem = 0;
set->elems = re_malloc (Idx, size);
- if (BE (set->elems == NULL, 0) && (MALLOC_0_IS_NONNULL || size != 0))
+ if (__glibc_unlikely (set->elems == NULL)
+ && (MALLOC_0_IS_NONNULL || size != 0))
return REG_ESPACE;
return REG_NOERROR;
}
set->alloc = 1;
set->nelem = 1;
set->elems = re_malloc (Idx, 1);
- if (BE (set->elems == NULL, 0))
+ if (__glibc_unlikely (set->elems == NULL))
{
set->alloc = set->nelem = 0;
return REG_ESPACE;
{
set->alloc = 2;
set->elems = re_malloc (Idx, 2);
- if (BE (set->elems == NULL, 0))
+ if (__glibc_unlikely (set->elems == NULL))
return REG_ESPACE;
if (elem1 == elem2)
{
{
dest->alloc = dest->nelem;
dest->elems = re_malloc (Idx, dest->alloc);
- if (BE (dest->elems == NULL, 0))
+ if (__glibc_unlikely (dest->elems == NULL))
{
dest->alloc = dest->nelem = 0;
return REG_ESPACE;
{
Idx new_alloc = src1->nelem + src2->nelem + dest->alloc;
Idx *new_elems = re_realloc (dest->elems, Idx, new_alloc);
- if (BE (new_elems == NULL, 0))
+ if (__glibc_unlikely (new_elems == NULL))
return REG_ESPACE;
dest->elems = new_elems;
dest->alloc = new_alloc;
{
dest->alloc = src1->nelem + src2->nelem;
dest->elems = re_malloc (Idx, dest->alloc);
- if (BE (dest->elems == NULL, 0))
+ if (__glibc_unlikely (dest->elems == NULL))
return REG_ESPACE;
}
else
{
Idx new_alloc = 2 * (src->nelem + dest->alloc);
Idx *new_buffer = re_realloc (dest->elems, Idx, new_alloc);
- if (BE (new_buffer == NULL, 0))
+ if (__glibc_unlikely (new_buffer == NULL))
return REG_ESPACE;
dest->elems = new_buffer;
dest->alloc = new_alloc;
}
- if (BE (dest->nelem == 0, 0))
+ if (__glibc_unlikely (dest->nelem == 0))
{
dest->nelem = src->nelem;
memcpy (dest->elems, src->elems, src->nelem * sizeof (Idx));
Idx idx;
/* In case the set is empty. */
if (set->alloc == 0)
- return BE (re_node_set_init_1 (set, elem) == REG_NOERROR, 1);
+ return __glibc_likely (re_node_set_init_1 (set, elem) == REG_NOERROR);
- if (BE (set->nelem, 0) == 0)
+ if (__glibc_unlikely (set->nelem) == 0)
{
/* We already guaranteed above that set->alloc != 0. */
set->elems[0] = elem;
Idx *new_elems;
set->alloc = set->alloc * 2;
new_elems = re_realloc (set->elems, Idx, set->alloc);
- if (BE (new_elems == NULL, 0))
+ if (__glibc_unlikely (new_elems == NULL))
return false;
set->elems = new_elems;
}
Idx *new_elems;
set->alloc = (set->alloc + 1) * 2;
new_elems = re_realloc (set->elems, Idx, set->alloc);
- if (BE (new_elems == NULL, 0))
+ if (__glibc_unlikely (new_elems == NULL))
return false;
set->elems = new_elems;
}
static Idx
re_dfa_add_node (re_dfa_t *dfa, re_token_t token)
{
- if (BE (dfa->nodes_len >= dfa->nodes_alloc, 0))
+ if (__glibc_unlikely (dfa->nodes_len >= dfa->nodes_alloc))
{
size_t new_nodes_alloc = dfa->nodes_alloc * 2;
Idx *new_nexts, *new_indices;
const size_t max_object_size = MAX (sizeof (re_token_t),
MAX (sizeof (re_node_set),
sizeof (Idx)));
- if (BE (MIN (IDX_MAX, SIZE_MAX / max_object_size) < new_nodes_alloc, 0))
+ if (__glibc_unlikely (MIN (IDX_MAX, SIZE_MAX / max_object_size)
+ < new_nodes_alloc))
return -1;
new_nodes = re_realloc (dfa->nodes, re_token_t, new_nodes_alloc);
- if (BE (new_nodes == NULL, 0))
+ if (__glibc_unlikely (new_nodes == NULL))
return -1;
dfa->nodes = new_nodes;
new_nexts = re_realloc (dfa->nexts, Idx, new_nodes_alloc);
new_indices = re_realloc (dfa->org_indices, Idx, new_nodes_alloc);
new_edests = re_realloc (dfa->edests, re_node_set, new_nodes_alloc);
new_eclosures = re_realloc (dfa->eclosures, re_node_set, new_nodes_alloc);
- if (BE (new_nexts == NULL || new_indices == NULL
- || new_edests == NULL || new_eclosures == NULL, 0))
+ if (__glibc_unlikely (new_nexts == NULL || new_indices == NULL
+ || new_edests == NULL || new_eclosures == NULL))
{
re_free (new_nexts);
re_free (new_indices);
/* Suppress bogus uninitialized-variable warnings. */
*err = REG_NOERROR;
#endif
- if (BE (nodes->nelem == 0, 0))
+ if (__glibc_unlikely (nodes->nelem == 0))
{
*err = REG_NOERROR;
return NULL;
/* There are no appropriate state in the dfa, create the new one. */
new_state = create_ci_newstate (dfa, nodes, hash);
- if (BE (new_state == NULL, 0))
+ if (__glibc_unlikely (new_state == NULL))
*err = REG_ESPACE;
return new_state;
}
/* There are no appropriate state in 'dfa', create the new one. */
new_state = create_cd_newstate (dfa, nodes, context, hash);
- if (BE (new_state == NULL, 0))
+ if (__glibc_unlikely (new_state == NULL))
*err = REG_ESPACE;
return new_state;
newstate->hash = hash;
err = re_node_set_alloc (&newstate->non_eps_nodes, newstate->nodes.nelem);
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
return REG_ESPACE;
for (i = 0; i < newstate->nodes.nelem; i++)
{
}
spot = dfa->state_table + (hash & dfa->state_hash_mask);
- if (BE (spot->alloc <= spot->num, 0))
+ if (__glibc_unlikely (spot->alloc <= spot->num))
{
Idx new_alloc = 2 * spot->num + 2;
re_dfastate_t **new_array = re_realloc (spot->array, re_dfastate_t *,
new_alloc);
- if (BE (new_array == NULL, 0))
+ if (__glibc_unlikely (new_array == NULL))
return REG_ESPACE;
spot->array = new_array;
spot->alloc = new_alloc;
re_dfastate_t *newstate;
newstate = (re_dfastate_t *) calloc (sizeof (re_dfastate_t), 1);
- if (BE (newstate == NULL, 0))
+ if (__glibc_unlikely (newstate == NULL))
return NULL;
err = re_node_set_init_copy (&newstate->nodes, nodes);
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
{
re_free (newstate);
return NULL;
newstate->has_constraint = 1;
}
err = register_state (dfa, newstate, hash);
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
{
free_state (newstate);
newstate = NULL;
re_dfastate_t *newstate;
newstate = (re_dfastate_t *) calloc (sizeof (re_dfastate_t), 1);
- if (BE (newstate == NULL, 0))
+ if (__glibc_unlikely (newstate == NULL))
return NULL;
err = re_node_set_init_copy (&newstate->nodes, nodes);
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
{
re_free (newstate);
return NULL;
if (newstate->entrance_nodes == &newstate->nodes)
{
newstate->entrance_nodes = re_malloc (re_node_set, 1);
- if (BE (newstate->entrance_nodes == NULL, 0))
+ if (__glibc_unlikely (newstate->entrance_nodes == NULL))
{
free_state (newstate);
return NULL;
}
}
err = register_state (dfa, newstate, hash);
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
{
free_state (newstate);
newstate = NULL;
#include <stdbool.h>
#include <stdint.h>
-/* Properties of integers. Although Gnulib has intprops.h, glibc does
- without for now. */
-#ifndef _LIBC
-# include "intprops.h"
-#else
-/* True if the real type T is signed. */
-# define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
-
-/* True if adding the nonnegative Idx values A and B would overflow.
- If false, set *R to A + B. A, B, and R may be evaluated more than
- once, or zero times. Although this is not a full implementation of
- Gnulib INT_ADD_WRAPV, it is good enough for glibc regex code.
- FIXME: This implementation is a fragile stopgap, and this file would
- be simpler and more robust if intprops.h were migrated into glibc. */
-# define INT_ADD_WRAPV(a, b, r) \
- (IDX_MAX - (a) < (b) ? true : (*(r) = (a) + (b), false))
-#endif
+#include <intprops.h>
#ifdef _LIBC
# include <libc-lock.h>
# define RE_ENABLE_I18N
#endif
-#define BE(expr, val) __builtin_expect (expr, val)
-
/* Number of ASCII characters. */
#define ASCII_CHARS 0x80
Idx len;
char *s = NULL;
- if (BE ((length1 < 0 || length2 < 0 || stop < 0
- || INT_ADD_WRAPV (length1, length2, &len)),
- 0))
+ if (__glibc_unlikely ((length1 < 0 || length2 < 0 || stop < 0
+ || INT_ADD_WRAPV (length1, length2, &len))))
return -2;
/* Concatenate the strings. */
{
s = re_malloc (char, len);
- if (BE (s == NULL, 0))
+ if (__glibc_unlikely (s == NULL))
return -2;
#ifdef _LIBC
memcpy (__mempcpy (s, string1, length1), string2, length2);
Idx last_start = start + range;
/* Check for out-of-range. */
- if (BE (start < 0 || start > length, 0))
+ if (__glibc_unlikely (start < 0 || start > length))
return -1;
- if (BE (length < last_start || (0 <= range && last_start < start), 0))
+ if (__glibc_unlikely (length < last_start
+ || (0 <= range && last_start < start)))
last_start = length;
- else if (BE (last_start < 0 || (range < 0 && start <= last_start), 0))
+ else if (__glibc_unlikely (last_start < 0
+ || (range < 0 && start <= last_start)))
last_start = 0;
lock_lock (dfa->lock);
if (start < last_start && bufp->fastmap != NULL && !bufp->fastmap_accurate)
re_compile_fastmap (bufp);
- if (BE (bufp->no_sub, 0))
+ if (__glibc_unlikely (bufp->no_sub))
regs = NULL;
/* We need at least 1 register. */
if (regs == NULL)
nregs = 1;
- else if (BE (bufp->regs_allocated == REGS_FIXED
- && regs->num_regs <= bufp->re_nsub, 0))
+ else if (__glibc_unlikely (bufp->regs_allocated == REGS_FIXED
+ && regs->num_regs <= bufp->re_nsub))
{
nregs = regs->num_regs;
- if (BE (nregs < 1, 0))
+ if (__glibc_unlikely (nregs < 1))
{
/* Nothing can be copied to regs. */
regs = NULL;
else
nregs = bufp->re_nsub + 1;
pmatch = re_malloc (regmatch_t, nregs);
- if (BE (pmatch == NULL, 0))
+ if (__glibc_unlikely (pmatch == NULL))
{
rval = -2;
goto out;
/* If caller wants register contents data back, copy them. */
bufp->regs_allocated = re_copy_regs (regs, pmatch, nregs,
bufp->regs_allocated);
- if (BE (bufp->regs_allocated == REGS_UNALLOCATED, 0))
+ if (__glibc_unlikely (bufp->regs_allocated == REGS_UNALLOCATED))
rval = -2;
}
- if (BE (rval == 0, 1))
+ if (__glibc_likely (rval == 0))
{
if (ret_len)
{
if (regs_allocated == REGS_UNALLOCATED)
{ /* No. So allocate them with malloc. */
regs->start = re_malloc (regoff_t, need_regs);
- if (BE (regs->start == NULL, 0))
+ if (__glibc_unlikely (regs->start == NULL))
return REGS_UNALLOCATED;
regs->end = re_malloc (regoff_t, need_regs);
- if (BE (regs->end == NULL, 0))
+ if (__glibc_unlikely (regs->end == NULL))
{
re_free (regs->start);
return REGS_UNALLOCATED;
{ /* Yes. If we need more elements than were already
allocated, reallocate them. If we need fewer, just
leave it alone. */
- if (BE (need_regs > regs->num_regs, 0))
+ if (__glibc_unlikely (need_regs > regs->num_regs))
{
regoff_t *new_start = re_realloc (regs->start, regoff_t, need_regs);
regoff_t *new_end;
- if (BE (new_start == NULL, 0))
+ if (__glibc_unlikely (new_start == NULL))
return REGS_UNALLOCATED;
new_end = re_realloc (regs->end, regoff_t, need_regs);
- if (BE (new_end == NULL, 0))
+ if (__glibc_unlikely (new_end == NULL))
{
re_free (new_start);
return REGS_UNALLOCATED;
nmatch -= extra_nmatch;
/* Check if the DFA haven't been compiled. */
- if (BE (preg->used == 0 || dfa->init_state == NULL
- || dfa->init_state_word == NULL || dfa->init_state_nl == NULL
- || dfa->init_state_begbuf == NULL, 0))
+ if (__glibc_unlikely (preg->used == 0 || dfa->init_state == NULL
+ || dfa->init_state_word == NULL
+ || dfa->init_state_nl == NULL
+ || dfa->init_state_begbuf == NULL))
return REG_NOMATCH;
#ifdef DEBUG
err = re_string_allocate (&mctx.input, string, length, dfa->nodes_len + 1,
preg->translate, (preg->syntax & RE_ICASE) != 0,
dfa);
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
goto free_return;
mctx.input.stop = stop;
mctx.input.raw_stop = stop;
mctx.input.newline_anchor = preg->newline_anchor;
err = match_ctx_init (&mctx, eflags, dfa->nbackref * 2);
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
goto free_return;
/* We will log all the DFA states through which the dfa pass,
if (nmatch > 1 || dfa->has_mb_node)
{
/* Avoid overflow. */
- if (BE ((MIN (IDX_MAX, SIZE_MAX / sizeof (re_dfastate_t *))
- <= mctx.input.bufs_len), 0))
+ if (__glibc_unlikely ((MIN (IDX_MAX, SIZE_MAX / sizeof (re_dfastate_t *))
+ <= mctx.input.bufs_len)))
{
err = REG_ESPACE;
goto free_return;
}
mctx.state_log = re_malloc (re_dfastate_t *, mctx.input.bufs_len + 1);
- if (BE (mctx.state_log == NULL, 0))
+ if (__glibc_unlikely (mctx.state_log == NULL))
{
err = REG_ESPACE;
goto free_return;
case 7:
/* Fastmap with single-byte translation, match forward. */
- while (BE (match_first < right_lim, 1)
+ while (__glibc_likely (match_first < right_lim)
&& !fastmap[t[(unsigned char) string[match_first]]])
++match_first;
goto forward_match_found_start_or_reached_end;
case 6:
/* Fastmap without translation, match forward. */
- while (BE (match_first < right_lim, 1)
+ while (__glibc_likely (match_first < right_lim)
&& !fastmap[(unsigned char) string[match_first]])
++match_first;
forward_match_found_start_or_reached_end:
- if (BE (match_first == right_lim, 0))
+ if (__glibc_unlikely (match_first == right_lim))
{
ch = match_first >= length
? 0 : (unsigned char) string[match_first];
/* If MATCH_FIRST is out of the valid range, reconstruct the
buffers. */
__re_size_t offset = match_first - mctx.input.raw_mbs_idx;
- if (BE (offset >= (__re_size_t) mctx.input.valid_raw_len, 0))
+ if (__glibc_unlikely (offset
+ >= (__re_size_t) mctx.input.valid_raw_len))
{
err = re_string_reconstruct (&mctx.input, match_first,
eflags);
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
goto free_return;
offset = match_first - mctx.input.raw_mbs_idx;
/* Reconstruct the buffers so that the matcher can assume that
the matching starts from the beginning of the buffer. */
err = re_string_reconstruct (&mctx.input, match_first, eflags);
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
goto free_return;
#ifdef RE_ENABLE_I18N
start <= last_start ? &match_first : NULL);
if (match_last != -1)
{
- if (BE (match_last == -2, 0))
+ if (__glibc_unlikely (match_last == -2))
{
err = REG_ESPACE;
goto free_return;
err = prune_impossible_nodes (&mctx);
if (err == REG_NOERROR)
break;
- if (BE (err != REG_NOMATCH, 0))
+ if (__glibc_unlikely (err != REG_NOMATCH))
goto free_return;
match_last = -1;
}
{
err = set_regs (preg, &mctx, nmatch, pmatch,
dfa->has_plural_match && dfa->nbackref > 0);
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
goto free_return;
}
if (pmatch[reg_idx].rm_so != -1)
{
#ifdef RE_ENABLE_I18N
- if (BE (mctx.input.offsets_needed != 0, 0))
+ if (__glibc_unlikely (mctx.input.offsets_needed != 0))
{
pmatch[reg_idx].rm_so =
(pmatch[reg_idx].rm_so == mctx.input.valid_len
halt_node = mctx->last_node;
/* Avoid overflow. */
- if (BE (MIN (IDX_MAX, SIZE_MAX / sizeof (re_dfastate_t *)) <= match_last, 0))
+ if (__glibc_unlikely (MIN (IDX_MAX, SIZE_MAX / sizeof (re_dfastate_t *))
+ <= match_last))
return REG_ESPACE;
sifted_states = re_malloc (re_dfastate_t *, match_last + 1);
- if (BE (sifted_states == NULL, 0))
+ if (__glibc_unlikely (sifted_states == NULL))
{
ret = REG_ESPACE;
goto free_return;
if (dfa->nbackref)
{
lim_states = re_malloc (re_dfastate_t *, match_last + 1);
- if (BE (lim_states == NULL, 0))
+ if (__glibc_unlikely (lim_states == NULL))
{
ret = REG_ESPACE;
goto free_return;
match_last);
ret = sift_states_backward (mctx, &sctx);
re_node_set_free (&sctx.limits);
- if (BE (ret != REG_NOERROR, 0))
+ if (__glibc_unlikely (ret != REG_NOERROR))
goto free_return;
if (sifted_states[0] != NULL || lim_states[0] != NULL)
break;
match_last + 1);
re_free (lim_states);
lim_states = NULL;
- if (BE (ret != REG_NOERROR, 0))
+ if (__glibc_unlikely (ret != REG_NOERROR))
goto free_return;
}
else
sift_ctx_init (&sctx, sifted_states, lim_states, halt_node, match_last);
ret = sift_states_backward (mctx, &sctx);
re_node_set_free (&sctx.limits);
- if (BE (ret != REG_NOERROR, 0))
+ if (__glibc_unlikely (ret != REG_NOERROR))
goto free_return;
if (sifted_states[0] == NULL)
{
err = REG_NOERROR;
cur_state = acquire_init_state_context (&err, mctx, cur_str_idx);
/* An initial state must not be NULL (invalid). */
- if (BE (cur_state == NULL, 0))
+ if (__glibc_unlikely (cur_state == NULL))
{
assert (err == REG_ESPACE);
return -2;
/* Check OP_OPEN_SUBEXP in the initial state in case that we use them
later. E.g. Processing back references. */
- if (BE (dfa->nbackref, 0))
+ if (__glibc_unlikely (dfa->nbackref))
{
at_init_state = false;
err = check_subexp_matching_top (mctx, &cur_state->nodes, 0);
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
return err;
if (cur_state->has_backref)
{
err = transit_state_bkref (mctx, &cur_state->nodes);
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
return err;
}
}
}
/* If the RE accepts NULL string. */
- if (BE (cur_state->halt, 0))
+ if (__glibc_unlikely (cur_state->halt))
{
if (!cur_state->has_constraint
|| check_halt_state_context (mctx, cur_state, cur_str_idx))
re_dfastate_t *old_state = cur_state;
Idx next_char_idx = re_string_cur_idx (&mctx->input) + 1;
- if ((BE (next_char_idx >= mctx->input.bufs_len, 0)
+ if ((__glibc_unlikely (next_char_idx >= mctx->input.bufs_len)
&& mctx->input.bufs_len < mctx->input.len)
- || (BE (next_char_idx >= mctx->input.valid_len, 0)
+ || (__glibc_unlikely (next_char_idx >= mctx->input.valid_len)
&& mctx->input.valid_len < mctx->input.len))
{
err = extend_buffers (mctx, next_char_idx + 1);
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
{
assert (err == REG_ESPACE);
return -2;
/* Reached the invalid state or an error. Try to recover a valid
state using the state log, if available and if we have not
already found a valid (even if not the longest) match. */
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
return -2;
if (mctx->state_log == NULL
break;
}
- if (BE (at_init_state, 0))
+ if (__glibc_unlikely (at_init_state))
{
if (old_state == cur_state)
next_start_idx = next_char_idx;
re_node_set *edests = &dfa->edests[node];
Idx dest_node;
ok = re_node_set_insert (eps_via_nodes, node);
- if (BE (! ok, 0))
+ if (__glibc_unlikely (! ok))
return -2;
/* Pick up a valid destination, or return -1 if none
is found. */
{
Idx dest_node;
ok = re_node_set_insert (eps_via_nodes, node);
- if (BE (! ok, 0))
+ if (__glibc_unlikely (! ok))
return -2;
dest_node = dfa->edests[node].elems[0];
if (re_node_set_contains (&mctx->state_log[*pidx]->nodes,
cur_node = proceed_next_node (mctx, nmatch, pmatch, &idx, cur_node,
&eps_via_nodes, fs);
- if (BE (cur_node < 0, 0))
+ if (__glibc_unlikely (cur_node < 0))
{
- if (BE (cur_node == -2, 0))
+ if (__glibc_unlikely (cur_node == -2))
{
re_node_set_free (&eps_via_nodes);
if (prev_idx_match_malloced)
/* Build sifted state_log[str_idx]. It has the nodes which can epsilon
transit to the last_node and the last_node itself. */
err = re_node_set_init_1 (&cur_dest, sctx->last_node);
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
return err;
err = update_cur_sifted_state (mctx, sctx, str_idx, &cur_dest);
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
goto free_return;
/* Then check each states in the state_log. */
if (mctx->state_log[str_idx])
{
err = build_sifted_states (mctx, sctx, str_idx, &cur_dest);
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
goto free_return;
}
- It is in CUR_SRC.
And update state_log. */
err = update_cur_sifted_state (mctx, sctx, str_idx, &cur_dest);
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
goto free_return;
}
err = REG_NOERROR;
continue;
}
ok = re_node_set_insert (cur_dest, prev_node);
- if (BE (! ok, 0))
+ if (__glibc_unlikely (! ok))
return REG_ESPACE;
}
{
reg_errcode_t err;
err = extend_buffers (mctx, next_state_log_idx + 1);
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
return err;
}
re_node_set merged_set;
err = re_node_set_init_union (&merged_set, &dst[st_idx]->nodes,
&src[st_idx]->nodes);
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
return err;
dst[st_idx] = re_acquire_state (&err, dfa, &merged_set);
re_node_set_free (&merged_set);
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
return err;
}
}
/* At first, add the nodes which can epsilon transit to a node in
DEST_NODE. */
err = add_epsilon_src_nodes (dfa, dest_nodes, candidates);
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
return err;
/* Then, check the limitations in the current sift_context. */
{
err = check_subexp_limits (dfa, dest_nodes, candidates, &sctx->limits,
mctx->bkref_ents, str_idx);
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
return err;
}
}
sctx->sifted_states[str_idx] = re_acquire_state (&err, dfa, dest_nodes);
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
return err;
}
if (candidates && mctx->state_log[str_idx]->has_backref)
{
err = sift_states_bkref (mctx, sctx, str_idx, candidates);
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
return err;
}
return REG_NOERROR;
Idx i;
re_dfastate_t *state = re_acquire_state (&err, dfa, dest_nodes);
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
return err;
if (!state->inveclosure.alloc)
{
err = re_node_set_alloc (&state->inveclosure, dest_nodes->nelem);
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
return REG_ESPACE;
for (i = 0; i < dest_nodes->nelem; i++)
{
err = re_node_set_merge (&state->inveclosure,
dfa->inveclosures + dest_nodes->elems[i]);
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
return REG_ESPACE;
}
}
{
err = re_node_set_add_intersect (&except_nodes, candidates,
dfa->inveclosures + cur_node);
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
{
re_node_set_free (&except_nodes);
return err;
{
err = sub_epsilon_src_nodes (dfa, ops_node, dest_nodes,
candidates);
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
return err;
}
Remove it form the current sifted state. */
err = sub_epsilon_src_nodes (dfa, node, dest_nodes,
candidates);
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
return err;
--node_idx;
}
Remove it form the current sifted state. */
err = sub_epsilon_src_nodes (dfa, node, dest_nodes,
candidates);
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
return err;
}
}
{
local_sctx = *sctx;
err = re_node_set_init_copy (&local_sctx.limits, &sctx->limits);
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
goto free_return;
}
local_sctx.last_node = node;
local_sctx.last_str_idx = str_idx;
ok = re_node_set_insert (&local_sctx.limits, enabled_idx);
- if (BE (! ok, 0))
+ if (__glibc_unlikely (! ok))
{
err = REG_ESPACE;
goto free_return;
}
cur_state = local_sctx.sifted_states[str_idx];
err = sift_states_backward (mctx, &local_sctx);
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
goto free_return;
if (sctx->limited_states != NULL)
{
err = merge_state_array (dfa, sctx->limited_states,
local_sctx.sifted_states,
str_idx + 1);
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
goto free_return;
}
local_sctx.sifted_states[str_idx] = cur_state;
#ifdef RE_ENABLE_I18N
/* If the current state can accept multibyte. */
- if (BE (state->accept_mb, 0))
+ if (__glibc_unlikely (state->accept_mb))
{
*err = transit_state_mb (mctx, state);
- if (BE (*err != REG_NOERROR, 0))
+ if (__glibc_unlikely (*err != REG_NOERROR))
return NULL;
}
#endif /* RE_ENABLE_I18N */
for (;;)
{
trtable = state->trtable;
- if (BE (trtable != NULL, 1))
+ if (__glibc_likely (trtable != NULL))
return trtable[ch];
trtable = state->word_trtable;
- if (BE (trtable != NULL, 1))
+ if (__glibc_likely (trtable != NULL))
{
unsigned int context;
context
table_nodes = next_state->entrance_nodes;
*err = re_node_set_init_union (&next_nodes, table_nodes,
log_nodes);
- if (BE (*err != REG_NOERROR, 0))
+ if (__glibc_unlikely (*err != REG_NOERROR))
return NULL;
}
else
re_node_set_free (&next_nodes);
}
- if (BE (dfa->nbackref, 0) && next_state != NULL)
+ if (__glibc_unlikely (dfa->nbackref) && next_state != NULL)
{
/* Check OP_OPEN_SUBEXP in the current state in case that we use them
later. We must check them here, since the back references in the
next state might use them. */
*err = check_subexp_matching_top (mctx, &next_state->nodes,
cur_idx);
- if (BE (*err != REG_NOERROR, 0))
+ if (__glibc_unlikely (*err != REG_NOERROR))
return NULL;
/* If the next state has back references. */
if (next_state->has_backref)
{
*err = transit_state_bkref (mctx, &next_state->nodes);
- if (BE (*err != REG_NOERROR, 0))
+ if (__glibc_unlikely (*err != REG_NOERROR))
return NULL;
next_state = mctx->state_log[cur_idx];
}
& ((bitset_word_t) 1 << dfa->nodes[node].opr.idx)))
{
err = match_ctx_add_subtop (mctx, node, str_idx);
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
return err;
}
}
unsigned int context;
*err = re_node_set_alloc (&next_nodes, state->nodes.nelem + 1);
- if (BE (*err != REG_NOERROR, 0))
+ if (__glibc_unlikely (*err != REG_NOERROR))
return NULL;
for (node_cnt = 0; node_cnt < state->nodes.nelem; ++node_cnt)
{
{
*err = re_node_set_merge (&next_nodes,
dfa->eclosures + dfa->nexts[cur_node]);
- if (BE (*err != REG_NOERROR, 0))
+ if (__glibc_unlikely (*err != REG_NOERROR))
{
re_node_set_free (&next_nodes);
return NULL;
mctx->max_mb_elem_len = ((mctx->max_mb_elem_len < naccepted) ? naccepted
: mctx->max_mb_elem_len);
err = clean_state_log_if_needed (mctx, dest_idx);
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
return err;
#ifdef DEBUG
assert (dfa->nexts[cur_node_idx] != -1);
{
err = re_node_set_init_union (&dest_nodes,
dest_state->entrance_nodes, new_nodes);
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
return err;
}
context = re_string_context_at (&mctx->input, dest_idx - 1,
= re_acquire_state_context (&err, dfa, &dest_nodes, context);
if (dest_state != NULL)
re_node_set_free (&dest_nodes);
- if (BE (mctx->state_log[dest_idx] == NULL && err != REG_NOERROR, 0))
+ if (__glibc_unlikely (mctx->state_log[dest_idx] == NULL
+ && err != REG_NOERROR))
return err;
}
return REG_NOERROR;
Check the substring which the substring matched. */
bkc_idx = mctx->nbkref_ents;
err = get_subexp (mctx, node_idx, cur_str_idx);
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
goto free_return;
/* And add the epsilon closures (which is 'new_dest_nodes') of
mctx->state_log[dest_str_idx]
= re_acquire_state_context (&err, dfa, new_dest_nodes,
context);
- if (BE (mctx->state_log[dest_str_idx] == NULL
- && err != REG_NOERROR, 0))
+ if (__glibc_unlikely (mctx->state_log[dest_str_idx] == NULL
+ && err != REG_NOERROR))
goto free_return;
}
else
err = re_node_set_init_union (&dest_nodes,
dest_state->entrance_nodes,
new_dest_nodes);
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
{
re_node_set_free (&dest_nodes);
goto free_return;
mctx->state_log[dest_str_idx]
= re_acquire_state_context (&err, dfa, &dest_nodes, context);
re_node_set_free (&dest_nodes);
- if (BE (mctx->state_log[dest_str_idx] == NULL
- && err != REG_NOERROR, 0))
+ if (__glibc_unlikely (mctx->state_log[dest_str_idx] == NULL
+ && err != REG_NOERROR))
goto free_return;
}
/* We need to check recursively if the backreference can epsilon
{
err = check_subexp_matching_top (mctx, new_dest_nodes,
cur_str_idx);
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
goto free_return;
err = transit_state_bkref (mctx, new_dest_nodes);
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
goto free_return;
}
}
at the back reference? */
if (sl_str_diff > 0)
{
- if (BE (bkref_str_off + sl_str_diff > mctx->input.valid_len, 0))
+ if (__glibc_unlikely (bkref_str_off + sl_str_diff
+ > mctx->input.valid_len))
{
/* Not enough chars for a successful match. */
if (bkref_str_off + sl_str_diff > mctx->input.len)
err = clean_state_log_if_needed (mctx,
bkref_str_off
+ sl_str_diff);
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
return err;
buf = (const char *) re_string_get_buffer (&mctx->input);
}
if (err == REG_NOMATCH)
continue;
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
return err;
}
at the back reference? */
if (sl_str_off > 0)
{
- if (BE (bkref_str_off >= mctx->input.valid_len, 0))
+ if (__glibc_unlikely (bkref_str_off >= mctx->input.valid_len))
{
/* If we are at the end of the input, we cannot match. */
if (bkref_str_off >= mctx->input.len)
break;
err = extend_buffers (mctx, bkref_str_off + 1);
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
return err;
buf = (const char *) re_string_get_buffer (&mctx->input);
OP_CLOSE_SUBEXP);
if (err == REG_NOMATCH)
continue;
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
return err;
sub_last = match_ctx_add_sublast (sub_top, cls_node, sl_str);
- if (BE (sub_last == NULL, 0))
+ if (__glibc_unlikely (sub_last == NULL))
return REG_ESPACE;
err = get_subexp_sub (mctx, sub_top, sub_last, bkref_node,
bkref_str_idx);
return err;
err = match_ctx_add_entry (mctx, bkref_node, bkref_str, sub_top->str_idx,
sub_last->str_idx);
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
return err;
to_idx = bkref_str + sub_last->str_idx - sub_top->str_idx;
return clean_state_log_if_needed (mctx, to_idx);
subexp_num = dfa->nodes[top_node].opr.idx;
/* Extend the buffer if we need. */
- if (BE (path->alloc < last_str + mctx->max_mb_elem_len + 1, 0))
+ if (__glibc_unlikely (path->alloc < last_str + mctx->max_mb_elem_len + 1))
{
re_dfastate_t **new_array;
Idx old_alloc = path->alloc;
Idx incr_alloc = last_str + mctx->max_mb_elem_len + 1;
Idx new_alloc;
- if (BE (IDX_MAX - old_alloc < incr_alloc, 0))
+ if (__glibc_unlikely (IDX_MAX - old_alloc < incr_alloc))
return REG_ESPACE;
new_alloc = old_alloc + incr_alloc;
- if (BE (SIZE_MAX / sizeof (re_dfastate_t *) < new_alloc, 0))
+ if (__glibc_unlikely (SIZE_MAX / sizeof (re_dfastate_t *) < new_alloc))
return REG_ESPACE;
new_array = re_realloc (path->array, re_dfastate_t *, new_alloc);
- if (BE (new_array == NULL, 0))
+ if (__glibc_unlikely (new_array == NULL))
return REG_ESPACE;
path->array = new_array;
path->alloc = new_alloc;
if (str_idx == top_str)
{
err = re_node_set_init_1 (&next_nodes, top_node);
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
return err;
err = check_arrival_expand_ecl (dfa, &next_nodes, subexp_num, type);
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
{
re_node_set_free (&next_nodes);
return err;
if (cur_state && cur_state->has_backref)
{
err = re_node_set_init_copy (&next_nodes, &cur_state->nodes);
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
return err;
}
else
{
err = expand_bkref_cache (mctx, &next_nodes, str_idx,
subexp_num, type);
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
{
re_node_set_free (&next_nodes);
return err;
}
}
cur_state = re_acquire_state_context (&err, dfa, &next_nodes, context);
- if (BE (cur_state == NULL && err != REG_NOERROR, 0))
+ if (__glibc_unlikely (cur_state == NULL && err != REG_NOERROR))
{
re_node_set_free (&next_nodes);
return err;
{
err = re_node_set_merge (&next_nodes,
&mctx->state_log[str_idx + 1]->nodes);
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
{
re_node_set_free (&next_nodes);
return err;
err = check_arrival_add_next_nodes (mctx, str_idx,
&cur_state->non_eps_nodes,
&next_nodes);
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
{
re_node_set_free (&next_nodes);
return err;
if (next_nodes.nelem)
{
err = check_arrival_expand_ecl (dfa, &next_nodes, subexp_num, type);
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
{
re_node_set_free (&next_nodes);
return err;
}
err = expand_bkref_cache (mctx, &next_nodes, str_idx,
subexp_num, type);
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
{
re_node_set_free (&next_nodes);
return err;
}
context = re_string_context_at (&mctx->input, str_idx - 1, mctx->eflags);
cur_state = re_acquire_state_context (&err, dfa, &next_nodes, context);
- if (BE (cur_state == NULL && err != REG_NOERROR, 0))
+ if (__glibc_unlikely (cur_state == NULL && err != REG_NOERROR))
{
re_node_set_free (&next_nodes);
return err;
if (dest_state)
{
err = re_node_set_merge (&union_set, &dest_state->nodes);
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
{
re_node_set_free (&union_set);
return err;
}
}
ok = re_node_set_insert (&union_set, next_node);
- if (BE (! ok, 0))
+ if (__glibc_unlikely (! ok))
{
re_node_set_free (&union_set);
return REG_ESPACE;
}
mctx->state_log[next_idx] = re_acquire_state (&err, dfa,
&union_set);
- if (BE (mctx->state_log[next_idx] == NULL
- && err != REG_NOERROR, 0))
+ if (__glibc_unlikely (mctx->state_log[next_idx] == NULL
+ && err != REG_NOERROR))
{
re_node_set_free (&union_set);
return err;
|| check_node_accept (mctx, dfa->nodes + cur_node, str_idx))
{
ok = re_node_set_insert (next_nodes, dfa->nexts[cur_node]);
- if (BE (! ok, 0))
+ if (__glibc_unlikely (! ok))
{
re_node_set_free (&union_set);
return REG_ESPACE;
assert (cur_nodes->nelem);
#endif
err = re_node_set_alloc (&new_nodes, cur_nodes->nelem);
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
return err;
/* Create a new node set NEW_NODES with the nodes which are epsilon
closures of the node in CUR_NODES. */
{
/* There are no problematic nodes, just merge them. */
err = re_node_set_merge (&new_nodes, eclosure);
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
{
re_node_set_free (&new_nodes);
return err;
/* There are problematic nodes, re-calculate incrementally. */
err = check_arrival_expand_ecl_sub (dfa, &new_nodes, cur_node,
ex_subexp, type);
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
{
re_node_set_free (&new_nodes);
return err;
if (type == OP_CLOSE_SUBEXP)
{
ok = re_node_set_insert (dst_nodes, cur_node);
- if (BE (! ok, 0))
+ if (__glibc_unlikely (! ok))
return REG_ESPACE;
}
break;
}
ok = re_node_set_insert (dst_nodes, cur_node);
- if (BE (! ok, 0))
+ if (__glibc_unlikely (! ok))
return REG_ESPACE;
if (dfa->edests[cur_node].nelem == 0)
break;
err = check_arrival_expand_ecl_sub (dfa, dst_nodes,
dfa->edests[cur_node].elems[1],
ex_subexp, type);
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
return err;
}
cur_node = dfa->edests[cur_node].elems[0];
err2 = check_arrival_expand_ecl (dfa, &new_dests, subexp_num, type);
err3 = re_node_set_merge (cur_nodes, &new_dests);
re_node_set_free (&new_dests);
- if (BE (err != REG_NOERROR || err2 != REG_NOERROR
- || err3 != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR || err2 != REG_NOERROR
+ || err3 != REG_NOERROR))
{
err = (err != REG_NOERROR ? err
: (err2 != REG_NOERROR ? err2 : err3));
err = re_node_set_init_copy (&union_set,
&mctx->state_log[to_idx]->nodes);
ok = re_node_set_insert (&union_set, next_node);
- if (BE (err != REG_NOERROR || ! ok, 0))
+ if (__glibc_unlikely (err != REG_NOERROR || ! ok))
{
re_node_set_free (&union_set);
err = err != REG_NOERROR ? err : REG_ESPACE;
else
{
err = re_node_set_init_1 (&union_set, next_node);
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
return err;
}
mctx->state_log[to_idx] = re_acquire_state (&err, dfa, &union_set);
re_node_set_free (&union_set);
- if (BE (mctx->state_log[to_idx] == NULL
- && err != REG_NOERROR, 0))
+ if (__glibc_unlikely (mctx->state_log[to_idx] == NULL
+ && err != REG_NOERROR))
return err;
}
}
else
{
dests_alloc = re_malloc (struct dests_alloc, 1);
- if (BE (dests_alloc == NULL, 0))
+ if (__glibc_unlikely (dests_alloc == NULL))
return false;
dests_node_malloced = true;
}
/* At first, group all nodes belonging to 'state' into several
destinations. */
ndests = group_nodes_into_DFAstates (dfa, state, dests_node, dests_ch);
- if (BE (ndests <= 0, 0))
+ if (__glibc_unlikely (ndests <= 0))
{
if (dests_node_malloced)
re_free (dests_alloc);
{
state->trtable = (re_dfastate_t **)
calloc (sizeof (re_dfastate_t *), SBC_MAX);
- if (BE (state->trtable == NULL, 0))
+ if (__glibc_unlikely (state->trtable == NULL))
return false;
return true;
}
}
err = re_node_set_alloc (&follows, ndests + 1);
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
goto out_free;
/* Avoid arithmetic overflow in size calculation. */
- if (BE ((((SIZE_MAX - (sizeof (re_node_set) + sizeof (bitset_t)) * SBC_MAX)
- / (3 * sizeof (re_dfastate_t *)))
- < ndests),
- 0))
+ size_t ndests_max
+ = ((SIZE_MAX - (sizeof (re_node_set) + sizeof (bitset_t)) * SBC_MAX)
+ / (3 * sizeof (re_dfastate_t *)));
+ if (__glibc_unlikely (ndests_max < ndests))
goto out_free;
if (__libc_use_alloca ((sizeof (re_node_set) + sizeof (bitset_t)) * SBC_MAX
else
{
dest_states = re_malloc (re_dfastate_t *, ndests * 3);
- if (BE (dest_states == NULL, 0))
+ if (__glibc_unlikely (dest_states == NULL))
{
out_free:
if (dest_states_malloced)
if (next_node != -1)
{
err = re_node_set_merge (&follows, dfa->eclosures + next_node);
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
goto out_free;
}
}
dest_states[i] = re_acquire_state_context (&err, dfa, &follows, 0);
- if (BE (dest_states[i] == NULL && err != REG_NOERROR, 0))
+ if (__glibc_unlikely (dest_states[i] == NULL && err != REG_NOERROR))
goto out_free;
/* If the new state has context constraint,
build appropriate states for these contexts. */
{
dest_states_word[i] = re_acquire_state_context (&err, dfa, &follows,
CONTEXT_WORD);
- if (BE (dest_states_word[i] == NULL && err != REG_NOERROR, 0))
+ if (__glibc_unlikely (dest_states_word[i] == NULL
+ && err != REG_NOERROR))
goto out_free;
if (dest_states[i] != dest_states_word[i] && dfa->mb_cur_max > 1)
dest_states_nl[i] = re_acquire_state_context (&err, dfa, &follows,
CONTEXT_NEWLINE);
- if (BE (dest_states_nl[i] == NULL && err != REG_NOERROR, 0))
+ if (__glibc_unlikely (dest_states_nl[i] == NULL && err != REG_NOERROR))
goto out_free;
}
else
bitset_merge (acceptable, dests_ch[i]);
}
- if (!BE (need_word_trtable, 0))
+ if (!__glibc_unlikely (need_word_trtable))
{
/* We don't care about whether the following character is a word
character, or we are in a single-byte character set so we can
256-entry transition table. */
trtable = state->trtable =
(re_dfastate_t **) calloc (sizeof (re_dfastate_t *), SBC_MAX);
- if (BE (trtable == NULL, 0))
+ if (__glibc_unlikely (trtable == NULL))
goto out_free;
/* For all characters ch...: */
for (ch = i * BITSET_WORD_BITS, elem = acceptable[i], mask = 1;
elem;
mask <<= 1, elem >>= 1, ++ch)
- if (BE (elem & 1, 0))
+ if (__glibc_unlikely (elem & 1))
{
/* There must be exactly one destination which accepts
character ch. See group_nodes_into_DFAstates. */
starting at trtable[SBC_MAX]. */
trtable = state->word_trtable =
(re_dfastate_t **) calloc (sizeof (re_dfastate_t *), 2 * SBC_MAX);
- if (BE (trtable == NULL, 0))
+ if (__glibc_unlikely (trtable == NULL))
goto out_free;
/* For all characters ch...: */
for (ch = i * BITSET_WORD_BITS, elem = acceptable[i], mask = 1;
elem;
mask <<= 1, elem >>= 1, ++ch)
- if (BE (elem & 1, 0))
+ if (__glibc_unlikely (elem & 1))
{
/* There must be exactly one destination which accepts
character ch. See group_nodes_into_DFAstates. */
bitset_copy (dests_ch[ndests], remains);
bitset_copy (dests_ch[j], intersec);
err = re_node_set_init_copy (dests_node + ndests, &dests_node[j]);
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
goto error_return;
++ndests;
}
/* Put the position in the current group. */
ok = re_node_set_insert (&dests_node[j], cur_nodes->elems[i]);
- if (BE (! ok, 0))
+ if (__glibc_unlikely (! ok))
goto error_return;
/* If all characters are consumed, go to next node. */
{
bitset_copy (dests_ch[ndests], accepts);
err = re_node_set_init_1 (dests_node + ndests, cur_nodes->elems[i]);
- if (BE (err != REG_NOERROR, 0))
+ if (__glibc_unlikely (err != REG_NOERROR))
goto error_return;
++ndests;
bitset_empty (accepts);
int char_len, elem_len;
Idx i;
- if (BE (node->type == OP_UTF8_PERIOD, 0))
+ if (__glibc_unlikely (node->type == OP_UTF8_PERIOD))
{
unsigned char c = re_string_byte_at (input, str_idx), d;
- if (BE (c < 0xc2, 1))
+ if (__glibc_likely (c < 0xc2))
return 0;
if (str_idx + 2 > input->len)
re_string_t *pstr = &mctx->input;
/* Avoid overflow. */
- if (BE (MIN (IDX_MAX, SIZE_MAX / sizeof (re_dfastate_t *)) / 2
- <= pstr->bufs_len, 0))
+ if (__glibc_unlikely (MIN (IDX_MAX, SIZE_MAX / sizeof (re_dfastate_t *)) / 2
+ <= pstr->bufs_len))
return REG_ESPACE;
/* Double the lengths of the buffers, but allocate at least MIN_LEN. */
ret = re_string_realloc_buffers (pstr,
MAX (min_len,
MIN (pstr->len, pstr->bufs_len * 2)));
- if (BE (ret != REG_NOERROR, 0))
+ if (__glibc_unlikely (ret != REG_NOERROR))
return ret;
if (mctx->state_log != NULL)
does not have the right size. */
re_dfastate_t **new_array = re_realloc (mctx->state_log, re_dfastate_t *,
pstr->bufs_len + 1);
- if (BE (new_array == NULL, 0))
+ if (__glibc_unlikely (new_array == NULL))
return REG_ESPACE;
mctx->state_log = new_array;
}
if (pstr->mb_cur_max > 1)
{
ret = build_wcs_upper_buffer (pstr);
- if (BE (ret != REG_NOERROR, 0))
+ if (__glibc_unlikely (ret != REG_NOERROR))
return ret;
}
else
size_t max_object_size =
MAX (sizeof (struct re_backref_cache_entry),
sizeof (re_sub_match_top_t *));
- if (BE (MIN (IDX_MAX, SIZE_MAX / max_object_size) < n, 0))
+ if (__glibc_unlikely (MIN (IDX_MAX, SIZE_MAX / max_object_size) < n))
return REG_ESPACE;
mctx->bkref_ents = re_malloc (struct re_backref_cache_entry, n);
mctx->sub_tops = re_malloc (re_sub_match_top_t *, n);
- if (BE (mctx->bkref_ents == NULL || mctx->sub_tops == NULL, 0))
+ if (__glibc_unlikely (mctx->bkref_ents == NULL || mctx->sub_tops == NULL))
return REG_ESPACE;
}
/* Already zero-ed by the caller.
struct re_backref_cache_entry* new_entry;
new_entry = re_realloc (mctx->bkref_ents, struct re_backref_cache_entry,
mctx->abkref_ents * 2);
- if (BE (new_entry == NULL, 0))
+ if (__glibc_unlikely (new_entry == NULL))
{
re_free (mctx->bkref_ents);
return REG_ESPACE;
assert (mctx->sub_tops != NULL);
assert (mctx->asub_tops > 0);
#endif
- if (BE (mctx->nsub_tops == mctx->asub_tops, 0))
+ if (__glibc_unlikely (mctx->nsub_tops == mctx->asub_tops))
{
Idx new_asub_tops = mctx->asub_tops * 2;
re_sub_match_top_t **new_array = re_realloc (mctx->sub_tops,
re_sub_match_top_t *,
new_asub_tops);
- if (BE (new_array == NULL, 0))
+ if (__glibc_unlikely (new_array == NULL))
return REG_ESPACE;
mctx->sub_tops = new_array;
mctx->asub_tops = new_asub_tops;
}
mctx->sub_tops[mctx->nsub_tops] = calloc (1, sizeof (re_sub_match_top_t));
- if (BE (mctx->sub_tops[mctx->nsub_tops] == NULL, 0))
+ if (__glibc_unlikely (mctx->sub_tops[mctx->nsub_tops] == NULL))
return REG_ESPACE;
mctx->sub_tops[mctx->nsub_tops]->node = node;
mctx->sub_tops[mctx->nsub_tops++]->str_idx = str_idx;
match_ctx_add_sublast (re_sub_match_top_t *subtop, Idx node, Idx str_idx)
{
re_sub_match_last_t *new_entry;
- if (BE (subtop->nlasts == subtop->alasts, 0))
+ if (__glibc_unlikely (subtop->nlasts == subtop->alasts))
{
Idx new_alasts = 2 * subtop->alasts + 1;
re_sub_match_last_t **new_array = re_realloc (subtop->lasts,
re_sub_match_last_t *,
new_alasts);
- if (BE (new_array == NULL, 0))
+ if (__glibc_unlikely (new_array == NULL))
return NULL;
subtop->lasts = new_array;
subtop->alasts = new_alasts;
}
new_entry = calloc (1, sizeof (re_sub_match_last_t));
- if (BE (new_entry != NULL, 1))
+ if (__glibc_likely (new_entry != NULL))
{
subtop->lasts[subtop->nlasts] = new_entry;
new_entry->node = node;
--- /dev/null
+# Test for __inline keyword
+dnl Copyright 2017-2018 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl___INLINE],
+[
+ AC_CACHE_CHECK([whether the compiler supports the __inline keyword],
+ [gl_cv_c___inline],
+ [AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM(
+ [[typedef int foo_t;
+ static __inline foo_t foo (void) { return 0; }]],
+ [[return foo ();]])],
+ [gl_cv_c___inline=yes],
+ [gl_cv_c___inline=no])])
+ if test $gl_cv_c___inline = yes; then
+ AC_DEFINE([HAVE___INLINE], [1],
+ [Define to 1 if the compiler supports the keyword '__inline'.])
+ fi
+])
# Code from module inttypes-incomplete:
# Code from module largefile:
AC_REQUIRE([AC_SYS_LARGEFILE])
+ # Code from module libc-config:
# Code from module limits-h:
# Code from module localtime-buffer:
# Code from module lstat:
gl_gnulib_enabled_getgroups=false
gl_gnulib_enabled_be453cec5eecf5731a274f2de7f2db36=false
gl_gnulib_enabled_a9786850e999ae65a836a6041e8e5ed1=false
+ gl_gnulib_enabled_21ee726a3540c09237a8e70c0baf7467=false
gl_gnulib_enabled_2049e887c7e5308faad27b3f894bb8c9=false
gl_gnulib_enabled_5264294aa0a5557541b53c8c741f7f31=false
gl_gnulib_enabled_open=false
fi
fi
}
+ func_gl_gnulib_m4code_21ee726a3540c09237a8e70c0baf7467 ()
+ {
+ if ! $gl_gnulib_enabled_21ee726a3540c09237a8e70c0baf7467; then
+ gl___INLINE
+ gl_gnulib_enabled_21ee726a3540c09237a8e70c0baf7467=true
+ fi
+ }
func_gl_gnulib_m4code_2049e887c7e5308faad27b3f894bb8c9 ()
{
if ! $gl_gnulib_enabled_2049e887c7e5308faad27b3f894bb8c9; then
if test $ac_use_included_regex = yes; then
func_gl_gnulib_m4code_37f71b604aa9c54446783d80f42fe547
fi
+ if test $ac_use_included_regex = yes; then
+ func_gl_gnulib_m4code_21ee726a3540c09237a8e70c0baf7467
+ fi
if { test $HAVE_DECL_STRTOIMAX = 0 || test $REPLACE_STRTOIMAX = 1; } && test $ac_cv_type_long_long_int = yes; then
func_gl_gnulib_m4code_strtoll
fi
AM_CONDITIONAL([gl_GNULIB_ENABLED_getgroups], [$gl_gnulib_enabled_getgroups])
AM_CONDITIONAL([gl_GNULIB_ENABLED_be453cec5eecf5731a274f2de7f2db36], [$gl_gnulib_enabled_be453cec5eecf5731a274f2de7f2db36])
AM_CONDITIONAL([gl_GNULIB_ENABLED_a9786850e999ae65a836a6041e8e5ed1], [$gl_gnulib_enabled_a9786850e999ae65a836a6041e8e5ed1])
+ AM_CONDITIONAL([gl_GNULIB_ENABLED_21ee726a3540c09237a8e70c0baf7467], [$gl_gnulib_enabled_21ee726a3540c09237a8e70c0baf7467])
AM_CONDITIONAL([gl_GNULIB_ENABLED_2049e887c7e5308faad27b3f894bb8c9], [$gl_gnulib_enabled_2049e887c7e5308faad27b3f894bb8c9])
AM_CONDITIONAL([gl_GNULIB_ENABLED_5264294aa0a5557541b53c8c741f7f31], [$gl_gnulib_enabled_5264294aa0a5557541b53c8c741f7f31])
AM_CONDITIONAL([gl_GNULIB_ENABLED_open], [$gl_gnulib_enabled_open])
lib/c-strncasecmp.c
lib/careadlinkat.c
lib/careadlinkat.h
+ lib/cdefs.h
lib/cloexec.c
lib/cloexec.h
lib/close-stream.c
lib/ignore-value.h
lib/intprops.h
lib/inttypes.in.h
+ lib/libc-config.h
lib/limits.in.h
lib/localtime-buffer.c
lib/localtime-buffer.h
lib/warn-on-use.h
lib/xalloc-oversized.h
m4/00gnulib.m4
+ m4/__inline.m4
m4/absolute-header.m4
m4/acl.m4
m4/alloca.m4