pair functions must use size_t for index, not int

This commit is contained in:
Yuichi Nishiwaki 2014-09-27 17:19:16 +09:00
parent 7350f7e71e
commit 186bad0503
2 changed files with 12 additions and 12 deletions

View File

@ -57,7 +57,7 @@ pic_value pic_list5(pic_state *, pic_value, pic_value, pic_value, pic_value, pic
pic_value pic_list6(pic_state *, pic_value, pic_value, pic_value, pic_value, pic_value, pic_value);
pic_value pic_list7(pic_state *, pic_value, pic_value, pic_value, pic_value, pic_value, pic_value, pic_value);
pic_value pic_list_by_array(pic_state *, int, pic_value *);
pic_value pic_make_list(pic_state *, int, pic_value);
pic_value pic_make_list(pic_state *, size_t, pic_value);
#define pic_for_each(var, list) \
pic_for_each_helper_(var, GENSYM(tmp), list)
@ -69,7 +69,7 @@ pic_value pic_make_list(pic_state *, int, pic_value);
#define pic_push(pic, item, place) (place = pic_cons(pic, item, place))
#define pic_pop(pic, place) (place = pic_cdr(pic, place))
int pic_length(pic_state *, pic_value);
size_t pic_length(pic_state *, pic_value);
pic_value pic_reverse(pic_state *, pic_value);
pic_value pic_append(pic_state *, pic_value, pic_value);
@ -88,9 +88,9 @@ pic_value pic_cadr(pic_state *, pic_value);
pic_value pic_cdar(pic_state *, pic_value);
pic_value pic_cddr(pic_state *, pic_value);
pic_value pic_list_tail(pic_state *, pic_value, int);
pic_value pic_list_ref(pic_state *, pic_value, int);
void pic_list_set(pic_state *, pic_value, int, pic_value);
pic_value pic_list_tail(pic_state *, pic_value, size_t);
pic_value pic_list_ref(pic_state *, pic_value, size_t);
void pic_list_set(pic_state *, pic_value, size_t, pic_value);
pic_value pic_list_copy(pic_state *, pic_value);
#if defined(__cplusplus)

14
pair.c
View File

@ -172,10 +172,10 @@ pic_list_by_array(pic_state *pic, int c, pic_value *vs)
}
pic_value
pic_make_list(pic_state *pic, int k, pic_value fill)
pic_make_list(pic_state *pic, size_t k, pic_value fill)
{
pic_value list;
int i;
size_t i;
list = pic_nil_value();
for (i = 0; i < k; ++i) {
@ -185,10 +185,10 @@ pic_make_list(pic_state *pic, int k, pic_value fill)
return list;
}
int
size_t
pic_length(pic_state *pic, pic_value obj)
{
int c = 0;
size_t c = 0;
if (! pic_list_p(obj)) {
pic_errorf(pic, "length: expected list, but got ~s", obj);
@ -375,7 +375,7 @@ pic_cddr(pic_state *pic, pic_value v)
}
pic_value
pic_list_tail(pic_state *pic, pic_value list, int i)
pic_list_tail(pic_state *pic, pic_value list, size_t i)
{
while (i-- > 0) {
list = pic_cdr(pic, list);
@ -384,13 +384,13 @@ pic_list_tail(pic_state *pic, pic_value list, int i)
}
pic_value
pic_list_ref(pic_state *pic, pic_value list, int i)
pic_list_ref(pic_state *pic, pic_value list, size_t i)
{
return pic_car(pic, pic_list_tail(pic, list, i));
}
void
pic_list_set(pic_state *pic, pic_value list, int i, pic_value obj)
pic_list_set(pic_state *pic, pic_value list, size_t i, pic_value obj)
{
pic_pair_ptr(pic_list_tail(pic, list, i))->car = obj;
}