]> git.saurik.com Git - wxWidgets.git/blob - contrib/src/stc/scintilla/src/RESearch.h
Patch #1106564, corrects possible 100% CPU load condition.
[wxWidgets.git] / contrib / src / stc / scintilla / src / RESearch.h
1 // Scintilla source code edit control
2 /** @file RESearch.h
3 ** Interface to the regular expression search library.
4 **/
5 // Written by Neil Hodgson <neilh@scintilla.org>
6 // Based on the work of Ozan S. Yigit.
7 // This file is in the public domain.
8
9 #ifndef RESEARCH_H
10 #define RESEARCH_H
11
12 /*
13 * The following defines are not meant to be changeable.
14 * They are for readability only.
15 */
16 #define MAXCHR 256
17 #define CHRBIT 8
18 #define BITBLK MAXCHR/CHRBIT
19
20 class CharacterIndexer {
21 public:
22 virtual char CharAt(int index)=0;
23 };
24
25 class RESearch {
26
27 public:
28 RESearch();
29 ~RESearch();
30 void Init();
31 void Clear();
32 bool GrabMatches(CharacterIndexer &ci);
33 void ChSet(char c);
34 void ChSetWithCase(char c, bool caseSensitive);
35 const char *Compile(const char *pat, int length, bool caseSensitive, bool posix);
36 int Execute(CharacterIndexer &ci, int lp, int endp);
37 void ModifyWord(char *s);
38 int Substitute(CharacterIndexer &ci, char *src, char *dst);
39
40 enum {MAXTAG=10};
41 enum {MAXNFA=2048};
42 enum {NOTFOUND=-1};
43
44 int bopat[MAXTAG];
45 int eopat[MAXTAG];
46 char *pat[MAXTAG];
47
48 private:
49 int PMatch(CharacterIndexer &ci, int lp, int endp, char *ap);
50
51 int bol;
52 int tagstk[MAXTAG]; /* subpat tag stack..*/
53 char nfa[MAXNFA]; /* automaton.. */
54 int sta;
55 char bittab[BITBLK]; /* bit table for CCL */
56 /* pre-set bits... */
57 int failure;
58 };
59
60 #endif