Mercurial > hg > Applications > Grep
comparison regexParser/sequentialSearch.cc @ 230:2081b9d6a179
change var name BufferList to Buffer.
author | Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 18 Jan 2016 16:41:17 +0900 |
parents | 8be58af605da |
children | d67649929e96 |
comparison
equal
deleted
inserted
replaced
229:f2454c17e410 | 230:2081b9d6a179 |
---|---|
4 #include <fcntl.h> | 4 #include <fcntl.h> |
5 #include <sys/stat.h> | 5 #include <sys/stat.h> |
6 #include <sys/mman.h> | 6 #include <sys/mman.h> |
7 #include <sys/types.h> | 7 #include <sys/types.h> |
8 | 8 |
9 typedef struct bufferList { | 9 typedef struct buffer { |
10 unsigned char *buff; | 10 unsigned char *buff; |
11 unsigned char *buffptr; | 11 unsigned char *buffptr; |
12 unsigned char *buffend; | 12 unsigned char *buffend; |
13 unsigned char *matchBegin; | 13 unsigned char *matchBegin; |
14 } BufferList, *BufferListPtr; | 14 } Buffer, *BufferPtr; |
15 | 15 |
16 typedef struct { | 16 typedef struct { |
17 caddr_t file_mmap; | 17 caddr_t file_mmap; |
18 off_t size; | 18 off_t size; |
19 } st_mmap_t; | 19 } st_mmap_t; |
20 | 20 |
21 void state1(BufferList buff); | 21 void state1(Buffer buff); |
22 | 22 |
23 void stateSkip(BufferList buff) { | 23 void stateSkip(Buffer buff) { |
24 buff.matchBegin = buff.buffptr; | 24 buff.matchBegin = buff.buffptr; |
25 state1(buff); | 25 state1(buff); |
26 } | 26 } |
27 | 27 |
28 void stateMatch(BufferList buff) { | 28 void stateMatch(Buffer buff) { |
29 fwrite(buff.matchBegin,buff.buffptr-buff.matchBegin,1,stdout); | 29 fwrite(buff.matchBegin,buff.buffptr-buff.matchBegin,1,stdout); |
30 puts("\n"); | 30 puts("\n"); |
31 stateSkip(buff); | 31 stateSkip(buff); |
32 } | 32 } |
33 | 33 |
58 if (file_mmap == NULL) { | 58 if (file_mmap == NULL) { |
59 perror(""); | 59 perror(""); |
60 fprintf(stderr,"cannot mmap %s\n",filename); | 60 fprintf(stderr,"cannot mmap %s\n",filename); |
61 } | 61 } |
62 | 62 |
63 BufferList buff; | 63 Buffer buff; |
64 buff.buff = buff.buffptr = buff.matchBegin = file_mmap; | 64 buff.buff = buff.buffptr = buff.matchBegin = file_mmap; |
65 buff.buffend = buff.buff + st_mmap.size; | 65 buff.buffend = buff.buff + st_mmap.size; |
66 stateSkip(buff); | 66 stateSkip(buff); |
67 close(fd); | 67 close(fd); |
68 return 0; | 68 return 0; |