508
|
1 #include <stdio.h>
|
|
2 #include <string.h>
|
|
3 #include "Exec.h"
|
|
4 #include "Func.h"
|
|
5
|
|
6 /* これは必須 */
|
|
7 SchedDefineTask(Exec);
|
|
8
|
|
9 static int
|
|
10 run(SchedTask *s, void *rbuf, void *wbuf)
|
|
11 {
|
|
12 char *i_data = (char*)s->get_input(rbuf, 0);
|
|
13 unsigned long long *o_data = (unsigned long long*)s->get_output(wbuf, 0);
|
|
14 int length = s->get_param(0);
|
|
15 int word_flag = s->get_param(1);
|
|
16 int word_num = 0;
|
|
17 int line_num = 0;
|
|
18 int i;
|
|
19
|
|
20 /*先頭の文字まで、飛ぶルーチン*/
|
|
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
|
|
32 word_flag = 0;
|
|
33
|
|
34 for (; i < length; i++) {
|
|
35
|
|
36 //s->printf("[SPE%d]%c",id,i_data[i]);
|
|
37
|
|
38
|
|
39 if (i_data[i] == 0x20) {
|
|
40 //s->printf("スペース\n");
|
|
41 word_flag = 1;
|
|
42 }
|
|
43
|
|
44 else if (i_data[i] == 0x0A) {
|
|
45 //s->printf("改行\n");
|
|
46 line_num += 1;
|
|
47 word_flag = 1;
|
|
48 }
|
|
49
|
|
50 else {
|
|
51 word_num += word_flag;
|
|
52 word_flag = 0;
|
|
53 }
|
|
54
|
|
55 }
|
|
56
|
|
57 word_num += word_flag;
|
|
58
|
|
59 //s->printf("%d %d\n",word_num,line_num);
|
|
60
|
|
61 o_data[0] = (unsigned long long)word_num;
|
|
62 o_data[1] = (unsigned long long)line_num;
|
|
63
|
|
64 return 0;
|
|
65 }
|