Mercurial > hg > Game > Cerium
changeset 1623:f82467ce38f3 draft
fix regex_mas/ppe/Exec.cc . Convert char to unsigned char.
author | Masa <e085726@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 24 May 2013 09:48:30 +0900 |
parents | 4401690b4513 |
children | c0482a63d811 |
files | example/regex_mas/ppe/Exec.cc |
diffstat | 1 files changed, 7 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/example/regex_mas/ppe/Exec.cc Tue May 21 17:50:12 2013 +0900 +++ b/example/regex_mas/ppe/Exec.cc Fri May 24 09:48:30 2013 +0900 @@ -6,14 +6,13 @@ /* これは必須 */ SchedDefineTask(Exec); //ボイヤームーア法による文字列検索アルゴリズム -int BM_method(char *text,int text_length,char *pattern,unsigned long long *match_string) +int BM_method(unsigned char *text,int text_length,unsigned char *pattern,unsigned long long *match_string) { int skip[256]; - int i,j,text_len,pattern_len; + int text_len = text_length; + int pattern_len = strlen((char *)pattern); + int i = 0; int k = 0; - //text_len = strlen(text); - text_len = text_length; - pattern_len = strlen(pattern); for (i = 0; i < 256; ++i){ skip[i] = pattern_len; @@ -26,7 +25,7 @@ i = pattern_len - 1; while ( i < text_len){ - j = pattern_len - 1; + int j = pattern_len - 1; while (text[i] == pattern[j]){ if (j == 0){ match_string[k] = text[i]; @@ -43,11 +42,11 @@ static int run(SchedTask *s, void *rbuf, void *wbuf) { - char *i_data = (char *)rbuf; + unsigned char *i_data = (unsigned char *)rbuf; unsigned long long *o_data = (unsigned long long*)wbuf; int length = (int)s->get_inputSize(0); // int *offset = (int*)s->get_param(1); - char search_word[] = "ab"; + unsigned char search_word[] = "abcd"; // printf("offset = %d\n",offset); BM_method(i_data,length,search_word,o_data);