1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-21 06:55:39 +00:00

Update lib/regex from glibc via Gnulib

This syncs recent refactorings from glibc, and incorporates:
2018-10-15 libc-config: merge from glibc
2018-10-15 regex: depend on libc-config
* .gitignore: Do not ignore m4/_*.m4.
* lib/cdefs.h: New file, copied from Gnulib.
* lib/gnulib.mk.in, m4/gnulib-comp.m4: Regenerate.
* lib/libc-config.h, m4/__inline.m4: New files, copied from Gnulib.
* lib/regcomp.c, lib/regex.c, lib/regex_internal.c:
* lib/regex_internal.h, lib/regexec.c:
Copy from glibc via Gnulib.
This commit is contained in:
Paul Eggert 2018-10-15 00:55:37 -05:00
parent 6b8fd34c4a
commit 3d91dc1bb5
11 changed files with 1163 additions and 418 deletions

1
.gitignore vendored
View File

@ -264,6 +264,7 @@ etc/emacs.tmpdesktop
*.in-h
_*
!lib/_Noreturn.h
!m4/_*.m4
/bin/
/BIN/
/data/

514
lib/cdefs.h Normal file
View File

@ -0,0 +1,514 @@
/* 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 */

View File

@ -1040,6 +1040,7 @@ gamegroup = @gamegroup@
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@
@ -1900,6 +1901,17 @@ EXTRA_DIST += inttypes.in.h
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))

174
lib/libc-config.h Normal file
View File

