diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2016-11-29 20:06:08 +0200 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2016-11-29 20:06:08 +0200 |
commit | 295eef206ed65daa9801fc72875b34994b23ca01 (patch) | |
tree | ee11573a42ce94bb29c86ab9eade795d07ede294 /dfa.c | |
parent | 4931b67d7efa50576cea9f3045cc9d70ea779f2e (diff) | |
download | egawk-295eef206ed65daa9801fc72875b34994b23ca01.tar.gz egawk-295eef206ed65daa9801fc72875b34994b23ca01.tar.bz2 egawk-295eef206ed65daa9801fc72875b34994b23ca01.zip |
Add dfacopysyntax function and use it.
Diffstat (limited to 'dfa.c')
-rw-r--r-- | dfa.c | 24 |
1 files changed, 23 insertions, 1 deletions
@@ -805,6 +805,23 @@ char_context (struct dfa const *dfa, unsigned char c) return CTX_NONE; } +/* Copy the syntax settings from one dfa instance to another. + Saves considerable computation time if compiling many regular expressions + based on the same setting. */ +void +dfacopysyntax (struct dfa *to, const struct dfa *from) +{ + to->dfaexec = from->dfaexec; + to->simple_locale = from->simple_locale; + to->localeinfo = from->localeinfo; + + to->fast = from->fast; + + to->canychar = from->canychar; + to->lex.cur_mb_len = from->lex.cur_mb_len; + to->syntax = from->syntax; +} + /* Set a bit in the charclass for the given wchar_t. Do nothing if WC is represented by a multi-byte sequence. Even for MB_CUR_MAX == 1, this may happen when folding case in weird Turkish locales where @@ -3999,7 +4016,12 @@ dfamustfree (struct dfamust *dm) struct dfa * dfaalloc (void) { - return xmalloc (sizeof (struct dfa)); + void *p = xmalloc (sizeof (struct dfa)); + if (p) + { + memset (p, 0, sizeof (struct dfa)); + } + return p; } /* Initialize DFA. */ |