From 616eda51e35e99e4997df00e0d21754d3b3f950b Mon Sep 17 00:00:00 2001 From: Alasdair Kergon Date: Thu, 22 Apr 2010 23:09:18 +0000 Subject: [PATCH] don't optimise anything with TARGET_TRANS to avoid intefering with the matcher's counting --- libdm/regex/matcher.c | 2 -- libdm/regex/parse_rx.c | 7 ++++++- libdm/regex/parse_rx.h | 2 ++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/libdm/regex/matcher.c b/libdm/regex/matcher.c index fe3979d41..350a35303 100644 --- a/libdm/regex/matcher.c +++ b/libdm/regex/matcher.c @@ -37,8 +37,6 @@ struct dm_regex { /* Instance variables for the lexer */ struct dm_pool *scratch, *mem; }; -#define TARGET_TRANS '\0' - static int _count_nodes(struct rx_node *rx) { int r = 1; diff --git a/libdm/regex/parse_rx.c b/libdm/regex/parse_rx.c index fe38c7a81..20f8c30e2 100644 --- a/libdm/regex/parse_rx.c +++ b/libdm/regex/parse_rx.c @@ -452,7 +452,12 @@ static int _nodes_equal(struct rx_node *l, struct rx_node *r) return _nodes_equal(l->left, r->left); case CHARSET: - return dm_bitset_equal(l->charset, r->charset); + /* + * Never change anything containing TARGET_TRANS + * used by matcher as boundary marker between concatenated + * expressions. + */ + return (!dm_bit(l->charset, TARGET_TRANS) && dm_bitset_equal(l->charset, r->charset)); } /* NOTREACHED */ diff --git a/libdm/regex/parse_rx.h b/libdm/regex/parse_rx.h index 1c2393fc1..4a5d8b94d 100644 --- a/libdm/regex/parse_rx.h +++ b/libdm/regex/parse_rx.h @@ -33,6 +33,8 @@ enum { #define HAT_CHAR 0x2 #define DOLLAR_CHAR 0x3 +#define TARGET_TRANS '\0' + struct rx_node { int type; dm_bitset_t charset;