@ -0,0 +1,174 @@
/* 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)

File diff suppressed because it is too large Load Diff

View File

@ -18,7 +18,7 @@
<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"

View File

@ -59,7 +59,7 @@ re_string_allocate (re_string_t *pstr, const char *str, Idx len, Idx init_len,
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;
@ -84,7 +84,7 @@ re_string_construct (re_string_t *pstr, const char *str, Idx len,
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;
@ -97,14 +97,14 @@ re_string_construct (re_string_t *pstr, const char *str, Idx len,
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;
}
}
@ -146,17 +146,18 @@ re_string_realloc_buffers (re_string_t *pstr, Idx new_buf_len)
/* 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;
}
@ -166,7 +167,7 @@ re_string_realloc_buffers (re_string_t *pstr, Idx new_buf_len)
{
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;
}
@ -230,7 +231,7 @@ build_wcs_buffer (re_string_t *pstr)
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;
@ -244,17 +245,18 @@ build_wcs_buffer (re_string_t *pstr)
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;
@ -317,7 +319,7 @@ build_wcs_upper_buffer (re_string_t *pstr)
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)
@ -325,7 +327,7 @@ build_wcs_upper_buffer (re_string_t *pstr)
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
{
@ -350,7 +352,7 @@ build_wcs_upper_buffer (re_string_t *pstr)
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
@ -372,7 +374,7 @@ build_wcs_upper_buffer (re_string_t *pstr)
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;
@ -386,7 +388,7 @@ build_wcs_upper_buffer (re_string_t *pstr)
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)
@ -394,7 +396,7 @@ build_wcs_upper_buffer (re_string_t *pstr)
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)
{
@ -444,7 +446,7 @@ build_wcs_upper_buffer (re_string_t *pstr)
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)
@ -463,17 +465,17 @@ build_wcs_upper_buffer (re_string_t *pstr)
/* 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
@ -508,7 +510,8 @@ re_string_skip_chars (re_string_t *pstr, Idx new_raw_idx, wint_t *last_wc)
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)
@ -540,7 +543,7 @@ build_upper_buffer (re_string_t *pstr)
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);
}
@ -576,7 +579,7 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
{
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
{
@ -598,14 +601,14 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
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
@ -677,7 +680,7 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
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;
@ -693,7 +696,7 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
/* 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;
@ -721,7 +724,7 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
#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; */
@ -739,7 +742,7 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
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)
@ -769,13 +772,13 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
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;
@ -797,7 +800,7 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
? CONTEXT_NEWLINE : 0));
}
}
if (!BE (pstr->mbs_allocated, 0))
if (!__glibc_unlikely (pstr->mbs_allocated))
pstr->mbs += offset;
}
pstr->raw_mbs_idx = idx;
@ -811,7 +814,7 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
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
@ -819,7 +822,7 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
}
else
#endif /* RE_ENABLE_I18N */
if (BE (pstr->mbs_allocated, 0))
if (__glibc_unlikely (pstr->mbs_allocated))
{
if (pstr->icase)
build_upper_buffer (pstr);
@ -841,7 +844,7 @@ re_string_peek_byte_case (const re_string_t *pstr, Idx idx)
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
@ -873,7 +876,7 @@ re_string_peek_byte_case (const re_string_t *pstr, Idx idx)
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
@ -924,11 +927,11 @@ static unsigned int
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
@ -947,7 +950,8 @@ re_string_context_at (const re_string_t *input, Idx idx, int eflags)
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);
@ -971,7 +975,8 @@ re_node_set_alloc (re_node_set *set, Idx size)
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;
}
@ -983,7 +988,7 @@ re_node_set_init_1 (re_node_set *set, Idx elem)
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;
@ -998,7 +1003,7 @@ re_node_set_init_2 (re_node_set *set, Idx elem1, Idx elem2)
{
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)
{
@ -1031,7 +1036,7 @@ re_node_set_init_copy (re_node_set *dest, const re_node_set *src)
{
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;
@ -1062,7 +1067,7 @@ re_node_set_add_intersect (re_node_set *dest, const re_node_set *src1,
{
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;
@ -1148,7 +1153,7 @@ re_node_set_init_union (re_node_set *dest, const re_node_set *src1,
{
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
@ -1202,13 +1207,13 @@ re_node_set_merge (re_node_set *dest, const re_node_set *src)
{
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));
@ -1281,9 +1286,9 @@ re_node_set_insert (re_node_set *set, Idx elem)
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;
@ -1297,7 +1302,7 @@ re_node_set_insert (re_node_set *set, Idx 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;
}
@ -1336,7 +1341,7 @@ re_node_set_insert_last (re_node_set *set, Idx elem)
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;
}
@ -1403,7 +1408,7 @@ re_node_set_remove_at (re_node_set *set, Idx idx)
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;
@ -1414,19 +1419,20 @@ re_dfa_add_node (re_dfa_t *dfa, re_token_t token)
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);
@ -1485,7 +1491,7 @@ re_acquire_state (reg_errcode_t *err, const re_dfa_t *dfa,
/* 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;
@ -1504,7 +1510,7 @@ re_acquire_state (reg_errcode_t *err, const re_dfa_t *dfa,
/* 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;
@ -1551,7 +1557,7 @@ re_acquire_state_context (reg_errcode_t *err, const re_dfa_t *dfa,
}
/* 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;
@ -1572,7 +1578,7 @@ register_state (const re_dfa_t *dfa, re_dfastate_t *newstate,
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++)
{
@ -1583,12 +1589,12 @@ register_state (const re_dfa_t *dfa, re_dfastate_t *newstate,
}
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;
@ -1626,10 +1632,10 @@ create_ci_newstate (const re_dfa_t *dfa, const re_node_set *nodes,
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;
@ -1655,7 +1661,7 @@ create_ci_newstate (const re_dfa_t *dfa, const re_node_set *nodes,
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;
@ -1676,10 +1682,10 @@ create_cd_newstate (const re_dfa_t *dfa, const re_node_set *nodes,
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;
@ -1711,7 +1717,7 @@ create_cd_newstate (const re_dfa_t *dfa, const re_node_set *nodes,
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;
@ -1731,7 +1737,7 @@ create_cd_newstate (const re_dfa_t *dfa, const re_node_set *nodes,
}
}
err = register_state (dfa, newstate, hash);
if (BE (err != REG_NOERROR, 0))
if (__glibc_unlikely (err != REG_NOERROR))
{
free_state (newstate);
newstate = NULL;

View File

@ -33,23 +33,7 @@
#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>
@ -132,8 +116,6 @@
# define RE_ENABLE_I18N
#endif
#define BE(expr, val) __builtin_expect (expr, val)
/* Number of ASCII characters. */
#define ASCII_CHARS 0x80

File diff suppressed because it is too large Load Diff

22
m4/__inline.m4 Normal file
View File

@ -0,0 +1,22 @@
# 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
])

View File

@ -109,6 +109,7 @@ AC_DEFUN([gl_EARLY],
# 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:
@ -441,6 +442,7 @@ AC_DEFUN([gl_INIT],
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
@ -554,6 +556,13 @@ AC_DEFUN([gl_INIT],
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
@ -669,6 +678,9 @@ AC_DEFUN([gl_INIT],
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
@ -686,6 +698,7 @@ AC_DEFUN([gl_INIT],
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])
@ -858,6 +871,7 @@ AC_DEFUN([gl_FILE_LIST], [
lib/c-strncasecmp.c
lib/careadlinkat.c
lib/careadlinkat.h
lib/cdefs.h
lib/cloexec.c
lib/cloexec.h
lib/close-stream.c
@ -920,6 +934,7 @@ AC_DEFUN([gl_FILE_LIST], [
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
@ -1002,6 +1017,7 @@ AC_DEFUN([gl_FILE_LIST], [
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