Mercurial > hg > Applications > Grep
annotate regexParser/cerium/ppe/Print.cc @ 275:8879eb8c64a8
remove segmentation fault
author | Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Sat, 30 Jan 2016 19:06:41 +0900 |
parents | 5aa9d01926f1 |
children | 6cc1d9779f45 |
rev | line source |
---|---|
266 | 1 #include <stdio.h> |
2 #include <string.h> | |
3 #include "Print.h" | |
4 #include "Func.h" | |
5 #include "FileMapReduce.h" | |
272 | 6 #include "regexParser.h" |
266 | 7 |
8 #define STATUS_NUM 2 | |
9 /* これは必須 */ | |
10 SchedDefineTask1(Print,run_print); | |
11 | |
12 static int | |
13 run_print(SchedTask *s, void *rbuf, void *wbuf) | |
14 { | |
15 MapReduce *w = (MapReduce*)s->get_input(0); | |
16 | |
17 int out_size = w->division_out_size / sizeof(unsigned long long); | |
272 | 18 int out_task_num = w->task_num; |
266 | 19 ResultPtr prev = NULL; |
20 for (int i = 0; i < out_task_num ; i++) { | |
275
8879eb8c64a8
remove segmentation fault
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
272
diff
changeset
|
21 ResultPtr r = (ResultPtr)w->o_data[i*out_size+0]; |
8879eb8c64a8
remove segmentation fault
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
272
diff
changeset
|
22 StatePtr blockEnd = (StatePtr)w->o_data[i*out_size+2]; |
8879eb8c64a8
remove segmentation fault
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
272
diff
changeset
|
23 StatePtr blockBegin = (StatePtr)w->o_data[i*out_size+4]; // next Block's blockBegin. |
266 | 24 if (prev && i != out_task_num-1) { |
25 // 最後のブロックでなく、前の blockEnd が state 1 でない場合) | |
272 | 26 if ((blockBegin->bitState.bitContainer & ~blockEnd->bitState.bitContainer)==0) { |
266 | 27 // 前のブロックの matchBegin から最初 result の end までがマッチ |
272 | 28 fwrite(prev->begin,r->end - prev->begin,1,stdout); |
266 | 29 } |
30 r = r->next; | |
31 } | |
32 for (;r;r = r->next) { | |
33 if (r->end == NULL) { | |
34 prev = r; | |
35 break; | |
36 } | |
37 fwrite(r->begin,r->end - r->begin,1,stdout); | |
38 puts("\n"); | |
39 } | |
40 } | |
41 return 0; | |
42 } |