diff options
author | Michal Nazarewicz <mina86@mina86.com> | 2016-07-27 22:39:04 +0200 |
---|---|---|
committer | Michal Nazarewicz <mina86@mina86.com> | 2016-08-02 15:39:10 +0200 |
commit | 04d96eca08ff797c0cd93c33fe8589f4623fc449 (patch) | |
tree | adc46050fff677705e5be6400502495e3943dd1f /src/regex.h | |
parent | 9a418e0f98a6ee14d9984e597038168ebe0a7a03 (diff) | |
download | emacs-04d96eca08ff797c0cd93c33fe8589f4623fc449.tar.gz |
Get rid of re_set_syntax
Instead of using a global variable for storing regex syntax, pass it
to re_compile_pattern. This is only enabled when compiling Emacs (i.e.
‘#ifdef emacs’).
* src/regex.h (re_set_syntax): Declare only #ifndef emacs.
(re_compile_pattern): Now takes syntax argument #ifdef emacs.
* src/regex.c (re_syntax_options): Define only #ifndef emacs.
(re_compile_pattern): Use the new syntax argument #ifdef emacs.
* src/search.c (compile_pattern_1): Don’t use re_set_syntax and
instead pass syntax to re_compile_pattern directly.
Diffstat (limited to 'src/regex.h')
-rw-r--r-- | src/regex.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/regex.h b/src/regex.h index 01b659addbb..4497333500a 100644 --- a/src/regex.h +++ b/src/regex.h @@ -20,6 +20,13 @@ #ifndef _REGEX_H #define _REGEX_H 1 +#if defined emacs && (defined _REGEX_RE_COMP || defined _LIBC) +/* We’re not defining re_set_syntax and using a different prototype of + re_compile_pattern when building Emacs so fail compilation early with + a (somewhat helpful) error message when conflict is detected. */ +# error "_REGEX_RE_COMP nor _LIBC can be defined if emacs is defined." +#endif + /* Allow the use in C++ code. */ #ifdef __cplusplus extern "C" { @@ -453,14 +460,21 @@ typedef struct /* Declarations for routines. */ +#ifndef emacs + /* Sets the current default syntax to SYNTAX, and return the old syntax. You can also simply assign to the `re_syntax_options' variable. */ extern reg_syntax_t re_set_syntax (reg_syntax_t __syntax); +#endif + /* Compile the regular expression PATTERN, with length LENGTH and syntax given by the global `re_syntax_options', into the buffer BUFFER. Return NULL if successful, and an error string if not. */ extern const char *re_compile_pattern (const char *__pattern, size_t __length, +#ifdef emacs + reg_syntax_t syntax, +#endif struct re_pattern_buffer *__buffer); |