Mercurial > hg > Game > Cerium
changeset 1603:44ff9443cc1c draft
Display match lines.
author | Masa <e085726@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 09 Apr 2013 17:17:57 +0900 |
parents | e33e106ca3e0 |
children | e6855e99bdde |
files | example/regex_mas/ppe/Exec.cc |
diffstat | 1 files changed, 41 insertions(+), 25 deletions(-) [+] |
line wrap: on
line diff
--- a/example/regex_mas/ppe/Exec.cc Sat Apr 06 17:27:30 2013 +0900 +++ b/example/regex_mas/ppe/Exec.cc Tue Apr 09 17:17:57 2013 +0900 @@ -3,6 +3,8 @@ #include "Exec.h" #include "Func.h" +#define BUFFER_SIZE 4096 + /* これは必須 */ SchedDefineTask(Exec); @@ -14,42 +16,56 @@ unsigned long long *head_tail_flag = o_data +2; int length = (int)s->get_inputSize(0); int word_num = 0; - int line_num = 0; + int line_num = 1; int i = 0; - bool word_flag = false; - bool line_flag = false; bool word_head_a_flag = false; - - head_tail_flag[0] = (i_data[0] != 0x20) && (i_data[0] != 0x0A); - //word_num -= 1-head_tail_flag[0]; - + bool a_flag = 0; + bool match_flag = 0; + char line_data[BUFFER_SIZE]; + int line_i = 0; + //head_tail_flag[0] = (i_data[0] != 0x20) && (i_data[0] != 0x0A); + for (; i < length; i++) { - if (i_data[i] == 0x61) { - word_head_a_flag = true; - } else if ((i_data[i] == 0x62) && (word_head_a_flag == true)){ - word_flag = true; - line_flag = true; - word_head_a_flag = true; - } else if (i_data[i] == 0x20) { //空白 - word_num += word_flag; - word_flag = false; - word_head_a_flag = false; - } else if (i_data[i] == 0x0A) { // 改行 - line_num += line_flag; - word_num += word_flag; - line_flag = false; - word_flag = false; - word_head_a_flag = false; + if (i_data[i] == 0x0A) { + + if (match_flag == true) { + printf("%d : ",line_num); + for (int k = 0; k < line_i; k++) { + printf("%c",line_data[k]); + } + printf("\n"); + } + match_flag = false; + line_i = 0; + line_num++; + //output_line_data(line_num); + } else { + //input_line_data(i_data[i]); + line_data[line_i] = i_data[i]; + line_i++; + if (i_data[i] == 0x61) { + a_flag = true; + }else if ((i_data[i] == 0x62) && (a_flag == true)) { + match_flag = true; + }else if (i_data[i] == 0x20) { + a_flag = false; + } } } - + //head_tail_flag[1] = (i_data[i-1] != 0x20) && (i_data[i-1] != 0x0A); head_tail_flag[1] = (word_head_a_flag == true); - s->printf("SPE include 'a*b' %d lines. %d words. \n",line_num,word_num); o_data[0] = (unsigned long long)word_num; o_data[1] = (unsigned long long)line_num; return 0; } +/* +void input_line_data(char *input_data,char *output_data){ + int i = 0; + char *line_data =; + +} +*/