[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
dfa.c badly broken when dropped into gawk
From: |
Arnold Robbins |
Subject: |
dfa.c badly broken when dropped into gawk |
Date: |
Sun, 15 Dec 2019 20:43:53 +0200 |
User-agent: |
Heirloom mailx 12.5 6/20/10 |
Hi.
The current dfa.[ch] are badly broken when dropped into gawk. To
reproduce:
1. Checkout the gawk repo
2. Copy gnulib/lib/dfa.[ch] into gawk/support/.
3. Apply the minimal patch below
Then the usual `./bootstrap.sh && ./configure && make -j && make check'.
You'll see lots of the tests blowing up spectacularly.
Please repair things.
Thanks,
Arnold
----------------------------------------
diff --git a/lib/dfa.c b/lib/dfa.c
index 8c88c9d..818f58f 100644
--- a/lib/dfa.c
+++ b/lib/dfa.c
@@ -890,6 +890,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
diff --git a/lib/dfa.h b/lib/dfa.h
index 96c3bf1..c6dc786 100644
--- a/lib/dfa.h
+++ b/lib/dfa.h
@@ -42,7 +42,7 @@ struct dfa;
/* Allocate a struct dfa. The struct dfa is completely opaque.
The returned pointer should be passed directly to free() after
calling dfafree() on it. */
-extern struct dfa *dfaalloc (void) _GL_ATTRIBUTE_MALLOC;
+extern struct dfa *dfaalloc (void) /* _GL_ATTRIBUTE_MALLOC */ ;
/* DFA options that can be ORed together, for dfasyntax's 4th arg. */
enum
@@ -105,6 +105,11 @@ extern struct dfa *dfasuperset (struct dfa const *d)
_GL_ATTRIBUTE_PURE;
/* The DFA is likely to be fast. */
extern bool dfaisfast (struct dfa const *) _GL_ATTRIBUTE_PURE;
+/* Copy the syntax settings from one dfa instance to another.
+ Saves considerable computation time if compiling many regular expressions
+ based on the same setting. */
+extern void dfacopysyntax (struct dfa *to, const struct dfa *from);
+
/* Free the storage held by the components of a struct dfa. */
extern void dfafree (struct dfa *);
- dfa.c badly broken when dropped into gawk,
Arnold Robbins <=