diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2016-11-29 20:06:41 +0200 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2016-11-29 20:06:41 +0200 |
commit | 5b481a85111b33d9430b7f4c63474709ffbd0fab (patch) | |
tree | 12f3bd7856d27f6e2a957d16682458f5b7d74182 /dfa.c | |
parent | 2d0858d286df94ea822bf8f51656ecf7ac05b6ea (diff) | |
parent | 295eef206ed65daa9801fc72875b34994b23ca01 (diff) | |
download | egawk-5b481a85111b33d9430b7f4c63474709ffbd0fab.tar.gz egawk-5b481a85111b33d9430b7f4c63474709ffbd0fab.tar.bz2 egawk-5b481a85111b33d9430b7f4c63474709ffbd0fab.zip |
Merge branch 'master' into feature/fix-comments
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. */ |