• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/ap/gpl/timemachine/gettext-0.17/gettext-tools/libgrep/

Lines Matching refs:kwset

0 /* kwset.c - search for any of a set of keywords.
33 #include "kwset.h"
74 struct kwset
93 struct kwset *kwset;
95 kwset = (struct kwset *) malloc(sizeof (struct kwset));
96 if (!kwset)
99 obstack_init(&kwset->obstack);
100 kwset->words = 0;
101 kwset->trie
102 = (struct trie *) obstack_alloc(&kwset->obstack, sizeof (struct trie));
103 if (!kwset->trie)
105 kwsfree((kwset_t) kwset);
108 kwset->trie->accepting = 0;
109 kwset->trie->links = 0;
110 kwset->trie->parent = 0;
111 kwset->trie->next = 0;
112 kwset->trie->fail = 0;
113 kwset->trie->depth = 0;
114 kwset->trie->shift = 0;
115 kwset->mind = INT_MAX;
116 kwset->maxd = -1;
117 kwset->target = 0;
118 kwset->trans = trans;
120 return (kwset_t) kwset;
128 struct kwset *kwset;
137 kwset = (struct kwset *) kws;
138 trie = kwset->trie;
145 label = kwset->trans ? kwset->trans[(unsigned char) *--text] : *--text;
169 link = (struct tree *) obstack_alloc(&kwset->obstack,
175 link->trie = (struct trie *) obstack_alloc(&kwset->obstack,
268 trie->accepting = 1 + 2 * kwset->words;
269 ++kwset->words;
272 if (trie->depth < kwset->mind)
273 kwset->mind = trie->depth;
274 if (trie->depth > kwset->maxd)
275 kwset->maxd = trie->depth;
378 register struct kwset *kwset;
385 kwset = (struct kwset *) kws;
390 if (kwset->mind < 256)
392 delta[i] = kwset->mind;
399 if (kwset->words == 1 && kwset->trans == 0)
402 kwset->target = (char *) obstack_alloc(&kwset->obstack, kwset->mind);
403 for (i = kwset->mind - 1, curr = kwset->trie; i >= 0; --i)
405 kwset->target[i] = curr->links->label;
409 for (i = 0; i < kwset->mind; ++i)
410 delta[(unsigned char) kwset->target[i]] = kwset->mind - (i + 1);
411 kwset->mind2 = kwset->mind;
414 for (i = 0; i < kwset->mind - 1; ++i)
415 if (kwset->target[i] == kwset->target[kwset->mind - 1])
416 kwset->mind2 = kwset->mind - (i + 1);
422 for (curr = last = kwset->trie; curr; curr = curr->next)
427 curr->shift = kwset->mind;
428 curr->maxshift = kwset->mind;
434 treefails(curr->links, curr->fail, kwset->trie);
457 for (curr = kwset->trie->next; curr; curr = curr->next)
469 treenext(kwset->trie->links, next);
471 if ((trans = kwset->trans) != 0)
473 kwset->next[i] = next[(unsigned char) trans[i]];
476 kwset->next[i] = next[i];
480 if ((trans = kwset->trans) != 0)
482 kwset->delta[i] = delta[(unsigned char) trans[i]];
485 kwset->delta[i] = delta[i];
496 struct kwset const *kwset;
501 kwset = (struct kwset const *) kws;
502 len = kwset->mind;
510 tp = (const char *) memchr (text, kwset->target[0], size);
514 d1 = kwset->delta;
515 sp = kwset->target + len;
517 md2 = kwset->mind2;
582 struct kwset const *kwset;
597 kwset = (struct kwset *) kws;
598 if (len < kwset->mind)
600 next = kwset->next;
601 delta = kwset->delta;
602 trans = kwset->trans;
605 if ((d = kwset->mind) != 0)
609 mch = text, accept = kwset->trie;
613 if (len >= 4 * kwset->mind)
614 qlim = lim - 4 * kwset->mind;
674 if (lim - mch > kwset->maxd)
675 lim = mch + kwset->maxd;
745 struct kwset const *kwset = (struct kwset *) kws;
746 if (kwset->words == 1 && kwset->trans == 0)
753 kwsmatch->size[0] = kwset->mind;
765 struct kwset *kwset;
767 kwset = (struct kwset *) kws;
768 obstack_free(&kwset->obstack, 0);