mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
put spaces after if/while
This commit is contained in:
@@ -156,7 +156,7 @@ usage(const char *name)
|
||||
const char *const *p = usage_msg;
|
||||
|
||||
printf("Usage: %s [switches]\n", name);
|
||||
while(*p)
|
||||
while (*p)
|
||||
printf(" %s\n", *p++);
|
||||
}
|
||||
|
||||
@@ -281,7 +281,7 @@ main(int argc, char **argv)
|
||||
last_code_line[char_index] = '\0';
|
||||
#else
|
||||
char* line = readline(code_block_open ? "* " : "> ");
|
||||
if(line == NULL) {
|
||||
if (line == NULL) {
|
||||
printf("\n");
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ usage(const char *name)
|
||||
const char *const *p = usage_msg;
|
||||
|
||||
printf("Usage: %s [switches] programfile\n", name);
|
||||
while(*p)
|
||||
while (*p)
|
||||
printf(" %s\n", *p++);
|
||||
}
|
||||
|
||||
|
||||
+10
-10
@@ -104,7 +104,7 @@ ary_fill_with_nil(mrb_value *ptr, mrb_int size)
|
||||
{
|
||||
mrb_value nil = mrb_nil_value();
|
||||
|
||||
while((int)(size--)) {
|
||||
while ((int)(size--)) {
|
||||
*ptr++ = nil;
|
||||
}
|
||||
}
|
||||
@@ -166,7 +166,7 @@ ary_expand_capa(mrb_state *mrb, struct RArray *a, mrb_int len)
|
||||
mrb_raise(mrb, E_ARGUMENT_ERROR, "array size too big");
|
||||
}
|
||||
|
||||
while(capa < len) {
|
||||
while (capa < len) {
|
||||
if (capa == 0) {
|
||||
capa = ARY_DEFAULT_LEN;
|
||||
}
|
||||
@@ -180,7 +180,7 @@ ary_expand_capa(mrb_state *mrb, struct RArray *a, mrb_int len)
|
||||
if (capa > a->aux.capa) {
|
||||
mrb_value *expanded_ptr = (mrb_value *)mrb_realloc(mrb, a->ptr, sizeof(mrb_value)*capa);
|
||||
|
||||
if(!expanded_ptr) {
|
||||
if (!expanded_ptr) {
|
||||
mrb_raise(mrb, E_RUNTIME_ERROR, "out of memory");
|
||||
}
|
||||
|
||||
@@ -203,7 +203,7 @@ ary_shrink_capa(mrb_state *mrb, struct RArray *a)
|
||||
capa = ARY_DEFAULT_LEN;
|
||||
break;
|
||||
}
|
||||
} while(capa > a->len * ARY_SHRINK_RATIO);
|
||||
} while (capa > a->len * ARY_SHRINK_RATIO);
|
||||
|
||||
if (capa > a->len && capa < a->aux.capa) {
|
||||
a->aux.capa = capa;
|
||||
@@ -366,7 +366,7 @@ mrb_ary_times(mrb_state *mrb, mrb_value self)
|
||||
ary = mrb_ary_new_capa(mrb, a1->len * times);
|
||||
a2 = mrb_ary_ptr(ary);
|
||||
ptr = a2->ptr;
|
||||
while(times--) {
|
||||
while (times--) {
|
||||
array_copy(ptr, a1->ptr, a1->len);
|
||||
ptr += a1->len;
|
||||
a2->len += a1->len;
|
||||
@@ -387,7 +387,7 @@ mrb_ary_reverse_bang(mrb_state *mrb, mrb_value self)
|
||||
p1 = a->ptr;
|
||||
p2 = a->ptr + a->len - 1;
|
||||
|
||||
while(p1 < p2) {
|
||||
while (p1 < p2) {
|
||||
mrb_value tmp = *p1;
|
||||
*p1++ = *p2;
|
||||
*p2-- = tmp;
|
||||
@@ -410,7 +410,7 @@ mrb_ary_reverse(mrb_state *mrb, mrb_value self)
|
||||
p1 = a->ptr;
|
||||
e = p1 + a->len;
|
||||
p2 = b->ptr + a->len - 1;
|
||||
while(p1 < e) {
|
||||
while (p1 < e) {
|
||||
*p2-- = *p1++;
|
||||
}
|
||||
b->len = a->len;
|
||||
@@ -451,7 +451,7 @@ mrb_ary_push_m(mrb_state *mrb, mrb_value self)
|
||||
int len;
|
||||
|
||||
mrb_get_args(mrb, "*", &argv, &len);
|
||||
while(len--) {
|
||||
while (len--) {
|
||||
mrb_ary_push(mrb, self, *argv++);
|
||||
}
|
||||
|
||||
@@ -492,7 +492,7 @@ mrb_ary_shift(mrb_state *mrb, mrb_value self)
|
||||
mrb_int size = a->len;
|
||||
|
||||
val = *ptr;
|
||||
while((int)(--size)) {
|
||||
while ((int)(--size)) {
|
||||
*ptr = *(ptr+1);
|
||||
++ptr;
|
||||
}
|
||||
@@ -753,7 +753,7 @@ mrb_ary_delete_at(mrb_state *mrb, mrb_value self)
|
||||
|
||||
ptr = a->ptr + index;
|
||||
len = a->len - index;
|
||||
while((int)(--len)) {
|
||||
while ((int)(--len)) {
|
||||
*ptr = *(ptr+1);
|
||||
++ptr;
|
||||
}
|
||||
|
||||
+1
-1
@@ -686,7 +686,7 @@ mrb_include_module(mrb_state *mrb, struct RClass *c, struct RClass *m)
|
||||
struct RClass *p = c, *ic;
|
||||
int superclass_seen = 0;
|
||||
|
||||
while(p) {
|
||||
while (p) {
|
||||
if (c != p && p->tt == MRB_TT_CLASS) {
|
||||
superclass_seen = 1;
|
||||
}
|
||||
|
||||
+8
-8
@@ -320,11 +320,11 @@ get_debug_record_size(mrb_state *mrb, mrb_irep *irep)
|
||||
|
||||
size += sizeof(uint32_t); // record size
|
||||
size += sizeof(uint16_t); // filename size
|
||||
if(irep->filename) {
|
||||
if (irep->filename) {
|
||||
size += strlen(irep->filename); // filename
|
||||
}
|
||||
size += sizeof(uint32_t); // niseq
|
||||
if(irep->lines) {
|
||||
if (irep->lines) {
|
||||
size += sizeof(uint16_t) * irep->ilen; // lineno
|
||||
}
|
||||
|
||||
@@ -340,17 +340,17 @@ write_lineno_record(mrb_state *mrb, mrb_irep *irep, uint8_t* bin)
|
||||
|
||||
cur += sizeof(uint32_t); /* record size */
|
||||
|
||||
if(irep->filename) {
|
||||
if (irep->filename) {
|
||||
filename_len = strlen(irep->filename);
|
||||
}
|
||||
cur += uint16_to_bin(filename_len, cur); /* filename size */
|
||||
|
||||
if(filename_len) {
|
||||
if (filename_len) {
|
||||
memcpy(cur, irep->filename, filename_len);
|
||||
cur += filename_len; /* filename */
|
||||
}
|
||||
|
||||
if(irep->lines) {
|
||||
if (irep->lines) {
|
||||
cur += uint32_to_bin(irep->ilen, cur); /* niseq */
|
||||
for (iseq_no = 0; iseq_no < irep->ilen; iseq_no++) {
|
||||
cur += uint16_to_bin(irep->lines[iseq_no], cur); /* opcode */
|
||||
@@ -432,7 +432,7 @@ mrb_dump_irep(mrb_state *mrb, size_t start_index, int debug_info, uint8_t **bin,
|
||||
section_size += section_irep_size;
|
||||
|
||||
/* DEBUG section size */
|
||||
if(debug_info) {
|
||||
if (debug_info) {
|
||||
section_lineno_size += sizeof(struct rite_section_lineno_header);
|
||||
for (irep_no = start_index; irep_no < mrb->irep_len; irep_no++) {
|
||||
section_lineno_size += get_debug_record_size(mrb, mrb->irep[irep_no]);
|
||||
@@ -442,7 +442,7 @@ mrb_dump_irep(mrb_state *mrb, size_t start_index, int debug_info, uint8_t **bin,
|
||||
|
||||
*bin_size += sizeof(struct rite_binary_header) + section_size + sizeof(struct rite_binary_footer);
|
||||
cur = *bin = (uint8_t *)mrb_malloc(mrb, *bin_size);
|
||||
if(cur == NULL) {
|
||||
if (cur == NULL) {
|
||||
goto error_exit;
|
||||
}
|
||||
|
||||
@@ -456,7 +456,7 @@ mrb_dump_irep(mrb_state *mrb, size_t start_index, int debug_info, uint8_t **bin,
|
||||
cur += section_irep_size;
|
||||
|
||||
/* write DEBUG section */
|
||||
if(debug_info) {
|
||||
if (debug_info) {
|
||||
result = mrb_write_section_lineno(mrb, start_index, cur);
|
||||
if (result != MRB_DUMP_OK) {
|
||||
goto error_exit;
|
||||
|
||||
+17
-17
@@ -271,11 +271,11 @@ read_rite_binary_header(const uint8_t *bin, size_t *bin_size, uint16_t *crc)
|
||||
{
|
||||
const struct rite_binary_header *header = (const struct rite_binary_header *)bin;
|
||||
|
||||
if(memcmp(header->binary_identify, RITE_BINARY_IDENFIFIER, sizeof(header->binary_identify)) != 0) {
|
||||
if (memcmp(header->binary_identify, RITE_BINARY_IDENFIFIER, sizeof(header->binary_identify)) != 0) {
|
||||
return MRB_DUMP_INVALID_FILE_HEADER;
|
||||
}
|
||||
|
||||
if(memcmp(header->binary_version, RITE_BINARY_FORMAT_VER, sizeof(header->binary_version)) != 0) {
|
||||
if (memcmp(header->binary_version, RITE_BINARY_FORMAT_VER, sizeof(header->binary_version)) != 0) {
|
||||
return MRB_DUMP_INVALID_FILE_HEADER;
|
||||
}
|
||||
|
||||
@@ -303,12 +303,12 @@ mrb_read_irep(mrb_state *mrb, const uint8_t *bin)
|
||||
}
|
||||
|
||||
result = read_rite_binary_header(bin, &bin_size, &crc);
|
||||
if(result != MRB_DUMP_OK) {
|
||||
if (result != MRB_DUMP_OK) {
|
||||
return result;
|
||||
}
|
||||
|
||||
n = offset_crc_body();
|
||||
if(crc != calc_crc_16_ccitt(bin + n, bin_size - n, 0)) {
|
||||
if (crc != calc_crc_16_ccitt(bin + n, bin_size - n, 0)) {
|
||||
return MRB_DUMP_INVALID_FILE_HEADER;
|
||||
}
|
||||
|
||||
@@ -317,21 +317,21 @@ mrb_read_irep(mrb_state *mrb, const uint8_t *bin)
|
||||
|
||||
do {
|
||||
section_header = (const struct rite_section_header *)bin;
|
||||
if(memcmp(section_header->section_identify, RITE_SECTION_IREP_IDENTIFIER, sizeof(section_header->section_identify)) == 0) {
|
||||
if (memcmp(section_header->section_identify, RITE_SECTION_IREP_IDENTIFIER, sizeof(section_header->section_identify)) == 0) {
|
||||
result = read_rite_section_irep(mrb, bin);
|
||||
if(result < MRB_DUMP_OK) {
|
||||
if (result < MRB_DUMP_OK) {
|
||||
return result;
|
||||
}
|
||||
total_nirep += result;
|
||||
}
|
||||
else if(memcmp(section_header->section_identify, RITE_SECTION_LIENO_IDENTIFIER, sizeof(section_header->section_identify)) == 0) {
|
||||
else if (memcmp(section_header->section_identify, RITE_SECTION_LIENO_IDENTIFIER, sizeof(section_header->section_identify)) == 0) {
|
||||
result = read_rite_section_lineno(mrb, bin, sirep);
|
||||
if(result < MRB_DUMP_OK) {
|
||||
if (result < MRB_DUMP_OK) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
bin += bin_to_uint32(section_header->section_size);
|
||||
} while(memcmp(section_header->section_identify, RITE_BINARY_EOF, sizeof(section_header->section_identify)) != 0);
|
||||
} while (memcmp(section_header->section_identify, RITE_BINARY_EOF, sizeof(section_header->section_identify)) != 0);
|
||||
|
||||
return total_nirep;
|
||||
}
|
||||
@@ -509,7 +509,7 @@ mrb_read_irep_file(mrb_state *mrb, FILE* fp)
|
||||
}
|
||||
result = read_rite_binary_header(buf, NULL, &crc);
|
||||
mrb_free(mrb, buf);
|
||||
if(result != MRB_DUMP_OK) {
|
||||
if (result != MRB_DUMP_OK) {
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -517,14 +517,14 @@ mrb_read_irep_file(mrb_state *mrb, FILE* fp)
|
||||
fpos = ftell(fp);
|
||||
buf = mrb_malloc(mrb, block_size);
|
||||
fseek(fp, offset_crc_body(), SEEK_SET);
|
||||
while((nbytes = fread(buf, 1, block_size, fp)) > 0) {
|
||||
while ((nbytes = fread(buf, 1, block_size, fp)) > 0) {
|
||||
crcwk = calc_crc_16_ccitt(buf, nbytes, crcwk);
|
||||
}
|
||||
mrb_free(mrb, buf);
|
||||
if (nbytes == 0 && ferror(fp)) {
|
||||
return MRB_DUMP_READ_FAULT;
|
||||
}
|
||||
if(crcwk != crc) {
|
||||
if (crcwk != crc) {
|
||||
return MRB_DUMP_INVALID_FILE_HEADER;
|
||||
}
|
||||
fseek(fp, fpos + section_size, SEEK_SET);
|
||||
@@ -538,24 +538,24 @@ mrb_read_irep_file(mrb_state *mrb, FILE* fp)
|
||||
}
|
||||
section_size = bin_to_uint32(section_header.section_size);
|
||||
|
||||
if(memcmp(section_header.section_identify, RITE_SECTION_IREP_IDENTIFIER, sizeof(section_header.section_identify)) == 0) {
|
||||
if (memcmp(section_header.section_identify, RITE_SECTION_IREP_IDENTIFIER, sizeof(section_header.section_identify)) == 0) {
|
||||
fseek(fp, fpos, SEEK_SET);
|
||||
result = read_rite_section_irep_file(mrb, fp);
|
||||
if(result < MRB_DUMP_OK) {
|
||||
if (result < MRB_DUMP_OK) {
|
||||
return result;
|
||||
}
|
||||
total_nirep += result;
|
||||
}
|
||||
else if(memcmp(section_header.section_identify, RITE_SECTION_LIENO_IDENTIFIER, sizeof(section_header.section_identify)) == 0) {
|
||||
else if (memcmp(section_header.section_identify, RITE_SECTION_LIENO_IDENTIFIER, sizeof(section_header.section_identify)) == 0) {
|
||||
fseek(fp, fpos, SEEK_SET);
|
||||
result = read_rite_section_lineno_file(mrb, fp, sirep);
|
||||
if(result < MRB_DUMP_OK) {
|
||||
if (result < MRB_DUMP_OK) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
fseek(fp, fpos + section_size, SEEK_SET);
|
||||
} while(memcmp(section_header.section_identify, RITE_BINARY_EOF, sizeof(section_header.section_identify)) != 0);
|
||||
} while (memcmp(section_header.section_identify, RITE_BINARY_EOF, sizeof(section_header.section_identify)) != 0);
|
||||
|
||||
return total_nirep;
|
||||
}
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ static mrb_value mrb_str_subseq(mrb_state *mrb, mrb_value str, mrb_int beg, mrb_
|
||||
#define RESIZE_CAPA(s,capacity) do {\
|
||||
s->ptr = (char *)mrb_realloc(mrb, s->ptr, (capacity)+1);\
|
||||
s->aux.capa = capacity;\
|
||||
} while (0)
|
||||
} while(0)
|
||||
|
||||
void
|
||||
mrb_str_decref(mrb_state *mrb, mrb_shared_string *shared)
|
||||
|
||||
@@ -63,7 +63,7 @@ stack_clear(mrb_value *from, size_t count)
|
||||
{
|
||||
const mrb_value mrb_value_zero = { { 0 } };
|
||||
|
||||
while(count-- > 0) {
|
||||
while (count-- > 0) {
|
||||
*from++ = mrb_value_zero;
|
||||
}
|
||||
}
|
||||
@@ -1659,7 +1659,7 @@ mrb_run(mrb_state *mrb, struct RProc *proc, mrb_value self)
|
||||
default:\
|
||||
goto L_SEND;\
|
||||
}\
|
||||
} while (0)
|
||||
} while(0)
|
||||
|
||||
CASE(OP_EQ) {
|
||||
/* A B C R(A) := R(A)<R(A+1) (Syms[B]=:==,C=1)*/
|
||||
|
||||
@@ -59,18 +59,18 @@ MRuby.each_target do
|
||||
|
||||
%w(ok_test ko_test kill_test).each do |vname|
|
||||
f.puts %Q[ val2 = mrb_gv_get(mrb2, mrb_intern(mrb2, "$#{vname}"));]
|
||||
f.puts %Q[ if(mrb_fixnum_p(val2)) {]
|
||||
f.puts %Q[ if (mrb_fixnum_p(val2)) {]
|
||||
f.puts %Q[ val1 = mrb_gv_get(mrb, mrb_intern(mrb, "$#{vname}"));]
|
||||
f.puts %Q[ mrb_gv_set(mrb, mrb_intern(mrb, "$#{vname}"), mrb_fixnum_value(mrb_fixnum(val1) + mrb_fixnum(val2)));]
|
||||
f.puts %Q[ }\n]
|
||||
end
|
||||
|
||||
f.puts %Q[ ary2 = mrb_gv_get(mrb2, mrb_intern(mrb2, "$asserts"));]
|
||||
f.puts %Q[ if(mrb_test(ary2)) {]
|
||||
f.puts %Q[ if (mrb_test(ary2)) {]
|
||||
f.puts %Q[ ary1 = mrb_gv_get(mrb, mrb_intern(mrb, "$asserts"));]
|
||||
f.puts %Q[ val2 = mrb_ary_shift(mrb2, ary2);]
|
||||
f.puts %Q[ ]
|
||||
f.puts %Q[ while(mrb_test(val2)) {]
|
||||
f.puts %Q[ while (mrb_test(val2)) {]
|
||||
f.puts %Q[ char *str = mrb_string_value_cstr(mrb2, &val2);]
|
||||
f.puts %Q[ mrb_ary_push(mrb, ary1, mrb_str_new_cstr(mrb, str));]
|
||||
f.puts %Q[ val2 = mrb_ary_shift(mrb2, ary2);]
|
||||
|
||||
+2
-2
@@ -43,7 +43,7 @@ usage(const char *name)
|
||||
const char *const *p = usage_msg;
|
||||
|
||||
printf("Usage: %s [switches] programfile\n", name);
|
||||
while(*p)
|
||||
while (*p)
|
||||
printf(" %s\n", *p++);
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ parse_args(mrb_state *mrb, int argc, char **argv, struct _args *args)
|
||||
args->check_syntax = 1;
|
||||
break;
|
||||
case 'v':
|
||||
if(!args->verbose) mrb_show_version(mrb);
|
||||
if (!args->verbose) mrb_show_version(mrb);
|
||||
args->verbose = 1;
|
||||
break;
|
||||
case 'g':
|
||||
|
||||
Reference in New Issue
Block a user