Mercurial > hg > Applications > Grep
view 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 |
line wrap: on
line source
#include <stdio.h> #include <string.h> #include "Print.h" #include "Func.h" #include "FileMapReduce.h" #include "regexParser.h" #define STATUS_NUM 2 /* これは必須 */ SchedDefineTask1(Print,run_print); static int run_print(SchedTask *s, void *rbuf, void *wbuf) { MapReduce *w = (MapReduce*)s->get_input(0); int out_size = w->division_out_size / sizeof(unsigned long long); int out_task_num = w->task_num; ResultPtr prev = NULL; for (int i = 0; i < out_task_num ; i++) { ResultPtr r = (ResultPtr)w->o_data[i*out_size+0]; StatePtr blockEnd = (StatePtr)w->o_data[i*out_size+2]; StatePtr blockBegin = (StatePtr)w->o_data[i*out_size+4]; // next Block's blockBegin. if (prev && i != out_task_num-1) { // 最後のブロックでなく、前の blockEnd が state 1 でない場合) if ((blockBegin->bitState.bitContainer & ~blockEnd->bitState.bitContainer)==0) { // 前のブロックの matchBegin から最初 result の end までがマッチ fwrite(prev->begin,r->end - prev->begin,1,stdout); } r = r->next; } for (;r;r = r->next) { if (r->end == NULL) { prev = r; break; } fwrite(r->begin,r->end - r->begin,1,stdout); puts("\n"); } } return 0; }