Mercurial > hg > Game > Cerium
comparison 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 |
comparison
equal
deleted
inserted
replaced
665:77d9e3bc25b2 | 666:f02b3338b91b |
---|---|
10 run(SchedTask *s, void *rbuf, void *wbuf) | 10 run(SchedTask *s, void *rbuf, void *wbuf) |
11 { | 11 { |
12 char *i_data = (char*)s->get_input(rbuf, 0); | 12 char *i_data = (char*)s->get_input(rbuf, 0); |
13 unsigned long long *o_data = (unsigned long long*)s->get_output(wbuf, 0); | 13 unsigned long long *o_data = (unsigned long long*)s->get_output(wbuf, 0); |
14 long length = (long)s->get_param(0); | 14 long length = (long)s->get_param(0); |
15 long word_flag = (long)s->get_param(1); | 15 long word_flag = 1-(long)s->get_param(1); |
16 int word_num = 0; | 16 int word_num = 0; |
17 int line_num = 0; | 17 int line_num = 0; |
18 int i; | 18 int i ; |
19 | 19 |
20 /*先頭の文字まで、飛ぶルーチン*/ | 20 word_num -= word_flag; |
21 for(i = 0; i < length; i++) { | |
22 if ((i_data[i] != 0x20) && (i_data[i] != 0x0A)) { | |
23 //s->printf("[SPE%d] break[%d] %d\n",id,i,i_data[i]); | |
24 break; | |
25 } | |
26 //s->printf("[SPE%d]%c",id,i_data[start_num]); | |
27 word_num += word_flag; | |
28 word_flag = 0; | |
29 line_num += (i_data[i] == 0x0A); | |
30 } | |
31 | 21 |
32 word_flag = 0; | 22 for (i=0; i < length; i++) { |
33 | |
34 for (; i < length; i++) { | |
35 | 23 |
36 //s->printf("[SPE%d]%c",id,i_data[i]); | 24 //s->printf("[SPE%d]%c",id,i_data[i]); |
37 | 25 |
38 if((i_data[i] != 0x20) && (i_data[i] != 0x0A)) { | 26 if((i_data[i] != 0x20) && (i_data[i] != 0x0A)) { |
39 //s->printf("文字 数 = %d\n", word_num + word_flag); | 27 //s->printf("文字 数 = %d\n", word_num + word_flag); |