Mercurial > hg > Applications > Grep
changeset 43:ead0a307449e
add regex.cc
author | Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 03 Mar 2015 00:44:39 +0900 |
parents | cdb4fd81c31f |
children | 62739627f8ec |
files | regex/Regex.h regex/bmsearch.cc regex/main.cc regex/regex.cc |
diffstat | 4 files changed, 34 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/regex/Regex.h Mon Mar 02 23:59:24 2015 +0900 +++ b/regex/Regex.h Tue Mar 03 00:44:39 2015 +0900 @@ -11,3 +11,12 @@ char* searchWord; int searchWordLen; } BMData, *BMDataPtr; + +typedef struct regexData { + char* readText; + int readTextLen; + char* searchWord; + int searchWordLen; + char** matchLinesHeads; + char* matchLineNum; +} RegexData, *RegexDataPtr;
--- a/regex/bmsearch.cc Mon Mar 02 23:59:24 2015 +0900 +++ b/regex/bmsearch.cc Tue Mar 03 00:44:39 2015 +0900 @@ -48,4 +48,3 @@ result->matchNum = matchCounter; return result; } -
--- a/regex/main.cc Mon Mar 02 23:59:24 2015 +0900 +++ b/regex/main.cc Tue Mar 03 00:44:39 2015 +0900 @@ -13,6 +13,7 @@ const char *usr_help_mode = "Please add -bm or -regex"; extern int *createBMskiptable(BMDataPtr); extern void *BMmethod(BMDataPtr,ResultPtr); +extern void *regex(RegexDataPtr); int main(int argc, char* argv[]) { @@ -82,7 +83,12 @@ free(result); free(bmdata); }else if (regexFlag == true) { - + RegexDataPtr regexD = (RegexDataPtr)malloc(sizeof(RegexData)); + regexD->readText = textfile; + regexD->readTextLen = sb.st_size; + regexD->searchWord = searchWord; + regexD->searchWordLen = strlen((const char*)regexD->searchWord); + regex(regexD); }else{ puts(usr_help_mode); exit(1);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/regex/regex.cc Tue Mar 03 00:44:39 2015 +0900 @@ -0,0 +1,18 @@ +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <math.h> +#include <string.h> +#include <sys/mman.h> +#include <sys/stat.h> +#include <sys/types.h> +#include <fcntl.h> +#include "regex.h" + +void* regex(RegexDataPtr regexD) +{ + char* readText = regexD->readText; + int readTextLen = regexD->readTextLen; + char* searchWord = regexD->searchWord; + int searchWordLen = regexD->searchWordLen; +}