666
|
1 #include <stdio.h>
|
|
2 #include <string.h>
|
|
3 #include "Exec.h"
|
|
4 #include "Func.h"
|
|
5
|
|
6 /* これは必須 */
|
|
7 SchedDefineTask(Exec);
|
|
8
|
|
9 // typedef char *cvector __attribute__ ((vector_size (16)));
|
|
10 typedef char *cvector;
|
|
11
|
|
12 static int
|
|
13 run(SchedTask *s, void *rbuf, void *wbuf)
|
|
14 {
|
|
15 cvector i_data ;
|
|
16 i_data = (cvector)s->get_input(rbuf, 0);
|
|
17 unsigned long long *o_data = (unsigned long long*)s->get_output(wbuf, 0);
|
|
18 int length = (long)s->get_param(0);
|
|
19 int word_flag = 1-(long)s->get_param(1);
|
|
20 int word_num = 0;
|
|
21 int line_num = 0;
|
|
22 int i;
|
|
23 static char spaces[] = {0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20};
|
|
24 cvector space = (cvector)spaces;
|
|
25 static char newlines []= {0x0a,0x0a,0x0a,0x0a,0x0a,0x0a,0x0a,0x0a,0x0a,0x0a,0x0a,0x0a,0x0a,0x0a,0x0a,0x0a};
|
|
26 cvector newline = (cvector)newlines;
|
|
27
|
|
28 // word_flag ==1 not in a word
|
|
29 word_num -= word_flag;
|
|
30
|
|
31 for (; i < length; i++) {
|
|
32
|
|
33 //s->printf("[SPE%d]%c",id,i_data[i]);
|
|
34
|
|
35
|
|
36 if (i_data[i] == space[i%16]) {
|
|
37 //s->printf("スペース\n");
|
|
38 word_flag = 1;
|
|
39 }
|
|
40
|
|
41 else if (i_data[i] == newline[i%16]) {
|
|
42 //s->printf("改行\n");
|
|
43 line_num += 1;
|
|
44 word_flag = 1;
|
|
45 }
|
|
46
|
|
47 else {
|
|
48 word_num += word_flag;
|
|
49 word_flag = 0;
|
|
50 }
|
|
51
|
|
52 }
|
|
53
|
|
54 word_num += word_flag;
|
|
55
|
|
56 //s->printf("%d %d\n",word_num,line_num);
|
|
57
|
|
58 o_data[0] = (unsigned long long)word_num;
|
|
59 o_data[1] = (unsigned long long)line_num;
|
|
60
|
|
61 return 0;
|
|
62 }
|