From b57b273845c7173dd87e1e5de14404a8d7e27f34 Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Fri, 27 Sep 2002 19:24:24 +0000 Subject: #include for alloca (searcher_next_token): Changed slightly to 2002-09-27 Jeffrey Stedfast * e-searching-tokenizer.c: #include 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 --- mail/ChangeLog | 9 +++++++++ mail/e-searching-tokenizer.c | 28 +++++++++++++++++----------- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/mail/ChangeLog b/mail/ChangeLog index 3920b075c2..6862bcbaf8 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,12 @@ +2002-09-27 Jeffrey Stedfast + + * e-searching-tokenizer.c: #include 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. + 2002-09-26 Dan Winship * mail-config.c (impl_GNOME_Evolution_MailConfig_addAccount, 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 +#endif + +#include #include #include + #include #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; -- cgit