public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2/libdm/regex matcher.c
@ 2010-08-09 10:30 thornber
  0 siblings, 0 replies; 4+ messages in thread
From: thornber @ 2010-08-09 10:30 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	thornber@sourceware.org	2010-08-09 10:30:52

Modified files:
	libdm/regex    : matcher.c 

Log message:
	[REGEX] fix bug in matcher that was causing segfault with chars of 0x80 and over.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/regex/matcher.c.diff?cvsroot=lvm2&r1=1.11&r2=1.12

--- LVM2/libdm/regex/matcher.c	2010/07/21 12:09:13	1.11
+++ LVM2/libdm/regex/matcher.c	2010/08/09 10:30:52	1.12
@@ -375,7 +375,7 @@
         struct dfa_state *ns;
 
         if (!(ns = cs->lookup[(unsigned char) c]))
-                _calc_state(m, cs, c);
+                _calc_state(m, cs, (unsigned char) c);
 
 	if (!(ns = cs->lookup[(unsigned char) c]))
 		return NULL;


^ permalink raw reply	[flat|nested] 4+ messages in thread

* LVM2/libdm/regex matcher.c
@ 2010-11-29 14:25 zkabelac
  0 siblings, 0 replies; 4+ messages in thread
From: zkabelac @ 2010-11-29 14:25 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2010-11-29 14:25:14

Modified files:
	libdm/regex    : matcher.c 

Log message:
	Optimize lookup table read
	
	Reread lookup table only when needed.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/regex/matcher.c.diff?cvsroot=lvm2&r1=1.14&r2=1.15

--- LVM2/libdm/regex/matcher.c	2010/11/29 12:43:49	1.14
+++ LVM2/libdm/regex/matcher.c	2010/11/29 14:25:13	1.15
@@ -372,11 +372,11 @@
 {
         struct dfa_state *ns;
 
-        if (!cs->lookup[(unsigned char) c])
-                _calc_state(m, cs, (unsigned char) c);
-
-	if (!(ns = cs->lookup[(unsigned char) c]))
-		return NULL;
+	if (!(ns = cs->lookup[(unsigned char) c])) {
+		_calc_state(m, cs, (unsigned char) c);
+		if (!(ns = cs->lookup[(unsigned char) c]))
+			return NULL;
+	}
 
         // yuck, we have to special case the target trans
         if (ns->final == -1)


^ permalink raw reply	[flat|nested] 4+ messages in thread

* LVM2/libdm/regex matcher.c
@ 2010-11-29 12:43 zkabelac
  0 siblings, 0 replies; 4+ messages in thread
From: zkabelac @ 2010-11-29 12:43 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2010-11-29 12:43:49

Modified files:
	libdm/regex    : matcher.c 

Log message:
	Remove dead assignment in _step_matcher
	
	'ns' is not used after this assignment and it is reassigned with the following
	code, so dropping this assignment.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/regex/matcher.c.diff?cvsroot=lvm2&r1=1.13&r2=1.14

--- LVM2/libdm/regex/matcher.c	2010/09/30 21:06:52	1.13
+++ LVM2/libdm/regex/matcher.c	2010/11/29 12:43:49	1.14
@@ -372,7 +372,7 @@
 {
         struct dfa_state *ns;
 
-        if (!(ns = cs->lookup[(unsigned char) c]))
+        if (!cs->lookup[(unsigned char) c])
                 _calc_state(m, cs, (unsigned char) c);
 
 	if (!(ns = cs->lookup[(unsigned char) c]))


^ permalink raw reply	[flat|nested] 4+ messages in thread

* LVM2/libdm/regex matcher.c
@ 2010-07-21 12:02 thornber
  0 siblings, 0 replies; 4+ messages in thread
From: thornber @ 2010-07-21 12:02 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	thornber@sourceware.org	2010-07-21 12:02:51

Modified files:
	libdm/regex    : matcher.c 

Log message:
	[REGEX] remove the state_queue structure.
	
	Instead we just have a 'next' field in the dfa_state.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/regex/matcher.c.diff?cvsroot=lvm2&r1=1.9&r2=1.10

--- LVM2/libdm/regex/matcher.c	2010/07/21 12:00:53	1.9
+++ LVM2/libdm/regex/matcher.c	2010/07/21 12:02:51	1.10
@@ -19,14 +19,10 @@
 #include "assert.h"
 
 struct dfa_state {
+	struct dfa_state *next;
 	int final;
-	struct dfa_state *lookup[256];
-};
-
-struct state_queue {
-	struct dfa_state *s;
 	dm_bitset_t bits;
-	struct state_queue *next;
+	struct dfa_state *lookup[256];
 };
 
 struct dm_regex {		/* Instance variables for the lexer */
@@ -44,7 +40,7 @@
         dm_bitset_t dfa_copy;
         struct ttree *tt;
         dm_bitset_t bs;
-        struct state_queue *h, *t;
+        struct dfa_state *h, *t;
 };
 
 static int _count_nodes(struct rx_node *rx)
@@ -206,29 +202,20 @@
 	return dm_pool_zalloc(mem, sizeof(struct dfa_state));
 }
 
-static struct state_queue *_create_state_queue(struct dm_pool *mem,
-					       struct dfa_state *dfa,
-					       dm_bitset_t bits)
+static struct dfa_state *_create_state_queue(struct dm_pool *mem,
+                                             struct dfa_state *dfa,
+                                             dm_bitset_t bits)
 {
-	struct state_queue *r = dm_pool_alloc(mem, sizeof(*r));
-
-	if (!r) {
-		stack;
-		return NULL;
-	}
-
-	r->s = dfa;
-	r->bits = dm_bitset_create(mem, bits[0]);	/* first element is the size */
-	dm_bit_copy(r->bits, bits);
-	r->next = 0;
-	return r;
+	dfa->bits = dm_bitset_create(mem, bits[0]);	/* first element is the size */
+	dm_bit_copy(dfa->bits, bits);
+	dfa->next = 0;
+	return dfa;
 }
 
-static void _calc_state(struct dm_regex *m, struct state_queue *h, int a)
+static void _calc_state(struct dm_regex *m, struct dfa_state *dfa, int a)
 {
         int set_bits = 0, i;
-        struct dfa_state *dfa = h->s;
-        dm_bitset_t dfa_bits = h->bits;
+        dm_bitset_t dfa_bits = dfa->bits;
         dm_bit_and(m->dfa_copy, m->charmap[a], dfa_bits);
 
         /* iterate through all the states in firstpos */
@@ -241,7 +228,7 @@
         }
 
         if (set_bits) {         /* FIXME: this is always true */
-                struct state_queue *tmp;
+                struct dfa_state *tmp;
                 struct dfa_state *ldfa = ttree_lookup(m->tt, m->bs + 1);
                 if (!ldfa) {
                         /* push */
@@ -300,7 +287,7 @@
         m->dfa_copy = dm_bitset_create(m->scratch, m->num_charsets);
 
         /* keep processing until there's nothing in the queue */
-        struct state_queue *s;
+        struct dfa_state *s;
 	while ((s = m->h)) {
 		/* pop state off front of the queue */
 		m->h = m->h->next;


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-11-29 14:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-09 10:30 LVM2/libdm/regex matcher.c thornber
  -- strict thread matches above, loose matches on Subject: below --
2010-11-29 14:25 zkabelac
2010-11-29 12:43 zkabelac
2010-07-21 12:02 thornber

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).