亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? research.cxx

?? 一個可以提供語法高亮顯示的編輯器
?? CXX
?? 第 1 頁 / 共 2 頁
字號:
// Scintilla source code edit control
/** @file RESearch.cxx
 ** Regular expression search library.
 **/

/*
 * regex - Regular expression pattern matching  and replacement
 *
 * By:  Ozan S. Yigit (oz)
 *      Dept. of Computer Science
 *      York University
 *
 * Original code available from http://www.cs.yorku.ca/~oz/ 
 * Translation to C++ by Neil Hodgson neilh@scintilla.org
 * Removed all use of register.
 * Converted to modern function prototypes.
 * Put all global/static variables into an object so this code can be 
 * used from multiple threads etc.
 *
 * These routines are the PUBLIC DOMAIN equivalents of regex
 * routines as found in 4.nBSD UN*X, with minor extensions.
 *
 * These routines are derived from various implementations found
 * in software tools books, and Conroy's grep. They are NOT derived
 * from licensed/restricted software.
 * For more interesting/academic/complicated implementations,
 * see Henry Spencer's regexp routines, or GNU Emacs pattern
 * matching module.
 *
 * Modification history:
 *
 * $Log: RESearch.cxx,v $
 * Revision 1.9  2003/03/21 10:36:08  nyamatongwe
 * Detect patterns too long in regular expression search.
 *
 * Revision 1.8  2003/03/04 10:53:59  nyamatongwe
 * Patch from Jakub to optionally implement more POSIX compatible regular
 * expressions. \(..\) changes to (..)
 * Fixes problem where find previous would not find earlier matches on same
 * line.
 *
 * Revision 1.8  2003/03/03 20:12:56  vrana
 * Added posix syntax.
 *
 * Revision 1.7  2002/09/28 00:33:28  nyamatongwe
 * Fixed problem with character ranges caused by expansion to 8 bits.
 *
 * Revision 1.6  2001/04/29 13:32:10  nyamatongwe
 * Addition of new target methods - versions of ReplaceTarget that take counted
 * strings to allow for nulls, SearchInTarget and Get/SetSearchFlags to use a
 * series of calls rather than a structure.
 * Handling of \000 in search and replace.
 * Handling of /escapes within character ranges of regular expressions.
 * Some handling of bare ^ and $ regular expressions.
 *
 * Revision 1.5  2001/04/20 07:36:09  nyamatongwe
 * Removed DEBUG code that failed to compile on GTK+.
 *
 * Revision 1.4  2001/04/13 03:52:13  nyamatongwe
 * Added URL to find original code to comments.
 *
 * Revision 1.3  2001/04/06 12:24:21  nyamatongwe
 * Made regular expression searching work on a line by line basis, made ^ and
 * $ work, made [set] work, and added a case insensitive option.
 *
 * Revision 1.2  2001/04/05 01:58:04  nyamatongwe
 * Replace target functionality to make find and replace operations faster
 * by diminishing screen updates and allow for \d patterns in the replacement
 * text.
 *
 * Revision 1.1  2001/04/04 12:52:44  nyamatongwe
 * Moved to public domain regular expresion implementation.
 *
 * Revision 1.4  1991/10/17  03:56:42  oz
 * miscellaneous changes, small cleanups etc.
 *
 * Revision 1.3  1989/04/01  14:18:09  oz
 * Change all references to a dfa: this is actually an nfa.
 *
 * Revision 1.2  88/08/28  15:36:04  oz
 * Use a complement bitmap to represent NCL.
 * This removes the need to have seperate 
 * code in the PMatch case block - it is 
 * just CCL code now.
 * 
 * Use the actual CCL code in the CLO
 * section of PMatch. No need for a recursive
 * PMatch call.
 * 
 * Use a bitmap table to set char bits in an
 * 8-bit chunk.
 * 
 * Interfaces:
 *      RESearch::Compile:        compile a regular expression into a NFA.
 *
 *			char *RESearch::Compile(s)
 *			char *s;
 *
 *      RESearch::Execute:        execute the NFA to match a pattern.
 *
 *			int RESearch::Execute(s)
 *			char *s;
 *
 *	RESearch::ModifyWord		change RESearch::Execute's understanding of what a "word"
 *			looks like (for \< and \>) by adding into the
 *			hidden word-syntax table.
 *
 *			void RESearch::ModifyWord(s)
 *			char *s;
 *
 *      RESearch::Substitute:	substitute the matched portions in a new string.
 *
 *			int RESearch::Substitute(src, dst)
 *			char *src;
 *			char *dst;
 *
 *	re_fail:	failure routine for RESearch::Execute.
 *
 *			void re_fail(msg, op)
 *			char *msg;
 *			char op;
 *  
 * Regular Expressions:
 *
 *      [1]     char    matches itself, unless it is a special
 *                      character (metachar): . \ [ ] * + ^ $
 *
 *      [2]     .       matches any character.
 *
 *      [3]     \       matches the character following it, except
 *			when followed by a left or right round bracket,
 *			a digit 1 to 9 or a left or right angle bracket. 
 *			(see [7], [8] and [9])
 *			It is used as an escape character for all 
 *			other meta-characters, and itself. When used
 *			in a set ([4]), it is treated as an ordinary
 *			character.
 *
 *      [4]     [set]   matches one of the characters in the set.
 *                      If the first character in the set is "^",
 *                      it matches a character NOT in the set, i.e. 
 *			complements the set. A shorthand S-E is 
 *			used to specify a set of characters S upto 
 *			E, inclusive. The special characters "]" and 
 *			"-" have no special meaning if they appear 
 *			as the first chars in the set.
 *                      examples:        match:
 *
 *                              [a-z]    any lowercase alpha
 *
 *                              [^]-]    any char except ] and -
 *
 *                              [^A-Z]   any char except uppercase
 *                                       alpha
 *
 *                              [a-zA-Z] any alpha
 *
 *      [5]     *       any regular expression form [1] to [4], followed by
 *                      closure char (*) matches zero or more matches of
 *                      that form.
 *
 *      [6]     +       same as [5], except it matches one or more.
 *
 *      [7]             a regular expression in the form [1] to [10], enclosed
 *                      as \(form\) matches what form matches. The enclosure
 *                      creates a set of tags, used for [8] and for
 *                      pattern substution. The tagged forms are numbered
 *			starting from 1.
 *
 *      [8]             a \ followed by a digit 1 to 9 matches whatever a
 *                      previously tagged regular expression ([7]) matched.
 *
 *	[9]	\<	a regular expression starting with a \< construct
 *		\>	and/or ending with a \> construct, restricts the
 *			pattern matching to the beginning of a word, and/or
 *			the end of a word. A word is defined to be a character
 *			string beginning and/or ending with the characters
 *			A-Z a-z 0-9 and _. It must also be preceded and/or
 *			followed by any character outside those mentioned.
 *
 *      [10]            a composite regular expression xy where x and y
 *                      are in the form [1] to [10] matches the longest
 *                      match of x followed by a match for y.
 *
 *      [11]	^	a regular expression starting with a ^ character
 *		$	and/or ending with a $ character, restricts the
 *                      pattern matching to the beginning of the line,
 *                      or the end of line. [anchors] Elsewhere in the
 *			pattern, ^ and $ are treated as ordinary characters.
 *
 *
 * Acknowledgements:
 *
 *	HCR's Hugh Redelmeier has been most helpful in various
 *	stages of development. He convinced me to include BOW
 *	and EOW constructs, originally invented by Rob Pike at
 *	the University of Toronto.
 *
 * References:
 *              Software tools			Kernighan & Plauger
 *              Software tools in Pascal        Kernighan & Plauger
 *              Grep [rsx-11 C dist]            David Conroy
 *		ed - text editor		Un*x Programmer's Manual
 *		Advanced editing on Un*x	B. W. Kernighan
 *		RegExp routines			Henry Spencer
 *
 * Notes:
 *
 *	This implementation uses a bit-set representation for character
 *	classes for speed and compactness. Each character is represented 
 *	by one bit in a 128-bit block. Thus, CCL always takes a 
 *	constant 16 bytes in the internal nfa, and RESearch::Execute does a single
 *	bit comparison to locate the character in the set.
 *
 * Examples:
 *
 *	pattern:	foo*.*
 *	compile:	CHR f CHR o CLO CHR o END CLO ANY END END
 *	matches:	fo foo fooo foobar fobar foxx ...
 *
 *	pattern:	fo[ob]a[rz]	
 *	compile:	CHR f CHR o CCL bitset CHR a CCL bitset END
 *	matches:	fobar fooar fobaz fooaz
 *
 *	pattern:	foo\\+
 *	compile:	CHR f CHR o CHR o CHR \ CLO CHR \ END END
 *	matches:	foo\ foo\\ foo\\\  ...
 *
 *	pattern:	\(foo\)[1-3]\1	(same as foo[1-3]foo)
 *	compile:	BOT 1 CHR f CHR o CHR o EOT 1 CCL bitset REF 1 END
 *	matches:	foo1foo foo2foo foo3foo
 *
 *	pattern:	\(fo.*\)-\1
 *	compile:	BOT 1 CHR f CHR o CLO ANY END EOT 1 CHR - REF 1 END
 *	matches:	foo-foo fo-fo fob-fob foobar-foobar ...
 */

#include "RESearch.h"

#define OKP     1
#define NOP     0

#define CHR     1
#define ANY     2
#define CCL     3
#define BOL     4
#define EOL     5
#define BOT     6
#define EOT     7
#define BOW	8
#define EOW	9
#define REF     10
#define CLO     11

#define END     0

/*
 * The following defines are not meant to be changeable.
 * They are for readability only.
 */
#define BLKIND	0170
#define BITIND	07

#define ASCIIB	0177

const char bitarr[] = {1,2,4,8,16,32,64,'\200'};

#define badpat(x)	(*nfa = END, x)
 
RESearch::RESearch() {
	Init();
}

RESearch::~RESearch() {
	Clear();
}

void RESearch::Init() {
	sta = NOP;               	/* status of lastpat */
	bol = 0;
	for (int i=0; i<MAXTAG; i++)
		pat[i] = 0;
	for (int j=0; j<BITBLK; j++)
		bittab[j] = 0;
}

void RESearch::Clear() {
	for (int i=0; i<MAXTAG; i++) {
		delete []pat[i];
		pat[i] = 0;
		bopat[i] = NOTFOUND;
		eopat[i] = NOTFOUND;
	}
}

bool RESearch::GrabMatches(CharacterIndexer &ci) {
	bool success = true;
	for (unsigned int i=0; i<MAXTAG; i++) {
		if ((bopat[i] != NOTFOUND) && (eopat[i] != NOTFOUND)) {
			unsigned int len = eopat[i] - bopat[i];
			pat[i] = new char[len + 1];
			if (pat[i]) {
				for (unsigned int j=0; j<len; j++)
					pat[i][j] = ci.CharAt(bopat[i] + j);
				pat[i][len] = '\0';
			} else {
				success = false;
			}
		}
	}
	return success;
}

void RESearch::ChSet(char c) {
	bittab[((c) & BLKIND) >> 3] |= bitarr[(c) & BITIND];
}

void RESearch::ChSetWithCase(char c, bool caseSensitive) {
	if (caseSensitive) {
		ChSet(c);
	} else {
		if ((c >= 'a') && (c <= 'z')) {
			ChSet(c);
			ChSet(static_cast<char>(c - 'a' + 'A'));
		} else if ((c >= 'A') && (c <= 'Z')) {
			ChSet(c);
			ChSet(static_cast<char>(c - 'A' + 'a'));
		} else {
			ChSet(c);
		}
	}
}

const char escapeValue(char ch) {
	switch (ch) {
	case 'a':	return '\a';
	case 'b':	return '\b';
	case 'f':	return '\f';
	case 'n':	return '\n';
	case 'r':	return '\r';
	case 't':	return '\t';
	case 'v':	return '\v';
	}
	return 0;
}

const char *RESearch::Compile(const char *pat, int length, bool caseSensitive, bool posix) {
	char *mp=nfa;          /* nfa pointer       */
	char *lp;              /* saved pointer..   */
	char *sp=nfa;          /* another one..     */
    char *mpMax = mp + MAXNFA - BITBLK - 10;

	int tagi = 0;          /* tag stack index   */
	int tagc = 1;          /* actual tag count  */

	int n;
	char mask;		/* xor mask -CCL/NCL */
	int c1, c2;
		
	if (!pat || !length)
		if (sta)
			return 0;
		else
			return badpat("No previous regular expression");
	sta = NOP;

	const char *p=pat;               /* pattern pointer   */
	for (int i=0; i<length; i++, p++) {
		if (mp > mpMax)
			return badpat("Pattern too long");
		lp = mp;
		switch(*p) {

		case '.':               /* match any char..  */
			*mp++ = ANY;
			break;

		case '^':               /* match beginning.. */
			if (p == pat)
				*mp++ = BOL;
			else {
				*mp++ = CHR;
				*mp++ = *p;
			}
			break;

		case '$':               /* match endofline.. */
			if (!*(p+1))
				*mp++ = EOL;
			else {
				*mp++ = CHR;
				*mp++ = *p;
			}
			break;

		case '[':               /* match char class..*/
			*mp++ = CCL;

			i++;
			if (*++p == '^') {
				mask = '\377';	
				i++;
				p++;
			} else
				mask = 0;

			if (*p == '-') {		/* real dash */
				i++;
				ChSet(*p++);
			}
			if (*p == ']') {	/* real brace */
				i++;
				ChSet(*p++);
			}
			while (*p && *p != ']') {
				if (*p == '-' && *(p+1) && *(p+1) != ']') {
					i++;
					p++;
					c1 = *(p-2) + 1;
					i++;
					c2 = *p++;
					while (c1 <= c2) {
						ChSetWithCase(static_cast<char>(c1++), caseSensitive);
					}
				} else if (*p == '\\' && *(p+1)) {
					i++;
					p++;
					char escape = escapeValue(*p);
					if (escape)
						ChSetWithCase(escape, caseSensitive);
					else
						ChSetWithCase(*p, caseSensitive);
					i++;
					p++;
				} else {
					i++;
					ChSetWithCase(*p++, caseSensitive);
				}
			}
			if (!*p)
				return badpat("Missing ]");

			for (n = 0; n < BITBLK; bittab[n++] = (char) 0)
				*mp++ = static_cast<char>(mask ^ bittab[n]);
	
			break;

		case '*':               /* match 0 or more.. */
		case '+':               /* match 1 or more.. */

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日本最新不卡在线| 91在线视频免费91| 成人黄色国产精品网站大全在线免费观看 | 欧美精选一区二区| 久久久久97国产精华液好用吗| 亚洲一区二区在线免费看| 国产一区二区免费看| 欧美三级在线视频| 日韩一区在线看| 精品一区二区三区在线观看| 色呦呦国产精品| 国产清纯白嫩初高生在线观看91 | 国产精品私房写真福利视频| 天天综合网天天综合色| www.欧美精品一二区| 精品国产一区二区三区久久久蜜月 | 亚洲大片免费看| 成人免费视频网站在线观看| 日韩午夜电影在线观看| 亚洲已满18点击进入久久| 粉嫩aⅴ一区二区三区四区五区| 欧美一级片在线观看| 亚洲国产一区视频| 色综合久久久网| 国产精品国产三级国产a| 国产一区不卡视频| 日韩精品一区二区三区三区免费| 亚洲一二三区在线观看| 91亚洲精品久久久蜜桃| 欧美国产激情一区二区三区蜜月| 久久99国产精品久久99| 538在线一区二区精品国产| 亚洲国产日韩a在线播放性色| 91亚洲永久精品| 亚洲伦理在线精品| 色视频成人在线观看免| 亚洲欧美偷拍三级| 色久综合一二码| 洋洋成人永久网站入口| 色婷婷综合久久久久中文| 日韩一区欧美一区| 日本久久电影网| 亚洲国产日韩a在线播放| 欧美性猛交一区二区三区精品| 亚洲欧美国产77777| 91福利在线免费观看| 亚洲成av人片一区二区梦乃| 欧美日韩成人综合| 日韩不卡免费视频| 精品国内二区三区| 成人免费电影视频| 亚洲免费资源在线播放| 欧美亚日韩国产aⅴ精品中极品| 亚洲一区二区五区| 日韩三级精品电影久久久 | 午夜欧美视频在线观看| 91精品欧美福利在线观看| 麻豆成人91精品二区三区| 久久中文字幕电影| 97久久超碰国产精品电影| 亚洲风情在线资源站| 欧美一区二视频| 国产激情视频一区二区三区欧美| 亚洲欧美自拍偷拍| 欧美日韩在线亚洲一区蜜芽| 久久精品国产在热久久| 国产精品婷婷午夜在线观看| 91久久精品一区二区| 久久精品99国产精品日本| 国产精品视频免费看| 欧美日韩专区在线| 国产乱国产乱300精品| 亚洲日本在线a| 欧美一区二区三区免费在线看| 国产精品1区二区.| 免费精品99久久国产综合精品| 精品国产一区二区三区久久影院 | 日本一区二区三区dvd视频在线| 欧美这里有精品| 精品午夜久久福利影院| 一区二区三区在线影院| 久久久噜噜噜久久人人看 | 亚洲一区自拍偷拍| 久久久三级国产网站| 91国偷自产一区二区开放时间 | 91精品国产91热久久久做人人 | 久久国产成人午夜av影院| 中文字幕一区二区三区四区 | 92国产精品观看| 久久精品国产99国产精品| 亚洲欧美日韩国产综合| 日韩视频永久免费| 欧美怡红院视频| 国产成人av电影在线观看| 天堂成人免费av电影一区| 中文字幕乱码一区二区免费| 欧美一级高清片在线观看| 色吧成人激情小说| 成人黄页在线观看| 国产精品一线二线三线| 日韩国产精品久久久久久亚洲| 亚洲人被黑人高潮完整版| 国产亚洲一二三区| 日韩久久久久久| 在线成人小视频| 欧美网站大全在线观看| 91在线视频播放地址| 成人av资源下载| 国产xxx精品视频大全| 国产精品亚洲第一区在线暖暖韩国| 日韩一区精品字幕| 天天做天天摸天天爽国产一区 | 色噜噜狠狠色综合中国| 不卡欧美aaaaa| www.欧美精品一二区| 国产成人一区在线| 成人深夜在线观看| 成人黄色在线网站| 国产原创一区二区三区| 亚洲精品欧美综合四区| 久久亚洲精品国产精品紫薇| 日韩欧美国产wwwww| 日韩一区二区免费在线电影| 91.麻豆视频| 精品国产一区久久| 国产欧美一区二区精品性| 国产午夜亚洲精品午夜鲁丝片| 精品va天堂亚洲国产| 国产欧美一区二区三区鸳鸯浴| 久久久精品国产免费观看同学| 国产目拍亚洲精品99久久精品| 国产亚洲成av人在线观看导航| 久久精品亚洲精品国产欧美| 国产婷婷色一区二区三区四区| 国产欧美一区二区精品婷婷| 综合自拍亚洲综合图不卡区| 亚洲已满18点击进入久久| 日韩精品免费专区| 国内精品视频666| 成人午夜激情影院| 欧美色综合影院| 日韩欧美国产系列| 中文字幕一区二区三区在线播放| 一区二区三区日韩在线观看| 婷婷六月综合网| 国产综合久久久久影院| 色综合久久综合网欧美综合网 | 国产不卡在线播放| 91视频精品在这里| 欧美久久一二三四区| 久久先锋影音av鲁色资源| 国产精品免费久久| 亚洲国产精品精华液网站| 免费成人深夜小野草| 成人做爰69片免费看网站| 色哟哟精品一区| 久久综合久久综合久久综合| 亚洲卡通动漫在线| 国产一区二区三区精品视频| 一本久道久久综合中文字幕| 久久综合色婷婷| 亚洲动漫第一页| 成人国产亚洲欧美成人综合网| 欧美精品久久一区| 日韩伦理免费电影| 国内精品写真在线观看| 欧美伦理电影网| 亚洲天天做日日做天天谢日日欢 | 波多野结衣视频一区| 56国语精品自产拍在线观看| 日韩伦理电影网| 风流少妇一区二区| 日韩欧美在线影院| 亚洲福利一二三区| 日韩西西人体444www| 国产精品美女久久久久高潮| 精品国产一区二区精华| 亚洲最色的网站| 国产一区欧美一区| 欧美高清视频一二三区| 欧美一区二区三区白人| 99精品国产热久久91蜜凸| 欧美国产一区二区| 国产一区二区在线观看视频| 欧美精品一级二级三级| 国产精品久久久久影院老司| 国产精品白丝av| 亚洲欧美二区三区| 欧美在线视频不卡| 免费av网站大全久久| 日韩欧美一级二级三级| 国产不卡视频在线观看| **性色生活片久久毛片| 91麻豆免费看| 日本欧美在线看| 精品剧情在线观看| 91在线观看污| 免费人成精品欧美精品| 欧美精品久久久久久久久老牛影院 | 亚洲天堂久久久久久久|