nrgrep函数分析(3)--搜索实现分析
来源:互联网 发布:levirebrushed mac 编辑:程序博客网 时间:2024/06/07 07:01
此节重点分析的是nrgrep中与搜索相关的函数(其他与pattern函数往后再说),从Shell.c的234行/* get the pattern */开始:
1、 searchData *searchPreproc (byte *pat)
该函数是搜索前的预处理函数,根据pat初始化searchData(此数据结构在nrgrep中十分重要)
typedef struct
{ int searchType; /* type of pattern */
void *preprocData; /* data from preprocessing */
bool (*search)(); /* search function */
} searchData;
初始化工作有:给数据类型赋予相应的值
searchType
preprocData(返回Data)
search
SIMPLE
simplePreproc(simpleData)
simpleSearch
ESIMPLE
esimplePreproc(esimpleData)
esimpleSearch
EXTENDED
extendedPreproc(extendedData)
extendedSearch
EEXTENDED
eextendedPreproc(eextendedData)
eextendedSearch
REGULAR
regularPreproc(regulardData)
regularSearch
EREGULAR
eregularPreproc(eregulardData)
eregularSearch
2、 void recPreproc (void) 记录的预处理 当中也执行了simplePreproc().
/* search the files */接下来是两类不同选项时的搜索函数,由main调用
3、 int recSearchFile (char *fname, Buffer B, searchData *P)
/* searches the file handled by B for P using R as record
separator, reports matches as appropriate and returns number
of matches */
while循环
l searchScan (&pbeg,&pend,P) return P->search (beg,end,P->preprocData);
执行预处理是初始化的search函数(e.g. simpleSearch,extekdedSearch etc.)
l /* report the matching record */ 反馈相应匹配record
4、 int recSearchRecFile (char *fname, Buffer B, searchData *P)
/* searches the file handled by B for P using R as record
separator, but scans record by record. this is our way to
handle OptRecNumber or !OptRecPositive */
while循环
l simpleSearch (&rbeg,&rend,RecPatt)
l searchScan (&pbeg,&pend,P) return P->search (beg,end,P->preprocData);
执行预处理是初始化的search函数(e.g. simpleSearch,extekdedSearch etc.)
l /* report the matching record */ 反馈相应匹配record
- nrgrep函数分析(3)--搜索实现分析
- nrgrep函数分析(2)--搜索参数探讨
- nrgrep函数分析(1)--搜索流程简析
- PHP源代码分析-字符串搜索系列函数实现详解
- arp_rcv函数实现分析
- sqrt函数实现分析
- tcp_sendmsg函数实现分析
- Solr分布式搜索技术实现分析
- Solr分布式搜索技术实现分析
- 常用搜索算法的分析与实现
- linux select()函数实现分析
- select函数实现原理分析
- Select函数实现原理分析
- Select函数实现原理分析
- Select函数实现原理分析
- Select函数实现原理分析
- Select函数实现原理分析
- Select函数实现原理分析
- 开机自动打开文件夹开机自动运行记事本,开机自动打开文本文件,开机自动打开记事本服务
- hdu 1004 超时
- 关于委托、事件、处理事件的方法以及.NET 续一个实例
- 关于网站优化
- nrgrep函数分析(2)--搜索参数探讨
- nrgrep函数分析(3)--搜索实现分析
- 刷分
- malloc()与 alloc()区别
- Text-svg元素详解
- 用fork()和vfork()创建的进程各有何特点
- oracle数据文件内部BLOCK结构详解
- 网站的SEO优化
- GRASP模式总结
- java 中的 Enmu 的用法