mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-30 22:43:12 +03:00
regex: simplify Gnulib port
This simplifies the code, by removing stuff intended for porting to Gnulib but no longer needed there. * posix/regcomp.c [!_LIBC]: No need to put #ifdef _LIBC around uses of libc_hidden_def, weak_alias. * posix/regcomp.c, posix/regexec.c: Use __restrict rather than _Restrict_ except for public-facing headers. * posix/regex_internal.h (attribute_hidden) [!_LIBC]: Remove; already defined elsewhere. * posix/regex.c, posix/regex_internal.h: Use __GNUC_PREREQ instead of rolling our own. * posix/regex_internal.h (__GNUC_PREREQ): Remove duplicate defn.
This commit is contained in:
15
ChangeLog
15
ChangeLog
@ -1,3 +1,18 @@
|
|||||||
|
2018-12-27 Paul Eggert <eggert@cs.ucla.edu>
|
||||||
|
|
||||||
|
regex: simplify Gnulib port
|
||||||
|
This simplifies the code, by removing stuff intended for porting
|
||||||
|
to Gnulib but no longer needed there.
|
||||||
|
* posix/regcomp.c [!_LIBC]: No need to put #ifdef _LIBC around
|
||||||
|
uses of libc_hidden_def, weak_alias.
|
||||||
|
* posix/regcomp.c, posix/regexec.c: Use __restrict rather than
|
||||||
|
_Restrict_ except for public-facing headers.
|
||||||
|
* posix/regex_internal.h (attribute_hidden) [!_LIBC]:
|
||||||
|
Remove; already defined elsewhere.
|
||||||
|
* posix/regex.c, posix/regex_internal.h:
|
||||||
|
Use __GNUC_PREREQ instead of rolling our own.
|
||||||
|
* posix/regex_internal.h (__GNUC_PREREQ): Remove duplicate defn.
|
||||||
|
|
||||||
2018-12-27 Wilco Dijkstra <wdijkstr@arm.com>
|
2018-12-27 Wilco Dijkstra <wdijkstr@arm.com>
|
||||||
|
|
||||||
* benchtests/bench-strlen.c (generic_strlen): New function.
|
* benchtests/bench-strlen.c (generic_strlen): New function.
|
||||||
|
@ -233,9 +233,7 @@ re_compile_pattern (const char *pattern, size_t length,
|
|||||||
return NULL;
|
return NULL;
|
||||||
return gettext (__re_error_msgid + __re_error_msgid_idx[(int) ret]);
|
return gettext (__re_error_msgid + __re_error_msgid_idx[(int) ret]);
|
||||||
}
|
}
|
||||||
#ifdef _LIBC
|
|
||||||
weak_alias (__re_compile_pattern, re_compile_pattern)
|
weak_alias (__re_compile_pattern, re_compile_pattern)
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Set by 're_set_syntax' to the current regexp syntax to recognize. Can
|
/* Set by 're_set_syntax' to the current regexp syntax to recognize. Can
|
||||||
also be assigned to arbitrarily: each pattern buffer stores its own
|
also be assigned to arbitrarily: each pattern buffer stores its own
|
||||||
@ -260,9 +258,7 @@ re_set_syntax (reg_syntax_t syntax)
|
|||||||
re_syntax_options = syntax;
|
re_syntax_options = syntax;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#ifdef _LIBC
|
|
||||||
weak_alias (__re_set_syntax, re_set_syntax)
|
weak_alias (__re_set_syntax, re_set_syntax)
|
||||||
#endif
|
|
||||||
|
|
||||||
int
|
int
|
||||||
re_compile_fastmap (struct re_pattern_buffer *bufp)
|
re_compile_fastmap (struct re_pattern_buffer *bufp)
|
||||||
@ -281,9 +277,7 @@ re_compile_fastmap (struct re_pattern_buffer *bufp)
|
|||||||
bufp->fastmap_accurate = 1;
|
bufp->fastmap_accurate = 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#ifdef _LIBC
|
|
||||||
weak_alias (__re_compile_fastmap, re_compile_fastmap)
|
weak_alias (__re_compile_fastmap, re_compile_fastmap)
|
||||||
#endif
|
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
__attribute__ ((always_inline))
|
__attribute__ ((always_inline))
|
||||||
@ -464,7 +458,7 @@ re_compile_fastmap_iter (regex_t *bufp, const re_dfastate_t *init_state,
|
|||||||
the return codes and their meanings.) */
|
the return codes and their meanings.) */
|
||||||
|
|
||||||
int
|
int
|
||||||
regcomp (regex_t *_Restrict_ preg, const char *_Restrict_ pattern, int cflags)
|
regcomp (regex_t *__restrict preg, const char *__restrict pattern, int cflags)
|
||||||
{
|
{
|
||||||
reg_errcode_t ret;
|
reg_errcode_t ret;
|
||||||
reg_syntax_t syntax = ((cflags & REG_EXTENDED) ? RE_SYNTAX_POSIX_EXTENDED
|
reg_syntax_t syntax = ((cflags & REG_EXTENDED) ? RE_SYNTAX_POSIX_EXTENDED
|
||||||
@ -515,16 +509,14 @@ regcomp (regex_t *_Restrict_ preg, const char *_Restrict_ pattern, int cflags)
|
|||||||
|
|
||||||
return (int) ret;
|
return (int) ret;
|
||||||
}
|
}
|
||||||
#ifdef _LIBC
|
|
||||||
libc_hidden_def (__regcomp)
|
libc_hidden_def (__regcomp)
|
||||||
weak_alias (__regcomp, regcomp)
|
weak_alias (__regcomp, regcomp)
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Returns a message corresponding to an error code, ERRCODE, returned
|
/* Returns a message corresponding to an error code, ERRCODE, returned
|
||||||
from either regcomp or regexec. We don't use PREG here. */
|
from either regcomp or regexec. We don't use PREG here. */
|
||||||
|
|
||||||
size_t
|
size_t
|
||||||
regerror (int errcode, const regex_t *_Restrict_ preg, char *_Restrict_ errbuf,
|
regerror (int errcode, const regex_t *__restrict preg, char *__restrict errbuf,
|
||||||
size_t errbuf_size)
|
size_t errbuf_size)
|
||||||
{
|
{
|
||||||
const char *msg;
|
const char *msg;
|
||||||
@ -555,9 +547,7 @@ regerror (int errcode, const regex_t *_Restrict_ preg, char *_Restrict_ errbuf,
|
|||||||
|
|
||||||
return msg_size;
|
return msg_size;
|
||||||
}
|
}
|
||||||
#ifdef _LIBC
|
|
||||||
weak_alias (__regerror, regerror)
|
weak_alias (__regerror, regerror)
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef RE_ENABLE_I18N
|
#ifdef RE_ENABLE_I18N
|
||||||
@ -657,10 +647,8 @@ regfree (regex_t *preg)
|
|||||||
re_free (preg->translate);
|
re_free (preg->translate);
|
||||||
preg->translate = NULL;
|
preg->translate = NULL;
|
||||||
}
|
}
|
||||||
#ifdef _LIBC
|
|
||||||
libc_hidden_def (__regfree)
|
libc_hidden_def (__regfree)
|
||||||
weak_alias (__regfree, regfree)
|
weak_alias (__regfree, regfree)
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Entry points compatible with 4.2 BSD regex library. We don't define
|
/* Entry points compatible with 4.2 BSD regex library. We don't define
|
||||||
them unless specifically requested. */
|
them unless specifically requested. */
|
||||||
|
@ -20,10 +20,10 @@
|
|||||||
#ifndef _LIBC
|
#ifndef _LIBC
|
||||||
# include <libc-config.h>
|
# include <libc-config.h>
|
||||||
|
|
||||||
# if (__GNUC__ == 4 && 6 <= __GNUC_MINOR__) || 4 < __GNUC__
|
# if __GNUC_PREREQ (4, 6)
|
||||||
# pragma GCC diagnostic ignored "-Wsuggest-attribute=pure"
|
# pragma GCC diagnostic ignored "-Wsuggest-attribute=pure"
|
||||||
# endif
|
# endif
|
||||||
# if (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) || 4 < __GNUC__
|
# if __GNUC_PREREQ (4, 3)
|
||||||
# pragma GCC diagnostic ignored "-Wold-style-definition"
|
# pragma GCC diagnostic ignored "-Wold-style-definition"
|
||||||
# pragma GCC diagnostic ignored "-Wtype-limits"
|
# pragma GCC diagnostic ignored "-Wtype-limits"
|
||||||
# endif
|
# endif
|
||||||
|
@ -144,10 +144,9 @@
|
|||||||
# define __mbrtowc mbrtowc
|
# define __mbrtowc mbrtowc
|
||||||
# define __wcrtomb wcrtomb
|
# define __wcrtomb wcrtomb
|
||||||
# define __regfree regfree
|
# define __regfree regfree
|
||||||
# define attribute_hidden
|
|
||||||
#endif /* not _LIBC */
|
#endif /* not _LIBC */
|
||||||
|
|
||||||
#if __GNUC__ < 3 + (__GNUC_MINOR__ < 1)
|
#if !__GNUC_PREREQ (3, 1)
|
||||||
# define __attribute__(arg)
|
# define __attribute__(arg)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -868,15 +867,6 @@ re_string_elem_size_at (const re_string_t *pstr, Idx idx)
|
|||||||
}
|
}
|
||||||
#endif /* RE_ENABLE_I18N */
|
#endif /* RE_ENABLE_I18N */
|
||||||
|
|
||||||
#ifndef __GNUC_PREREQ
|
|
||||||
# if defined __GNUC__ && defined __GNUC_MINOR__
|
|
||||||
# define __GNUC_PREREQ(maj, min) \
|
|
||||||
((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
|
|
||||||
# else
|
|
||||||
# define __GNUC_PREREQ(maj, min) 0
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if __GNUC_PREREQ (3,4)
|
#if __GNUC_PREREQ (3,4)
|
||||||
# undef __attribute_warn_unused_result__
|
# undef __attribute_warn_unused_result__
|
||||||
# define __attribute_warn_unused_result__ \
|
# define __attribute_warn_unused_result__ \
|
||||||
|
@ -189,7 +189,7 @@ static reg_errcode_t extend_buffers (re_match_context_t *mctx, int min_len);
|
|||||||
We return 0 if we find a match and REG_NOMATCH if not. */
|
We return 0 if we find a match and REG_NOMATCH if not. */
|
||||||
|
|
||||||
int
|
int
|
||||||
regexec (const regex_t *_Restrict_ preg, const char *_Restrict_ string,
|
regexec (const regex_t *__restrict preg, const char *__restrict string,
|
||||||
size_t nmatch, regmatch_t pmatch[], int eflags)
|
size_t nmatch, regmatch_t pmatch[], int eflags)
|
||||||
{
|
{
|
||||||
reg_errcode_t err;
|
reg_errcode_t err;
|
||||||
@ -232,8 +232,8 @@ __typeof__ (__regexec) __compat_regexec;
|
|||||||
|
|
||||||
int
|
int
|
||||||
attribute_compat_text_section
|
attribute_compat_text_section
|
||||||
__compat_regexec (const regex_t *_Restrict_ preg,
|
__compat_regexec (const regex_t *__restrict preg,
|
||||||
const char *_Restrict_ string, size_t nmatch,
|
const char *__restrict string, size_t nmatch,
|
||||||
regmatch_t pmatch[], int eflags)
|
regmatch_t pmatch[], int eflags)
|
||||||
{
|
{
|
||||||
return regexec (preg, string, nmatch, pmatch,
|
return regexec (preg, string, nmatch, pmatch,
|
||||||
|
Reference in New Issue
Block a user