MCPcopy Create free account
hub / github.com/git/git / cwexec

Function cwexec

kwset.c:625–779  ·  view source on GitHub ↗

Hairy multiple string search. */

Source from the content-addressed store, hash-verified

623
624/* Hairy multiple string search. */
625static size_t
626cwexec (kwset_t kws, char const *text, size_t len, struct kwsmatch *kwsmatch)
627{
628 struct kwset const *kwset;
629 struct trie * const *next;
630 struct trie const *trie;
631 struct trie const *accept;
632 char const *beg, *lim, *mch, *lmch;
633 register unsigned char c;
634 register unsigned char const *delta;
635 register int d;
636 register char const *end, *qlim;
637 register struct tree const *tree;
638 register unsigned char const *trans;
639
640 accept = NULL;
641
642 /* Initialize register copies and look for easy ways out. */
643 kwset = (struct kwset *) kws;
644 if (len < kwset->mind)
645 return -1;
646 next = kwset->next;
647 delta = kwset->delta;
648 trans = kwset->trans;
649 lim = text + len;
650 end = text;
651 if ((d = kwset->mind) != 0)
652 mch = NULL;
653 else
654 {
655 mch = text;
656 accept = kwset->trie;
657 goto match;
658 }
659
660 if (len >= 4 * kwset->mind)
661 qlim = lim - 4 * kwset->mind;
662 else
663 qlim = NULL;
664
665 while (lim - end >= d)
666 {
667 if (qlim && end <= qlim)
668 {
669 end += d - 1;
670 while ((d = delta[c = *end]) && end < qlim)
671 {
672 end += d;
673 end += delta[U(*end)];
674 end += delta[U(*end)];
675 }
676 ++end;
677 }
678 else
679 d = delta[c = (end += d)[-1]];
680 if (d)
681 continue;
682 beg = end - 1;

Callers 1

kwsexecFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected