diff options
author | Jeffrey Stedfast <fejj@ximian.com> | 2002-09-28 03:24:24 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2002-09-28 03:24:24 +0800 |
commit | b57b273845c7173dd87e1e5de14404a8d7e27f34 (patch) | |
tree | f87939e0cf0c65a1350dd379cb1833e6aa798029 /mail/e-searching-tokenizer.c | |
parent | 896cc4eb2292c0d11db7873c7b4fdd642365181e (diff) | |
download | gsoc2013-evolution-b57b273845c7173dd87e1e5de14404a8d7e27f34.tar.gz gsoc2013-evolution-b57b273845c7173dd87e1e5de14404a8d7e27f34.tar.zst gsoc2013-evolution-b57b273845c7173dd87e1e5de14404a8d7e27f34.zip |
#include <stdlib.h> for alloca (searcher_next_token): Changed slightly to
2002-09-27 Jeffrey Stedfast <fejj@ximian.com>
* e-searching-tokenizer.c: #include <stdlib.h> for alloca
(searcher_next_token): Changed slightly to make sure that m is not
NULL before dereferencing it. Also initialise m to NULL so that it
can't be used uninitialised (NULL is a safe initialised value
here).
(build_trie): Same, but for n.
svn path=/trunk/; revision=18250
Diffstat (limited to 'mail/e-searching-tokenizer.c')
-rw-r--r-- | mail/e-searching-tokenizer.c | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/mail/e-searching-tokenizer.c b/mail/e-searching-tokenizer.c index cedbf4ea20..0c1e090cb5 100644 --- a/mail/e-searching-tokenizer.c +++ b/mail/e-searching-tokenizer.c @@ -26,9 +26,15 @@ * USA. */ + +#ifdef HAVE_CONFIG_H #include <config.h> +#endif + +#include <stdlib.h> #include <string.h> #include <ctype.h> + #include <gal/unicode/gunicode.h> #include "e-searching-tokenizer.h" @@ -257,7 +263,7 @@ build_trie(int nocase, int len, char **words) { struct _state *q, *qt, *r; char *word; - struct _match *m, *n; + struct _match *m, *n = NULL; int i, depth; guint32 c; struct _trie *trie; @@ -265,10 +271,10 @@ build_trie(int nocase, int len, char **words) struct _state **state_depth; trie = g_malloc(sizeof(*trie)); - trie->root.matches = 0; + trie->root.matches = NULL; trie->root.final = 0; - trie->root.fail = 0; - trie->root.next = 0; + trie->root.fail = NULL; + trie->root.next = NULL; trie->state_chunks = e_memchunk_new(8, sizeof(struct _state)); trie->match_chunks = e_memchunk_new(8, sizeof(struct _match)); @@ -291,13 +297,13 @@ build_trie(int nocase, int len, char **words) if (nocase) c = g_unichar_tolower(c); m = g(q, c); - if (m == 0) { + if (m == NULL) { m = e_memchunk_alloc(trie->match_chunks); m->ch = c; m->next = q->matches; q->matches = m; q = m->match = e_memchunk_alloc(trie->state_chunks); - q->matches = 0; + q->matches = NULL; q->fail = &trie->root; q->final = 0; if (state_depth_max < depth) { @@ -335,9 +341,9 @@ build_trie(int nocase, int len, char **words) c = m->ch; qt = m->match; r = q->fail; - while (r != 0 && (n = g(r, c)) == NULL) + while (r && (n = g(r, c)) == NULL) r = r->fail; - if (r != 0) { + if (r != NULL) { qt->fail = n->match; if (qt->fail->final > qt->final) qt->final = qt->fail->final; @@ -713,7 +719,7 @@ searcher_next_token(struct _searcher *s) char *tok, *stok; struct _trie *t = s->t; struct _state *q = s->state; - struct _match *m; + struct _match *m = NULL; int offstart, offend; guint32 c; @@ -752,11 +758,11 @@ searcher_next_token(struct _searcher *s) c = g_unichar_tolower(c); while (q && (m = g(q, c)) == NULL) q = q->fail; - if (q == 0) { + if (q == NULL) { /* mismatch ... reset state */ output_subpending(s); q = &t->root; - } else { + } else if (m != NULL) { /* keep track of previous offsets of utf8 chars, rotating buffer */ s->last[s->lastp] = s->offset + (tok-stok)-1; s->lastp = (s->lastp+1)&s->last_mask; |