remove dependencies on pic_state from pic_strlen and pic_strcmp

This commit is contained in:
Yuichi Nishiwaki 2014-02-27 19:42:59 +09:00
parent d427e06831
commit 8e511bc410
2 changed files with 9 additions and 13 deletions

View File

@ -22,13 +22,13 @@ pic_str *pic_str_new(pic_state *, const char * /* nullable */, size_t);
pic_str *pic_str_new_cstr(pic_state *, const char *); pic_str *pic_str_new_cstr(pic_state *, const char *);
pic_str *pic_str_new_fill(pic_state *, size_t, char); pic_str *pic_str_new_fill(pic_state *, size_t, char);
size_t pic_strlen(pic_state *, pic_str *); size_t pic_strlen(pic_str *);
char pic_str_ref(pic_state *, pic_str *, size_t); char pic_str_ref(pic_state *, pic_str *, size_t);
void pic_str_set(pic_state *, pic_str *, size_t, char); void pic_str_set(pic_state *, pic_str *, size_t, char);
pic_str *pic_strcat(pic_state *, pic_str *, pic_str *); pic_str *pic_strcat(pic_state *, pic_str *, pic_str *);
pic_str *pic_substr(pic_state *, pic_str *, size_t, size_t); pic_str *pic_substr(pic_state *, pic_str *, size_t, size_t);
int pic_strcmp(pic_state *, pic_str *, pic_str *); int pic_strcmp(pic_str *, pic_str *);
pic_value pic_format(pic_state *, const char *, ...); pic_value pic_format(pic_state *, const char *, ...);
pic_value pic_vformat(pic_state *, const char *, va_list); pic_value pic_vformat(pic_state *, const char *, va_list);

View File

@ -49,10 +49,8 @@ pic_str_new_fill(pic_state *pic, size_t len, char fill)
} }
size_t size_t
pic_strlen(pic_state *pic, pic_str *str) pic_strlen(pic_str *str)
{ {
UNUSED(pic);
return str->len; return str->len;
} }
@ -104,10 +102,8 @@ pic_substr(pic_state *pic, pic_str *str, size_t s, size_t e)
} }
int int
pic_strcmp(pic_state *pic, pic_str *str1, pic_str *str2) pic_strcmp(pic_str *str1, pic_str *str2)
{ {
UNUSED(pic);
return strcmp(str1->str, str2->str); return strcmp(str1->str, str2->str);
} }
@ -232,7 +228,7 @@ pic_str_string_length(pic_state *pic)
pic_get_args(pic, "s", &str); pic_get_args(pic, "s", &str);
return pic_int_value(pic_strlen(pic, str)); return pic_int_value(pic_strlen(str));
} }
static pic_value static pic_value
@ -277,7 +273,7 @@ pic_str_string_set(pic_state *pic)
if (! pic_str_p(argv[i])) { \ if (! pic_str_p(argv[i])) { \
return pic_false_value(); \ return pic_false_value(); \
} \ } \
if (! (pic_strcmp(pic, pic_str_ptr(argv[i-1]), pic_str_ptr(argv[i])) op 0)) { \ if (! (pic_strcmp(pic_str_ptr(argv[i-1]), pic_str_ptr(argv[i])) op 0)) { \
return pic_false_value(); \ return pic_false_value(); \
} \ } \
} \ } \
@ -302,7 +298,7 @@ pic_str_string_copy(pic_state *pic)
case 1: case 1:
start = 0; start = 0;
case 2: case 2:
end = pic_strlen(pic, str); end = pic_strlen(str);
} }
return pic_obj_value(pic_substr(pic, str, start, end)); return pic_obj_value(pic_substr(pic, str, start, end));
@ -320,7 +316,7 @@ pic_str_string_copy_ip(pic_state *pic)
case 3: case 3:
start = 0; start = 0;
case 4: case 4:
end = pic_strlen(pic, from); end = pic_strlen(from);
} }
while (start < end) { while (start < end) {
@ -361,7 +357,7 @@ pic_str_string_fill_ip(pic_state *pic)
case 1: case 1:
start = 0; start = 0;
case 2: case 2:
end = pic_strlen(pic, str); end = pic_strlen(str);
} }
while (start < end) { while (start < end) {