diff --git a/ext/oj/cache.c b/ext/oj/cache.c index ebaf10d9..131e0b6d 100644 --- a/ext/oj/cache.c +++ b/ext/oj/cache.c @@ -129,7 +129,9 @@ static void rehash(Cache c) { } void cache_free(Cache c) { - for (uint32_t i = 0; i < c->size; i++) { + uint32_t i; + + for (i = 0; i < c->size; i++) { Slot next; Slot s; @@ -147,7 +149,8 @@ void cache_mark(Cache c) { uint32_t i; for (i = 0; i < c->size; i++) { - for (Slot s = c->slots[i]; NULL != s; s = s->next) { + Slot s; + for (s = c->slots[i]; NULL != s; s = s->next) { rb_gc_mark(s->val); } } diff --git a/ext/oj/debug.c b/ext/oj/debug.c index bedcbd66..dc68532c 100644 --- a/ext/oj/debug.c +++ b/ext/oj/debug.c @@ -109,8 +109,9 @@ static void mark(struct _ojParser *p) { void oj_set_parser_debug(ojParser p) { Funcs end = p->funcs + 3; + Funcs f; - for (Funcs f = p->funcs; f < end; f++) { + for (f = p->funcs; f < end; f++) { f->add_null = add_null; f->add_true = add_true; f->add_false = add_false; diff --git a/ext/oj/parser.c b/ext/oj/parser.c index 1fc3ea4e..c723428c 100644 --- a/ext/oj/parser.c +++ b/ext/oj/parser.c @@ -622,14 +622,14 @@ static void big_change(ojParser p) { buf_append_string(&p->buf, buf + len + 1, sizeof(buf) - len - 1); if (0 < p->num.exp) { int x = p->num.exp; - int d; + int d, div; bool started = false; buf_append(&p->buf, 'e'); if (0 < p->num.exp_neg) { buf_append(&p->buf, '-'); } - for (int div = 1000; 0 < div; div /= 10) { + for (div = 1000; 0 < div; div /= 10) { d = x / div % 10; if (started || 0 < d) { buf_append(&p->buf, '0' + d); @@ -646,6 +646,7 @@ static void big_change(ojParser p) { static void parse(ojParser p, const byte *json) { const byte *start; const byte *b = json; + int i; #if DEBUG printf("*** parse - mode: %c %s\n", p->map[256], (const char *)json); @@ -1015,7 +1016,7 @@ static void parse(ojParser p, const byte *json) { } p->ri = 0; *p->token = *b++; - for (int i = 1; i < 4; i++) { + for (i = 1; i < 4; i++) { if ('\0' == *b) { p->ri = i; break; @@ -1040,7 +1041,7 @@ static void parse(ojParser p, const byte *json) { } p->ri = 0; *p->token = *b++; - for (int i = 1; i < 4; i++) { + for (i = 1; i < 4; i++) { if ('\0' == *b) { p->ri = i; break; @@ -1065,7 +1066,7 @@ static void parse(ojParser p, const byte *json) { } p->ri = 0; *p->token = *b++; - for (int i = 1; i < 5; i++) { + for (i = 1; i < 5; i++) { if ('\0' == *b) { p->ri = i; break; diff --git a/ext/oj/saj2.c b/ext/oj/saj2.c index 7fd8d6fe..74c7b6a3 100644 --- a/ext/oj/saj2.c +++ b/ext/oj/saj2.c @@ -182,8 +182,9 @@ static void add_str_key(ojParser p) { static void reset(ojParser p) { Funcs end = p->funcs + 3; + Funcs f; - for (Funcs f = p->funcs; f < end; f++) { + for (f = p->funcs; f < end; f++) { f->add_null = noop; f->add_true = noop; f->add_false = noop; @@ -312,13 +313,14 @@ static void mark(ojParser p) { return; } Delegate d = (Delegate)p->ctx; + VALUE *kp; cache_mark(d->str_cache); if (Qnil != d->handler) { rb_gc_mark(d->handler); } if (!d->cache_keys) { - for (VALUE *kp = d->keys; kp < d->tail; kp++) { + for (kp = d->keys; kp < d->tail; kp++) { rb_gc_mark(*kp); } } diff --git a/ext/oj/usual.c b/ext/oj/usual.c index a836816c..95af4f4f 100644 --- a/ext/oj/usual.c +++ b/ext/oj/usual.c @@ -323,6 +323,7 @@ static void open_array_key(ojParser p) { } static void close_object(ojParser p) { + VALUE *vp; Delegate d = (Delegate)p->ctx; d->ctail--; @@ -333,7 +334,7 @@ static void close_object(ojParser p) { volatile VALUE obj = rb_hash_new(); #if HAVE_RB_HASH_BULK_INSERT - for (VALUE *vp = head; kp < d->ktail; kp++, vp += 2) { + for (vp = head; kp < d->ktail; kp++, vp += 2) { *vp = d->get_key(p, kp); if (sizeof(kp->buf) - 1 < (size_t)kp->len) { xfree(kp->key); @@ -341,7 +342,7 @@ static void close_object(ojParser p) { } rb_hash_bulk_insert(d->vtail - head, head, obj); #else - for (VALUE *vp = head; kp < d->ktail; kp++, vp += 2) { + for (vp = head; kp < d->ktail; kp++, vp += 2) { rb_hash_aset(obj, d->get_key(p, kp), *(vp + 1)); if (sizeof(kp->buf) - 1 < (size_t)kp->len) { xfree(kp->key); @@ -355,6 +356,7 @@ static void close_object(ojParser p) { } static void close_object_class(ojParser p) { + VALUE *vp; Delegate d = (Delegate)p->ctx; d->ctail--; @@ -364,7 +366,7 @@ static void close_object_class(ojParser p) { VALUE * head = d->vhead + c->vi + 1; volatile VALUE obj = rb_class_new_instance(0, NULL, d->hash_class); - for (VALUE *vp = head; kp < d->ktail; kp++, vp += 2) { + for (vp = head; kp < d->ktail; kp++, vp += 2) { rb_funcall(obj, hset_id, 2, d->get_key(p, kp), *(vp + 1)); if (sizeof(kp->buf) - 1 < (size_t)kp->len) { xfree(kp->key); @@ -377,6 +379,7 @@ static void close_object_class(ojParser p) { } static void close_object_create(ojParser p) { + VALUE *vp; Delegate d = (Delegate)p->ctx; d->ctail--; @@ -391,7 +394,7 @@ static void close_object_create(ojParser p) { if (Qnil == d->hash_class) { obj = rb_hash_new(); #if HAVE_RB_HASH_BULK_INSERT - for (VALUE *vp = head; kp < d->ktail; kp++, vp += 2) { + for (vp = head; kp < d->ktail; kp++, vp += 2) { *vp = d->get_key(p, kp); if (sizeof(kp->buf) - 1 < (size_t)kp->len) { xfree(kp->key); @@ -399,7 +402,7 @@ static void close_object_create(ojParser p) { } rb_hash_bulk_insert(d->vtail - head, head, obj); #else - for (VALUE *vp = head; kp < d->ktail; kp++, vp += 2) { + for (vp = head; kp < d->ktail; kp++, vp += 2) { rb_hash_aset(obj, d->get_key(p, kp), *(vp + 1)); if (sizeof(kp->buf) - 1 < (size_t)kp->len) { xfree(kp->key); @@ -408,7 +411,7 @@ static void close_object_create(ojParser p) { #endif } else { obj = rb_class_new_instance(0, NULL, d->hash_class); - for (VALUE *vp = head; kp < d->ktail; kp++, vp += 2) { + for (vp = head; kp < d->ktail; kp++, vp += 2) { rb_funcall(obj, hset_id, 2, d->get_key(p, kp), *(vp + 1)); if (sizeof(kp->buf) - 1 < (size_t)kp->len) { xfree(kp->key); @@ -423,7 +426,7 @@ static void close_object_create(ojParser p) { volatile VALUE arg = rb_hash_new(); #if HAVE_RB_HASH_BULK_INSERT - for (VALUE *vp = head; kp < d->ktail; kp++, vp += 2) { + for (vp = head; kp < d->ktail; kp++, vp += 2) { *vp = d->get_key(p, kp); if (sizeof(kp->buf) - 1 < (size_t)kp->len) { xfree(kp->key); @@ -431,7 +434,7 @@ static void close_object_create(ojParser p) { } rb_hash_bulk_insert(d->vtail - head, head, arg); #else - for (VALUE *vp = head; kp < d->ktail; kp++, vp += 2) { + for (vp = head; kp < d->ktail; kp++, vp += 2) { rb_hash_aset(arg, d->get_key(p, kp), *(vp + 1)); if (sizeof(kp->buf) - 1 < (size_t)kp->len) { xfree(kp->key); @@ -441,7 +444,7 @@ static void close_object_create(ojParser p) { obj = rb_funcall(clas, oj_json_create_id, 1, arg); } else { obj = rb_class_new_instance(0, NULL, clas); - for (VALUE *vp = head; kp < d->ktail; kp++, vp += 2) { + for (vp = head; kp < d->ktail; kp++, vp += 2) { rb_ivar_set(obj, get_attr_id(p, kp), *(vp + 1)); if (sizeof(kp->buf) - 1 < (size_t)kp->len) { xfree(kp->key); @@ -468,13 +471,14 @@ static void close_array(ojParser p) { } static void close_array_class(ojParser p) { + VALUE *vp; Delegate d = (Delegate)p->ctx; d->ctail--; VALUE * head = d->vhead + d->ctail->vi + 1; volatile VALUE a = rb_class_new_instance(0, NULL, d->array_class); - for (VALUE *vp = head; vp < d->vtail; vp++) { + for (vp = head; vp < d->vtail; vp++) { rb_funcall(a, ltlt_id, 1, *vp); } d->vtail = head; @@ -682,6 +686,7 @@ static void mark(ojParser p) { return; } Delegate d = (Delegate)p->ctx; + VALUE *vp; if (NULL == d) { return; @@ -693,7 +698,7 @@ static void mark(ojParser p) { if (NULL != d->class_cache) { cache_mark(d->class_cache); } - for (VALUE *vp = d->vhead; vp < d->vtail; vp++) { + for (vp = d->vhead; vp < d->vtail; vp++) { if (Qundef != *vp) { rb_gc_mark(*vp); } @@ -1091,6 +1096,7 @@ static VALUE opt_symbol_keys_set(ojParser p, VALUE value) { } static VALUE option(ojParser p, const char *key, VALUE value) { + struct opt *op; struct opt opts[] = { {.name = "array_class", .func = opt_array_class}, {.name = "array_class=", .func = opt_array_class_set}, @@ -1119,7 +1125,7 @@ static VALUE option(ojParser p, const char *key, VALUE value) { {.name = NULL}, }; - for (struct opt *op = opts; NULL != op->name; op++) { + for (op = opts; NULL != op->name; op++) { if (0 == strcmp(key, op->name)) { return op->func(p, value); } diff --git a/ext/oj/validate.c b/ext/oj/validate.c index 2fd9e15a..a636b6eb 100644 --- a/ext/oj/validate.c +++ b/ext/oj/validate.c @@ -28,8 +28,9 @@ mark(ojParser p) { void oj_set_parser_validator(ojParser p) { p->ctx = NULL; Funcs end = p->funcs + 3; + Funcs f; - for (Funcs f = p->funcs; f < end; f++) { + for (f = p->funcs; f < end; f++) { f->add_null = noop; f->add_true = noop; f->add_false = noop;