Mercurial > hg > Game > Cerium
diff example/word_count/ppe/Exec.cc @ 666:f02b3338b91b draft
simplify word_count
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 03 Dec 2009 02:11:31 +0900 |
parents | beb0f17c19f9 |
children | 043c98537bc5 |
line wrap: on
line diff
--- a/example/word_count/ppe/Exec.cc Thu Dec 03 01:16:34 2009 +0900 +++ b/example/word_count/ppe/Exec.cc Thu Dec 03 02:11:31 2009 +0900 @@ -12,26 +12,14 @@ char *i_data = (char*)s->get_input(rbuf, 0); unsigned long long *o_data = (unsigned long long*)s->get_output(wbuf, 0); long length = (long)s->get_param(0); - long word_flag = (long)s->get_param(1); + long word_flag = 1-(long)s->get_param(1); int word_num = 0; int line_num = 0; - int i; + int i ; - /*先頭の文字まで、飛ぶルーチン*/ - for(i = 0; i < length; i++) { - if ((i_data[i] != 0x20) && (i_data[i] != 0x0A)) { - //s->printf("[SPE%d] break[%d] %d\n",id,i,i_data[i]); - break; - } - //s->printf("[SPE%d]%c",id,i_data[start_num]); - word_num += word_flag; - word_flag = 0; - line_num += (i_data[i] == 0x0A); - } + word_num -= word_flag; - word_flag = 0; - - for (; i < length; i++) { + for (i=0; i < length; i++) { //s->printf("[SPE%d]%c",id,i_data[i]);