summaryrefslogtreecommitdiff
path: root/src/regex.h
diff options
context:
space:
mode:
authorMichal Nazarewicz <mina86@mina86.com>2016-07-27 23:13:11 +0200
committerMichal Nazarewicz <mina86@mina86.com>2016-08-02 15:39:10 +0200
commit54a3c0c98f844ef6b21b011884132d5fe5ae5e1f (patch)
treef0d9813b80d65482c52ab021b2e821a539fc78cd /src/regex.h
parentda9c55ddbbd08fc07ab36dc8bdc740e352eeab2c (diff)
downloademacs-54a3c0c98f844ef6b21b011884132d5fe5ae5e1f.tar.gz
Hardcode regex syntax to remove dead code handling different syntax
Emacs only ever uses its own regex syntax so support for other syntaxes is never used. Hardcode the syntax so that the compilar can detect such dead code and remove it from compiled code. The only exception is RE_NO_POSIX_BACKTRACKING which can be separatelly specified. Handle this separatelly with a function argument (replacing now unnecessary syntax argument). With this patchset, size of Emacs binary on x86_64 machine is reduced by around 60 kB: new-sizes:-rwx------ 3 mpn eng 30254720 Jul 27 23:31 src/emacs old-sizes:-rwx------ 3 mpn eng 30314828 Jul 27 23:29 src/emacs * src/regex.h (re_pattern_buffer): Don’t define syntax field #ifdef emacs. (re_compile_pattern): Replace syntax with posix_backtracking argument. * src/regex.c (print_compiled_pattern): Don’t print syntax #ifdef emacs. (regex_compile): #ifdef emacs, replace syntax argument with posix_backtracking which is now used instead of testing for RE_NO_POSIX_BACKTRACKING syntax. (re_match_2_internal): Don’t access bufp->syntax #ifndef emacs. (re_compile_pattern): Replace syntax with posix_backtracking argument. * src/search.c (compile_pattern_1): Pass boolean posix_backtracking instead of syntax to re_compile_pattern.
Diffstat (limited to 'src/regex.h')
-rw-r--r--src/regex.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/regex.h b/src/regex.h
index af9480d583c..b672d3fdef7 100644
--- a/src/regex.h
+++ b/src/regex.h
@@ -354,9 +354,10 @@ struct re_pattern_buffer
/* Number of bytes actually used in `buffer'. */
size_t used;
+#ifndef emacs
/* Syntax setting with which the pattern was compiled. */
reg_syntax_t syntax;
-
+#endif
/* Pointer to a fastmap, if any, otherwise zero. re_search uses
the fastmap, if there is one, to skip over impossible
starting points for matches. */
@@ -473,7 +474,7 @@ extern reg_syntax_t re_set_syntax (reg_syntax_t __syntax);
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,
+ bool posix_backtracking,
const char *whitespace_regexp,
#endif
struct re_pattern_buffer *__buffer);