Unify `else` clause style

parent fbf4089d
...@@ -80,7 +80,8 @@ typedef struct mrb_value { ...@@ -80,7 +80,8 @@ typedef struct mrb_value {
if (v != v) { \ if (v != v) { \
(r).value.ttt = 0x7ff80000; \ (r).value.ttt = 0x7ff80000; \
(r).value.i = 0; \ (r).value.i = 0; \
} else { \ } \
else { \
(r).f = v; \ (r).f = v; \
}} while(0) }} while(0)
......
...@@ -44,7 +44,8 @@ struct RString { ...@@ -44,7 +44,8 @@ struct RString {
#define RSTR_SET_LEN(s, n) do {\ #define RSTR_SET_LEN(s, n) do {\
if (RSTR_EMBED_P(s)) {\ if (RSTR_EMBED_P(s)) {\
RSTR_SET_EMBED_LEN((s),(n));\ RSTR_SET_EMBED_LEN((s),(n));\
} else {\ }\
else {\
s->as.heap.len = (mrb_int)(n);\ s->as.heap.len = (mrb_int)(n);\
}\ }\
} while (0) } while (0)
......
...@@ -31,7 +31,8 @@ check_lineno(mrb_irep_debug_info_file *info_file, uint16_t lineno) ...@@ -31,7 +31,8 @@ check_lineno(mrb_irep_debug_info_file *info_file, uint16_t lineno)
return lineno; return lineno;
} }
} }
} else { }
else {
for (l_idx = 0; l_idx < count; ++l_idx) { for (l_idx = 0; l_idx < count; ++l_idx) {
if (lineno == info_file->lines.flat_map[l_idx].line) { if (lineno == info_file->lines.flat_map[l_idx].line) {
return lineno; return lineno;
...@@ -198,7 +199,8 @@ mrb_debug_set_break_line(mrb_state *mrb, mrb_debug_context *dbg, const char *fil ...@@ -198,7 +199,8 @@ mrb_debug_set_break_line(mrb_state *mrb, mrb_debug_context *dbg, const char *fil
result = check_file_lineno(dbg->root_irep, file, lineno); result = check_file_lineno(dbg->root_irep, file, lineno);
if (result == 0) { if (result == 0) {
return MRB_DEBUG_BREAK_INVALID_FILE; return MRB_DEBUG_BREAK_INVALID_FILE;
}else if (result == MRB_DEBUG_BP_FILE_OK) { }
else if (result == MRB_DEBUG_BP_FILE_OK) {
return MRB_DEBUG_BREAK_INVALID_LINENO; return MRB_DEBUG_BREAK_INVALID_LINENO;
} }
......
...@@ -259,7 +259,8 @@ parse_breakcommand(mrdb_state *mrdb, const char **file, uint32_t *line, char **c ...@@ -259,7 +259,8 @@ parse_breakcommand(mrdb_state *mrdb, const char **file, uint32_t *line, char **c
if ((body = strrchr(args, ':')) == NULL) { if ((body = strrchr(args, ':')) == NULL) {
body = args; body = args;
type = check_bptype(body); type = check_bptype(body);
} else { }
else {
if (body == args) { if (body == args) {
printf(BREAK_ERR_MSG_INVALIDSTR, args); printf(BREAK_ERR_MSG_INVALIDSTR, args);
return MRB_DEBUG_BPTYPE_NONE; return MRB_DEBUG_BPTYPE_NONE;
...@@ -274,7 +275,8 @@ parse_breakcommand(mrdb_state *mrdb, const char **file, uint32_t *line, char **c ...@@ -274,7 +275,8 @@ parse_breakcommand(mrdb_state *mrdb, const char **file, uint32_t *line, char **c
if (l <= 65535) { if (l <= 65535) {
*line = l; *line = l;
*file = (body == args)? mrb_debug_get_filename(dbg->irep, (uint32_t)(dbg->pc - dbg->irep->iseq)): args; *file = (body == args)? mrb_debug_get_filename(dbg->irep, (uint32_t)(dbg->pc - dbg->irep->iseq)): args;
} else { }
else {
puts(BREAK_ERR_MSG_RANGEOVER); puts(BREAK_ERR_MSG_RANGEOVER);
type = MRB_DEBUG_BPTYPE_NONE; type = MRB_DEBUG_BPTYPE_NONE;
} }
...@@ -285,11 +287,13 @@ parse_breakcommand(mrdb_state *mrdb, const char **file, uint32_t *line, char **c ...@@ -285,11 +287,13 @@ parse_breakcommand(mrdb_state *mrdb, const char **file, uint32_t *line, char **c
if (ISUPPER(*body)||ISLOWER(*body)||(*body == '_')) { if (ISUPPER(*body)||ISLOWER(*body)||(*body == '_')) {
*method = body; *method = body;
*cname = NULL; *cname = NULL;
} else { }
else {
printf(BREAK_ERR_MSG_INVALIDMETHOD, args); printf(BREAK_ERR_MSG_INVALIDMETHOD, args);
type = MRB_DEBUG_BPTYPE_NONE; type = MRB_DEBUG_BPTYPE_NONE;
} }
} else { }
else {
if (ISUPPER(*args)) { if (ISUPPER(*args)) {
switch(*body) { switch(*body) {
case '@': case '$': case '?': case '.': case ',': case ':': case '@': case '$': case '?': case '.': case ',': case ':':
...@@ -302,7 +306,8 @@ parse_breakcommand(mrdb_state *mrdb, const char **file, uint32_t *line, char **c ...@@ -302,7 +306,8 @@ parse_breakcommand(mrdb_state *mrdb, const char **file, uint32_t *line, char **c
*cname = args; *cname = args;
break; break;
} }
} else { }
else {
printf(BREAK_ERR_MSG_INVALIDCLASS, args); printf(BREAK_ERR_MSG_INVALIDCLASS, args);
type = MRB_DEBUG_BPTYPE_NONE; type = MRB_DEBUG_BPTYPE_NONE;
} }
...@@ -343,12 +348,15 @@ dbgcmd_break(mrb_state *mrb, mrdb_state *mrdb) ...@@ -343,12 +348,15 @@ dbgcmd_break(mrb_state *mrb, mrdb_state *mrdb)
if (ret >= 0) { if (ret >= 0) {
if (type == MRB_DEBUG_BPTYPE_LINE) { if (type == MRB_DEBUG_BPTYPE_LINE) {
printf(BREAK_SET_MSG_LINE, ret, file, line); printf(BREAK_SET_MSG_LINE, ret, file, line);
} else if ((type == MRB_DEBUG_BPTYPE_METHOD)&&(cname == NULL)) { }
else if ((type == MRB_DEBUG_BPTYPE_METHOD)&&(cname == NULL)) {
printf(BREAK_SET_MSG_METHOD, ret, method); printf(BREAK_SET_MSG_METHOD, ret, method);
} else { }
else {
printf(BREAK_SET_MSG_CLASS_METHOD, ret, cname, method); printf(BREAK_SET_MSG_CLASS_METHOD, ret, cname, method);
} }
} else { }
else {
switch (ret) { switch (ret) {
case MRB_DEBUG_BREAK_INVALID_LINENO: case MRB_DEBUG_BREAK_INVALID_LINENO:
printf(BREAK_ERR_MSG_INVALIDLINENO, line, file); printf(BREAK_ERR_MSG_INVALIDLINENO, line, file);
......
...@@ -13,7 +13,8 @@ dbgcmd_run(mrb_state *mrb, mrdb_state *mrdb) ...@@ -13,7 +13,8 @@ dbgcmd_run(mrb_state *mrb, mrdb_state *mrdb)
if (dbg->xm == DBG_INIT){ if (dbg->xm == DBG_INIT){
dbg->xm = DBG_RUN; dbg->xm = DBG_RUN;
} else { }
else {
dbg->xm = DBG_QUIT; dbg->xm = DBG_QUIT;
if (dbg->xphase == DBG_PHASE_RUNNING){ if (dbg->xphase == DBG_PHASE_RUNNING){
struct RClass *exc; struct RClass *exc;
...@@ -40,7 +41,8 @@ dbgcmd_continue(mrb_state *mrb, mrdb_state *mrdb) ...@@ -40,7 +41,8 @@ dbgcmd_continue(mrb_state *mrb, mrdb_state *mrdb)
if (dbg->xphase == DBG_PHASE_AFTER_RUN){ if (dbg->xphase == DBG_PHASE_AFTER_RUN){
puts("The program is not running."); puts("The program is not running.");
dbg->xm = DBG_QUIT; dbg->xm = DBG_QUIT;
} else { }
else {
dbg->xm = DBG_RUN; dbg->xm = DBG_RUN;
} }
return DBGST_CONTINUE; return DBGST_CONTINUE;
......
...@@ -2445,7 +2445,8 @@ codegen(codegen_scope *s, node *tree, int val) ...@@ -2445,7 +2445,8 @@ codegen(codegen_scope *s, node *tree, int val)
if (p2) { if (p2) {
off = new_lit(s, mrb_str_new_cstr(s->mrb, p2)); off = new_lit(s, mrb_str_new_cstr(s->mrb, p2));
genop(s, MKOP_ABx(OP_STRING, cursp(), off)); genop(s, MKOP_ABx(OP_STRING, cursp(), off));
} else { }
else {
genop(s, MKOP_A(OP_LOADNIL, cursp())); genop(s, MKOP_A(OP_LOADNIL, cursp()));
} }
argc++; argc++;
......
...@@ -4124,12 +4124,14 @@ parse_string(parser_state *p) ...@@ -4124,12 +4124,14 @@ parse_string(parser_state *p)
} }
if (flag > flags) { if (flag > flags) {
dup = strndup(flags, (size_t)(flag - flags)); dup = strndup(flags, (size_t)(flag - flags));
} else { }
else {
dup = NULL; dup = NULL;
} }
if (enc) { if (enc) {
encp = strndup(&enc, 1); encp = strndup(&enc, 1);
} else { }
else {
encp = NULL; encp = NULL;
} }
pylval.nd = new_regx(p, s, dup, encp); pylval.nd = new_regx(p, s, dup, encp);
......
...@@ -750,7 +750,8 @@ retry: ...@@ -750,7 +750,8 @@ retry:
mrb_int tmp_n = len; mrb_int tmp_n = len;
RSTRING(result)->flags &= ~MRB_STR_EMBED_LEN_MASK; RSTRING(result)->flags &= ~MRB_STR_EMBED_LEN_MASK;
RSTRING(result)->flags |= tmp_n << MRB_STR_EMBED_LEN_SHIFT; RSTRING(result)->flags |= tmp_n << MRB_STR_EMBED_LEN_SHIFT;
} else { }
else {
RSTRING(result)->as.heap.len = blen; RSTRING(result)->as.heap.len = blen;
} }
if (flags&(FPREC|FWIDTH)) { if (flags&(FPREC|FWIDTH)) {
......
...@@ -387,7 +387,8 @@ mrb_str_succ_bang(mrb_state *mrb, mrb_value self) ...@@ -387,7 +387,8 @@ mrb_str_succ_bang(mrb_state *mrb, mrb_value self)
if (e < b) { if (e < b) {
e = p + l - 1; e = p + l - 1;
result = mrb_str_new_lit(mrb, ""); result = mrb_str_new_lit(mrb, "");
} else { }
else {
// find leading letter of the ascii/number // find leading letter of the ascii/number
b = e; b = e;
while (b > p) { while (b > p) {
...@@ -405,7 +406,8 @@ mrb_str_succ_bang(mrb_state *mrb, mrb_value self) ...@@ -405,7 +406,8 @@ mrb_str_succ_bang(mrb_state *mrb, mrb_value self)
if (*e == 0xff) { if (*e == 0xff) {
mrb_str_cat_lit(mrb, result, "\x01"); mrb_str_cat_lit(mrb, result, "\x01");
(*e) = 0; (*e) = 0;
} else }
else
(*e)++; (*e)++;
break; break;
} }
...@@ -413,13 +415,16 @@ mrb_str_succ_bang(mrb_state *mrb, mrb_value self) ...@@ -413,13 +415,16 @@ mrb_str_succ_bang(mrb_state *mrb, mrb_value self)
if (*e == '9') { if (*e == '9') {
if (e == b) prepend = "1"; if (e == b) prepend = "1";
*e = '0'; *e = '0';
} else if (*e == 'z') { }
else if (*e == 'z') {
if (e == b) prepend = "a"; if (e == b) prepend = "a";
*e = 'a'; *e = 'a';
} else if (*e == 'Z') { }
else if (*e == 'Z') {
if (e == b) prepend = "A"; if (e == b) prepend = "A";
*e = 'A'; *e = 'A';
} else { }
else {
(*e)++; (*e)++;
break; break;
} }
......
...@@ -17,7 +17,8 @@ ...@@ -17,7 +17,8 @@
double round(double x) { double round(double x) {
if (x >= 0.0) { if (x >= 0.0) {
return (double)((int)(x + 0.5)); return (double)((int)(x + 0.5));
} else { }
else {
return (double)((int)(x - 0.5)); return (double)((int)(x - 0.5));
} }
} }
......
...@@ -191,7 +191,8 @@ exc_output_backtrace(mrb_state *mrb, struct RObject *exc, output_stream_func fun ...@@ -191,7 +191,8 @@ exc_output_backtrace(mrb_state *mrb, struct RObject *exc, output_stream_func fun
lastpc = mrb_obj_iv_get(mrb, exc, mrb_intern_lit(mrb, "lastpc")); lastpc = mrb_obj_iv_get(mrb, exc, mrb_intern_lit(mrb, "lastpc"));
if (mrb_nil_p(lastpc)) { if (mrb_nil_p(lastpc)) {
code = NULL; code = NULL;
} else { }
else {
code = (mrb_code*)mrb_cptr(lastpc); code = (mrb_code*)mrb_cptr(lastpc);
} }
......
...@@ -554,7 +554,8 @@ mrb_get_args(mrb_state *mrb, const char *format, ...) ...@@ -554,7 +554,8 @@ mrb_get_args(mrb_state *mrb, const char *format, ...)
argc = a->len; argc = a->len;
array_argv = TRUE; array_argv = TRUE;
} else { }
else {
array_argv = FALSE; array_argv = FALSE;
} }
...@@ -951,7 +952,8 @@ include_class_new(mrb_state *mrb, struct RClass *m, struct RClass *super) ...@@ -951,7 +952,8 @@ include_class_new(mrb_state *mrb, struct RClass *m, struct RClass *super)
ic->super = super; ic->super = super;
if (m->tt == MRB_TT_ICLASS) { if (m->tt == MRB_TT_ICLASS) {
ic->c = m->c; ic->c = m->c;
} else { }
else {
ic->c = m; ic->c = m;
} }
return ic; return ic;
......
...@@ -19,7 +19,8 @@ get_file(mrb_irep_debug_info *info, uint32_t pc) ...@@ -19,7 +19,8 @@ get_file(mrb_irep_debug_info *info, uint32_t pc)
if (!(pc < (*it)->start_pos)) { if (!(pc < (*it)->start_pos)) {
ret = it + 1; ret = it + 1;
count -= step + 1; count -= step + 1;
} else { count = step; } }
else { count = step; }
} }
--ret; --ret;
...@@ -86,7 +87,8 @@ mrb_debug_get_line(mrb_irep *irep, uint32_t pc) ...@@ -86,7 +87,8 @@ mrb_debug_get_line(mrb_irep *irep, uint32_t pc)
if (!(pc < it->start_pos)) { if (!(pc < it->start_pos)) {
ret = it + 1; ret = it + 1;
count -= step + 1; count -= step + 1;
} else { count = step; } }
else { count = step; }
} }
--ret; --ret;
......
...@@ -407,7 +407,8 @@ write_lineno_record_1(mrb_state *mrb, mrb_irep *irep, uint8_t* bin) ...@@ -407,7 +407,8 @@ write_lineno_record_1(mrb_state *mrb, mrb_irep *irep, uint8_t* bin)
if (irep->filename) { if (irep->filename) {
filename_len = strlen(irep->filename); filename_len = strlen(irep->filename);
} else { }
else {
filename_len = 0; filename_len = 0;
} }
mrb_assert_int_fit(size_t, filename_len, uint16_t, UINT16_MAX); mrb_assert_int_fit(size_t, filename_len, uint16_t, UINT16_MAX);
......
...@@ -944,7 +944,8 @@ lshift(mrb_state *mrb, mrb_int val, mrb_int width) ...@@ -944,7 +944,8 @@ lshift(mrb_state *mrb, mrb_int val, mrb_int width)
(val > (MRB_INT_MAX >> width))) { (val > (MRB_INT_MAX >> width))) {
goto bit_overflow; goto bit_overflow;
} }
} else { }
else {
if ((width > NUMERIC_SHIFT_WIDTH_MAX) || if ((width > NUMERIC_SHIFT_WIDTH_MAX) ||
(val < (MRB_INT_MIN >> width))) { (val < (MRB_INT_MIN >> width))) {
goto bit_overflow; goto bit_overflow;
......
...@@ -292,7 +292,8 @@ mrb_state_atexit(mrb_state *mrb, mrb_atexit_func f) ...@@ -292,7 +292,8 @@ mrb_state_atexit(mrb_state *mrb, mrb_atexit_func f)
stack_size = sizeof(mrb_atexit_func) * (mrb->atexit_stack_len + 1); stack_size = sizeof(mrb_atexit_func) * (mrb->atexit_stack_len + 1);
if (mrb->atexit_stack_len == 0) { if (mrb->atexit_stack_len == 0) {
mrb->atexit_stack = (mrb_atexit_func*)mrb_malloc(mrb, stack_size); mrb->atexit_stack = (mrb_atexit_func*)mrb_malloc(mrb, stack_size);
} else { }
else {
mrb->atexit_stack = (mrb_atexit_func*)mrb_realloc(mrb, mrb->atexit_stack, stack_size); mrb->atexit_stack = (mrb_atexit_func*)mrb_realloc(mrb, mrb->atexit_stack, stack_size);
} }
#endif #endif
......
...@@ -63,7 +63,8 @@ str_new(mrb_state *mrb, const char *p, size_t len) ...@@ -63,7 +63,8 @@ str_new(mrb_state *mrb, const char *p, size_t len)
if (p) { if (p) {
memcpy(s->as.ary, p, len); memcpy(s->as.ary, p, len);
} }
} else { }
else {
if (len >= MRB_INT_MAX) { if (len >= MRB_INT_MAX) {
mrb_raise(mrb, E_ARGUMENT_ERROR, "string size too big"); mrb_raise(mrb, E_ARGUMENT_ERROR, "string size too big");
} }
...@@ -2029,7 +2030,8 @@ mrb_str_split_m(mrb_state *mrb, mrb_value str) ...@@ -2029,7 +2030,8 @@ mrb_str_split_m(mrb_state *mrb, mrb_value str)
if (pat_len > 0) { if (pat_len > 0) {
end = mrb_memsearch(RSTRING_PTR(spat), pat_len, RSTRING_PTR(str)+idx, str_len - idx); end = mrb_memsearch(RSTRING_PTR(spat), pat_len, RSTRING_PTR(str)+idx, str_len - idx);
if (end < 0) break; if (end < 0) break;
} else { }
else {
end = chars2bytes(str, idx, 1); end = chars2bytes(str, idx, 1);
} }
mrb_ary_push(mrb, result, byte_subseq(mrb, str, idx, end)); mrb_ary_push(mrb, result, byte_subseq(mrb, str, idx, end));
...@@ -2852,7 +2854,8 @@ mrb_float_read(const char *string, char **endPtr) ...@@ -2852,7 +2854,8 @@ mrb_float_read(const char *string, char **endPtr)
if (*p == '-') { if (*p == '-') {
sign = TRUE; sign = TRUE;
p += 1; p += 1;
} else { }
else {
if (*p == '+') { if (*p == '+') {
p += 1; p += 1;
} }
...@@ -2888,24 +2891,28 @@ mrb_float_read(const char *string, char **endPtr) ...@@ -2888,24 +2891,28 @@ mrb_float_read(const char *string, char **endPtr)
p -= mantSize; p -= mantSize;
if (decPt < 0) { if (decPt < 0) {
decPt = mantSize; decPt = mantSize;
} else { }
else {
mantSize -= 1; /* One of the digits was the point. */ mantSize -= 1; /* One of the digits was the point. */
} }
if (mantSize > 18) { if (mantSize > 18) {
if (decPt - 18 > 29999) { if (decPt - 18 > 29999) {
fracExp = 29999; fracExp = 29999;
} else { }
else {
fracExp = decPt - 18; fracExp = decPt - 18;
} }
mantSize = 18; mantSize = 18;
} else { }
else {
fracExp = decPt - mantSize; fracExp = decPt - mantSize;
} }
if (mantSize == 0) { if (mantSize == 0) {
fraction = 0.0; fraction = 0.0;
p = string; p = string;
goto done; goto done;
} else { }
else {
int frac1, frac2; int frac1, frac2;
frac1 = 0; frac1 = 0;
for ( ; mantSize > 9; mantSize -= 1) for ( ; mantSize > 9; mantSize -= 1)
...@@ -2942,7 +2949,8 @@ mrb_float_read(const char *string, char **endPtr) ...@@ -2942,7 +2949,8 @@ mrb_float_read(const char *string, char **endPtr)
if (*p == '-') { if (*p == '-') {
expSign = TRUE; expSign = TRUE;
p += 1; p += 1;
} else { }
else {
if (*p == '+') { if (*p == '+') {
p += 1; p += 1;
} }
...@@ -2958,7 +2966,8 @@ mrb_float_read(const char *string, char **endPtr) ...@@ -2958,7 +2966,8 @@ mrb_float_read(const char *string, char **endPtr)
} }
if (expSign) { if (expSign) {
exp = fracExp - exp; exp = fracExp - exp;
} else { }
else {
exp = fracExp + exp; exp = fracExp + exp;
} }
...@@ -2972,7 +2981,8 @@ mrb_float_read(const char *string, char **endPtr) ...@@ -2972,7 +2981,8 @@ mrb_float_read(const char *string, char **endPtr)
if (exp < 0) { if (exp < 0) {
expSign = TRUE; expSign = TRUE;
exp = -exp; exp = -exp;
} else { }
else {
expSign = FALSE; expSign = FALSE;
} }
if (exp > maxExponent) { if (exp > maxExponent) {
...@@ -2987,7 +2997,8 @@ mrb_float_read(const char *string, char **endPtr) ...@@ -2987,7 +2997,8 @@ mrb_float_read(const char *string, char **endPtr)
} }
if (expSign) { if (expSign) {
fraction /= dblExp; fraction /= dblExp;
} else { }
else {
fraction *= dblExp; fraction *= dblExp;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment