diff options
| author | Michal Nazarewicz | 2016-07-27 22:39:04 +0200 |
|---|---|---|
| committer | Michal Nazarewicz | 2016-08-02 15:39:10 +0200 |
| commit | 04d96eca08ff797c0cd93c33fe8589f4623fc449 (patch) | |
| tree | adc46050fff677705e5be6400502495e3943dd1f /src/regex.h | |
| parent | 9a418e0f98a6ee14d9984e597038168ebe0a7a03 (diff) | |
| download | emacs-04d96eca08ff797c0cd93c33fe8589f4623fc449.tar.gz emacs-04d96eca08ff797c0cd93c33fe8589f4623fc449.zip | |
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 @@ | |||
| 20 | #ifndef _REGEX_H | 20 | #ifndef _REGEX_H |
| 21 | #define _REGEX_H 1 | 21 | #define _REGEX_H 1 |
| 22 | 22 | ||
| 23 | #if defined emacs && (defined _REGEX_RE_COMP || defined _LIBC) | ||
| 24 | /* We’re not defining re_set_syntax and using a different prototype of | ||
| 25 | re_compile_pattern when building Emacs so fail compilation early with | ||
| 26 | a (somewhat helpful) error message when conflict is detected. */ | ||
| 27 | # error "_REGEX_RE_COMP nor _LIBC can be defined if emacs is defined." | ||
| 28 | #endif | ||
| 29 | |||
| 23 | /* Allow the use in C++ code. */ | 30 | /* Allow the use in C++ code. */ |
| 24 | #ifdef __cplusplus | 31 | #ifdef __cplusplus |
| 25 | extern "C" { | 32 | extern "C" { |
| @@ -453,14 +460,21 @@ typedef struct | |||
| 453 | 460 | ||
| 454 | /* Declarations for routines. */ | 461 | /* Declarations for routines. */ |
| 455 | 462 | ||
| 463 | #ifndef emacs | ||
| 464 | |||
| 456 | /* Sets the current default syntax to SYNTAX, and return the old syntax. | 465 | /* Sets the current default syntax to SYNTAX, and return the old syntax. |
| 457 | You can also simply assign to the `re_syntax_options' variable. */ | 466 | You can also simply assign to the `re_syntax_options' variable. */ |
| 458 | extern reg_syntax_t re_set_syntax (reg_syntax_t __syntax); | 467 | extern reg_syntax_t re_set_syntax (reg_syntax_t __syntax); |
| 459 | 468 | ||
| 469 | #endif | ||
| 470 | |||
| 460 | /* Compile the regular expression PATTERN, with length LENGTH | 471 | /* Compile the regular expression PATTERN, with length LENGTH |
| 461 | and syntax given by the global `re_syntax_options', into the buffer | 472 | and syntax given by the global `re_syntax_options', into the buffer |
| 462 | BUFFER. Return NULL if successful, and an error string if not. */ | 473 | BUFFER. Return NULL if successful, and an error string if not. */ |
| 463 | extern const char *re_compile_pattern (const char *__pattern, size_t __length, | 474 | extern const char *re_compile_pattern (const char *__pattern, size_t __length, |
| 475 | #ifdef emacs | ||
| 476 | reg_syntax_t syntax, | ||
| 477 | #endif | ||
| 464 | struct re_pattern_buffer *__buffer); | 478 | struct re_pattern_buffer *__buffer); |
| 465 | 479 | ||
| 466 | 480 | ||