summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--include/mruby/boxing_nan.h3
-rw-r--r--include/mruby/string.h3
-rw-r--r--mrbgems/mruby-bin-debugger/tools/mrdb/apibreak.c156
-rw-r--r--mrbgems/mruby-bin-debugger/tools/mrdb/apibreak.h26
-rw-r--r--mrbgems/mruby-bin-debugger/tools/mrdb/cmdbreak.c88
-rw-r--r--mrbgems/mruby-bin-debugger/tools/mrdb/cmdmisc.c2
-rw-r--r--mrbgems/mruby-bin-debugger/tools/mrdb/cmdrun.c14
-rw-r--r--mrbgems/mruby-bin-debugger/tools/mrdb/mrdb.c24
-rw-r--r--mrbgems/mruby-compiler/core/codegen.c3
-rw-r--r--mrbgems/mruby-compiler/core/parse.y6
-rw-r--r--mrbgems/mruby-sprintf/src/sprintf.c3
-rw-r--r--mrbgems/mruby-string-ext/src/string.c15
-rw-r--r--mrbgems/mruby-time/src/time.c3
-rw-r--r--src/backtrace.c3
-rw-r--r--src/class.c8
-rw-r--r--src/debug.c6
-rw-r--r--src/dump.c3
-rw-r--r--src/gc.c1
-rw-r--r--src/numeric.c3
-rw-r--r--src/proc.c1
-rw-r--r--src/state.c3
-rw-r--r--src/string.c33
-rw-r--r--src/vm.c6
23 files changed, 229 insertions, 184 deletions
diff --git a/include/mruby/boxing_nan.h b/include/mruby/boxing_nan.h
index 4cb82bf14..700ea2ed3 100644
--- a/include/mruby/boxing_nan.h
+++ b/include/mruby/boxing_nan.h
@@ -80,7 +80,8 @@ typedef struct mrb_value {
if (v != v) { \
(r).value.ttt = 0x7ff80000; \
(r).value.i = 0; \
- } else { \
+ } \
+ else { \
(r).f = v; \
}} while(0)
diff --git a/include/mruby/string.h b/include/mruby/string.h
index 5a5a6ffd2..b18093218 100644
--- a/include/mruby/string.h
+++ b/include/mruby/string.h
@@ -44,7 +44,8 @@ struct RString {
#define RSTR_SET_LEN(s, n) do {\
if (RSTR_EMBED_P(s)) {\
RSTR_SET_EMBED_LEN((s),(n));\
- } else {\
+ }\
+ else {\
s->as.heap.len = (mrb_int)(n);\
}\
} while (0)
diff --git a/mrbgems/mruby-bin-debugger/tools/mrdb/apibreak.c b/mrbgems/mruby-bin-debugger/tools/mrdb/apibreak.c
index 27f27a05a..4553a965a 100644
--- a/mrbgems/mruby-bin-debugger/tools/mrdb/apibreak.c
+++ b/mrbgems/mruby-bin-debugger/tools/mrdb/apibreak.c
@@ -20,20 +20,21 @@
#define MRB_DEBUG_BP_LINENO_OK (0x0002)
static uint16_t
-check_lineno( mrb_irep_debug_info_file *info_file, uint16_t lineno )
+check_lineno(mrb_irep_debug_info_file *info_file, uint16_t lineno)
{
uint32_t count = info_file->line_entry_count;
uint16_t l_idx;
- if( info_file->line_type == mrb_debug_line_ary ) {
+ if (info_file->line_type == mrb_debug_line_ary) {
for (l_idx = 0; l_idx < count; ++l_idx) {
- if(lineno == info_file->lines.ary[l_idx]) {
+ if (lineno == info_file->lines.ary[l_idx]) {
return lineno;
}
}
- } else {
+ }
+ else {
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;
}
}
@@ -43,21 +44,21 @@ check_lineno( mrb_irep_debug_info_file *info_file, uint16_t lineno )
}
static int32_t
-get_break_index( mrb_debug_context *dbg, uint32_t bpno )
+get_break_index(mrb_debug_context *dbg, uint32_t bpno)
{
uint32_t i;
int32_t index;
char hit = FALSE;
for(i = 0 ; i < dbg->bpnum; i++) {
- if(dbg->bp[i].bpno == bpno) {
+ if (dbg->bp[i].bpno == bpno) {
hit = TRUE;
index = i;
break;
}
}
- if(hit == FALSE) {
+ if (hit == FALSE) {
return MRB_DEBUG_BREAK_INVALID_NO;
}
@@ -65,7 +66,7 @@ get_break_index( mrb_debug_context *dbg, uint32_t bpno )
}
static void
-free_breakpoint( mrb_state *mrb, mrb_debug_breakpoint *bp )
+free_breakpoint(mrb_state *mrb, mrb_debug_breakpoint *bp)
{
switch(bp->type) {
case MRB_DEBUG_BPTYPE_LINE:
@@ -73,7 +74,7 @@ free_breakpoint( mrb_state *mrb, mrb_debug_breakpoint *bp )
break;
case MRB_DEBUG_BPTYPE_METHOD:
mrb_free(mrb, (void*)bp->point.methodpoint.method_name);
- if(bp->point.methodpoint.class_name != NULL) {
+ if (bp->point.methodpoint.class_name != NULL) {
mrb_free(mrb, (void*)bp->point.methodpoint.class_name);
}
break;
@@ -83,7 +84,7 @@ free_breakpoint( mrb_state *mrb, mrb_debug_breakpoint *bp )
}
static uint16_t
-check_file_lineno( struct mrb_irep *irep, const char *file, uint16_t lineno )
+check_file_lineno(struct mrb_irep *irep, const char *file, uint16_t lineno)
{
mrb_irep_debug_info_file *info_file;
uint16_t result = 0;
@@ -93,17 +94,17 @@ check_file_lineno( struct mrb_irep *irep, const char *file, uint16_t lineno )
for (f_idx = 0; f_idx < irep->debug_info->flen; ++f_idx) {
info_file = irep->debug_info->files[f_idx];
- if(!strcmp(info_file->filename, file)) {
+ if (!strcmp(info_file->filename, file)) {
result = MRB_DEBUG_BP_FILE_OK;
- fix_lineno = check_lineno( info_file, lineno );
- if(fix_lineno != 0) {
+ fix_lineno = check_lineno(info_file, lineno);
+ if (fix_lineno != 0) {
return result | MRB_DEBUG_BP_LINENO_OK;
}
}
- for ( i=0; i < irep->rlen; ++i ) {
+ for (i=0; i < irep->rlen; ++i) {
result |= check_file_lineno(irep->reps[i], file, lineno);
- if(result == (MRB_DEBUG_BP_FILE_OK | MRB_DEBUG_BP_LINENO_OK)) {
+ if (result == (MRB_DEBUG_BP_FILE_OK | MRB_DEBUG_BP_LINENO_OK)) {
return result;
}
}
@@ -112,7 +113,7 @@ check_file_lineno( struct mrb_irep *irep, const char *file, uint16_t lineno )
}
static const char*
-get_class_name( mrb_state *mrb, struct RClass *class_obj )
+get_class_name(mrb_state *mrb, struct RClass *class_obj)
{
struct RClass *outer;
mrb_sym class_sym;
@@ -123,7 +124,7 @@ get_class_name( mrb_state *mrb, struct RClass *class_obj )
}
static int32_t
-compare_break_method( mrb_state *mrb, mrb_debug_breakpoint *bp, struct RClass *class_obj, mrb_sym method_sym, mrb_bool* isCfunc )
+compare_break_method(mrb_state *mrb, mrb_debug_breakpoint *bp, struct RClass *class_obj, mrb_sym method_sym, mrb_bool* isCfunc)
{
const char* class_name;
const char* method_name;
@@ -137,37 +138,37 @@ compare_break_method( mrb_state *mrb, mrb_debug_breakpoint *bp, struct RClass *c
method_name = mrb_sym2name(mrb, method_sym);
method_p = &bp->point.methodpoint;
- if(strcmp(method_p->method_name, method_name) == 0) {
+ if (strcmp(method_p->method_name, method_name) == 0) {
class_name = get_class_name(mrb, class_obj);
- if(class_name == NULL) {
- if(method_p->class_name == NULL) {
+ if (class_name == NULL) {
+ if (method_p->class_name == NULL) {
return bp->bpno;
}
}
- else if(method_p->class_name != NULL) {
+ else if (method_p->class_name != NULL) {
m = mrb_method_search_vm(mrb, &class_obj, method_sym);
- if(m == NULL) {
+ if (m == NULL) {
return MRB_DEBUG_OK;
}
- if(MRB_PROC_CFUNC_P(m)) {
+ if (MRB_PROC_CFUNC_P(m)) {
*isCfunc = TRUE;
}
is_defined = mrb_class_defined(mrb, method_p->class_name);
- if(is_defined == FALSE) {
+ if (is_defined == FALSE) {
return MRB_DEBUG_OK;
}
sc = mrb_class_get(mrb, method_p->class_name);
ssym = mrb_symbol(mrb_check_intern_cstr(mrb, method_p->method_name));
m = mrb_method_search_vm(mrb, &sc, ssym);
- if(m == NULL) {
+ if (m == NULL) {
return MRB_DEBUG_OK;
}
class_name = get_class_name(mrb, class_obj);
sn = get_class_name(mrb, sc);
- if(strcmp(sn, class_name) == 0) {
+ if (strcmp(sn, class_name) == 0) {
return bp->bpno;
}
}
@@ -176,29 +177,30 @@ compare_break_method( mrb_state *mrb, mrb_debug_breakpoint *bp, struct RClass *c
}
int32_t
-mrb_debug_set_break_line( mrb_state *mrb, mrb_debug_context *dbg, const char *file, uint16_t lineno)
+mrb_debug_set_break_line(mrb_state *mrb, mrb_debug_context *dbg, const char *file, uint16_t lineno)
{
int32_t index;
char* set_file;
uint16_t result;
- if((mrb == NULL)||(dbg == NULL)||(file == NULL)) {
+ if ((mrb == NULL)||(dbg == NULL)||(file == NULL)) {
return MRB_DEBUG_INVALID_ARGUMENT;
}
- if(dbg->bpnum >= MAX_BREAKPOINT) {
+ if (dbg->bpnum >= MAX_BREAKPOINT) {
return MRB_DEBUG_BREAK_NUM_OVER;
}
- if(dbg->next_bpno > MAX_BREAKPOINTNO) {
+ if (dbg->next_bpno > MAX_BREAKPOINTNO) {
return MRB_DEBUG_BREAK_NO_OVER;
}
/* file and lineno check (line type mrb_debug_line_ary only.) */
- result = check_file_lineno( dbg->root_irep, file, lineno );
- if(result == 0) {
+ result = check_file_lineno(dbg->root_irep, file, lineno);
+ if (result == 0) {
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;
}
@@ -220,25 +222,25 @@ mrb_debug_set_break_line( mrb_state *mrb, mrb_debug_context *dbg, const char *fi
}
int32_t
-mrb_debug_set_break_method( mrb_state *mrb, mrb_debug_context *dbg, const char *class_name, const char *method_name )
+mrb_debug_set_break_method(mrb_state *mrb, mrb_debug_context *dbg, const char *class_name, const char *method_name)
{
int32_t index;
char* set_class;
char* set_method;
- if((mrb == NULL) || (dbg == NULL) || (method_name == NULL)) {
+ if ((mrb == NULL) || (dbg == NULL) || (method_name == NULL)) {
return MRB_DEBUG_INVALID_ARGUMENT;
}
- if(dbg->bpnum >= MAX_BREAKPOINT) {
+ if (dbg->bpnum >= MAX_BREAKPOINT) {
return MRB_DEBUG_BREAK_NUM_OVER;
}
- if(dbg->next_bpno > MAX_BREAKPOINTNO) {
+ if (dbg->next_bpno > MAX_BREAKPOINTNO) {
return MRB_DEBUG_BREAK_NO_OVER;
}
- if(class_name != NULL) {
+ if (class_name != NULL) {
set_class = mrb_malloc(mrb, strlen(class_name) + 1);
strncpy(set_class, class_name, strlen(class_name) + 1);
}
@@ -263,9 +265,9 @@ mrb_debug_set_break_method( mrb_state *mrb, mrb_debug_context *dbg, const char *
}
int32_t
-mrb_debug_get_breaknum( mrb_state *mrb, mrb_debug_context *dbg )
+mrb_debug_get_breaknum(mrb_state *mrb, mrb_debug_context *dbg)
{
- if((mrb == NULL) || (dbg == NULL)) {
+ if ((mrb == NULL) || (dbg == NULL)) {
return MRB_DEBUG_INVALID_ARGUMENT;
}
@@ -273,15 +275,15 @@ mrb_debug_get_breaknum( mrb_state *mrb, mrb_debug_context *dbg )
}
int32_t
-mrb_debug_get_break_all( mrb_state *mrb, mrb_debug_context *dbg, uint32_t size, mrb_debug_breakpoint *bp )
+mrb_debug_get_break_all(mrb_state *mrb, mrb_debug_context *dbg, uint32_t size, mrb_debug_breakpoint *bp)
{
uint32_t get_size = 0;
- if((mrb == NULL) || (dbg == NULL) || (bp == NULL)) {
+ if ((mrb == NULL) || (dbg == NULL) || (bp == NULL)) {
return MRB_DEBUG_INVALID_ARGUMENT;
}
- if(dbg->bpnum >= size) {
+ if (dbg->bpnum >= size) {
get_size = size;
}
else {
@@ -294,16 +296,16 @@ mrb_debug_get_break_all( mrb_state *mrb, mrb_debug_context *dbg, uint32_t size,
}
int32_t
-mrb_debug_get_break( mrb_state *mrb, mrb_debug_context *dbg, uint32_t bpno, mrb_debug_breakpoint *bp )
+mrb_debug_get_break(mrb_state *mrb, mrb_debug_context *dbg, uint32_t bpno, mrb_debug_breakpoint *bp)
{
int32_t index;
- if((mrb == NULL) || (dbg == NULL) || (bp == NULL)) {
+ if ((mrb == NULL) || (dbg == NULL) || (bp == NULL)) {
return MRB_DEBUG_INVALID_ARGUMENT;
}
index = get_break_index(dbg, bpno);
- if(index == MRB_DEBUG_BREAK_INVALID_NO) {
+ if (index == MRB_DEBUG_BREAK_INVALID_NO) {
return MRB_DEBUG_BREAK_INVALID_NO;
}
@@ -316,24 +318,24 @@ mrb_debug_get_break( mrb_state *mrb, mrb_debug_context *dbg, uint32_t bpno, mrb_
}
int32_t
-mrb_debug_delete_break( mrb_state *mrb, mrb_debug_context *dbg, uint32_t bpno )
+mrb_debug_delete_break(mrb_state *mrb, mrb_debug_context *dbg, uint32_t bpno)
{
uint32_t i;
int32_t index;
- if((mrb == NULL) ||(dbg == NULL)) {
+ if ((mrb == NULL) ||(dbg == NULL)) {
return MRB_DEBUG_INVALID_ARGUMENT;
}
index = get_break_index(dbg, bpno);
- if(index == MRB_DEBUG_BREAK_INVALID_NO) {
+ if (index == MRB_DEBUG_BREAK_INVALID_NO) {
return MRB_DEBUG_BREAK_INVALID_NO;
}
free_breakpoint(mrb, &dbg->bp[index]);
for(i = index ; i < dbg->bpnum; i++) {
- if((i + 1) == dbg->bpnum) {
+ if ((i + 1) == dbg->bpnum) {
memset(&dbg->bp[i], 0, sizeof(mrb_debug_breakpoint));
}
else {
@@ -347,11 +349,11 @@ mrb_debug_delete_break( mrb_state *mrb, mrb_debug_context *dbg, uint32_t bpno )
}
int32_t
-mrb_debug_delete_break_all( mrb_state *mrb, mrb_debug_context *dbg )
+mrb_debug_delete_break_all(mrb_state *mrb, mrb_debug_context *dbg)
{
uint32_t i;
- if((mrb == NULL) || (dbg == NULL)) {
+ if ((mrb == NULL) || (dbg == NULL)) {
return MRB_DEBUG_INVALID_ARGUMENT;
}
@@ -365,16 +367,16 @@ mrb_debug_delete_break_all( mrb_state *mrb, mrb_debug_context *dbg )
}
int32_t
-mrb_debug_enable_break( mrb_state *mrb, mrb_debug_context *dbg, uint32_t bpno )
+mrb_debug_enable_break(mrb_state *mrb, mrb_debug_context *dbg, uint32_t bpno)
{
int32_t index = 0;
- if((mrb == NULL) || (dbg == NULL)) {
+ if ((mrb == NULL) || (dbg == NULL)) {
return MRB_DEBUG_INVALID_ARGUMENT;
}
index = get_break_index(dbg, bpno);
- if(index == MRB_DEBUG_BREAK_INVALID_NO) {
+ if (index == MRB_DEBUG_BREAK_INVALID_NO) {
return MRB_DEBUG_BREAK_INVALID_NO;
}
@@ -384,11 +386,11 @@ mrb_debug_enable_break( mrb_state *mrb, mrb_debug_context *dbg, uint32_t bpno )
}
int32_t
-mrb_debug_enable_break_all( mrb_state *mrb, mrb_debug_context *dbg )
+mrb_debug_enable_break_all(mrb_state *mrb, mrb_debug_context *dbg)
{
uint32_t i;
- if((mrb == NULL) || (dbg == NULL)) {
+ if ((mrb == NULL) || (dbg == NULL)) {
return MRB_DEBUG_INVALID_ARGUMENT;
}
@@ -400,16 +402,16 @@ mrb_debug_enable_break_all( mrb_state *mrb, mrb_debug_context *dbg )
}
int32_t
-mrb_debug_disable_break( mrb_state *mrb, mrb_debug_context *dbg, uint32_t bpno )
+mrb_debug_disable_break(mrb_state *mrb, mrb_debug_context *dbg, uint32_t bpno)
{
int32_t index = 0;
- if((mrb == NULL) || (dbg == NULL)) {
+ if ((mrb == NULL) || (dbg == NULL)) {
return MRB_DEBUG_INVALID_ARGUMENT;
}
index = get_break_index(dbg, bpno);
- if(index == MRB_DEBUG_BREAK_INVALID_NO) {
+ if (index == MRB_DEBUG_BREAK_INVALID_NO) {
return MRB_DEBUG_BREAK_INVALID_NO;
}
@@ -419,11 +421,11 @@ mrb_debug_disable_break( mrb_state *mrb, mrb_debug_context *dbg, uint32_t bpno )
}
int32_t
-mrb_debug_disable_break_all( mrb_state *mrb, mrb_debug_context *dbg )
+mrb_debug_disable_break_all(mrb_state *mrb, mrb_debug_context *dbg)
{
uint32_t i;
- if((mrb == NULL) || (dbg == NULL)) {
+ if ((mrb == NULL) || (dbg == NULL)) {
return MRB_DEBUG_INVALID_ARGUMENT;
}
@@ -435,10 +437,10 @@ mrb_debug_disable_break_all( mrb_state *mrb, mrb_debug_context *dbg )
}
static mrb_bool
-check_start_pc_for_line( mrb_irep *irep, mrb_code *pc, uint16_t line )
+check_start_pc_for_line(mrb_irep *irep, mrb_code *pc, uint16_t line)
{
- if( pc > irep->iseq ) {
- if( line == mrb_debug_get_line(irep, (uint32_t)(pc - irep->iseq - 1))) {
+ if (pc > irep->iseq) {
+ if (line == mrb_debug_get_line(irep, (uint32_t)(pc - irep->iseq - 1))) {
return FALSE;
}
}
@@ -446,17 +448,17 @@ check_start_pc_for_line( mrb_irep *irep, mrb_code *pc, uint16_t line )
}
int32_t
-mrb_debug_check_breakpoint_line( mrb_state *mrb, mrb_debug_context *dbg, const char *file, uint16_t line )
+mrb_debug_check_breakpoint_line(mrb_state *mrb, mrb_debug_context *dbg, const char *file, uint16_t line)
{
mrb_debug_breakpoint *bp;
mrb_debug_linepoint *line_p;
uint32_t i;
- if((mrb == NULL) || (dbg == NULL) || (file == NULL) || (line <= 0)) {
+ if ((mrb == NULL) || (dbg == NULL) || (file == NULL) || (line <= 0)) {
return MRB_DEBUG_INVALID_ARGUMENT;
}
- if(!check_start_pc_for_line(dbg->irep, dbg->pc, line)) {
+ if (!check_start_pc_for_line(dbg->irep, dbg->pc, line)) {
return MRB_DEBUG_OK;
}
@@ -464,9 +466,9 @@ mrb_debug_check_breakpoint_line( mrb_state *mrb, mrb_debug_context *dbg, const c
for(i=0; i<dbg->bpnum; i++) {
switch (bp->type) {
case MRB_DEBUG_BPTYPE_LINE:
- if(bp->enable == TRUE) {
+ if (bp->enable == TRUE) {
line_p = &bp->point.linepoint;
- if((strcmp(line_p->file, file) == 0) && (line_p->lineno == line)) {
+ if ((strcmp(line_p->file, file) == 0) && (line_p->lineno == line)) {
return bp->bpno;
}
}
@@ -484,27 +486,27 @@ mrb_debug_check_breakpoint_line( mrb_state *mrb, mrb_debug_context *dbg, const c
int32_t
-mrb_debug_check_breakpoint_method( mrb_state *mrb, mrb_debug_context *dbg, struct RClass *class_obj, mrb_sym method_sym, mrb_bool* isCfunc )
+mrb_debug_check_breakpoint_method(mrb_state *mrb, mrb_debug_context *dbg, struct RClass *class_obj, mrb_sym method_sym, mrb_bool* isCfunc)
{
mrb_debug_breakpoint *bp;
int32_t bpno;
uint32_t i;
- if((mrb == NULL) || (dbg == NULL) || (class_obj == NULL)) {
+ if ((mrb == NULL) || (dbg == NULL) || (class_obj == NULL)) {
return MRB_DEBUG_INVALID_ARGUMENT;
}
bp = dbg->bp;
for(i=0; i<dbg->bpnum; i++) {
- if(bp->type == MRB_DEBUG_BPTYPE_METHOD) {
- if(bp->enable == TRUE) {
+ if (bp->type == MRB_DEBUG_BPTYPE_METHOD) {
+ if (bp->enable == TRUE) {
bpno = compare_break_method(mrb, bp, class_obj, method_sym, isCfunc);
- if(bpno > 0) {
+ if (bpno > 0) {
return bpno;
}
}
}
- else if(bp->type == MRB_DEBUG_BPTYPE_NONE) {
+ else if (bp->type == MRB_DEBUG_BPTYPE_NONE) {
break;
}
bp++;
diff --git a/mrbgems/mruby-bin-debugger/tools/mrdb/apibreak.h b/mrbgems/mruby-bin-debugger/tools/mrdb/apibreak.h
index 3c7e41e52..08f1d8080 100644
--- a/mrbgems/mruby-bin-debugger/tools/mrdb/apibreak.h
+++ b/mrbgems/mruby-bin-debugger/tools/mrdb/apibreak.h
@@ -9,18 +9,18 @@
#include <mruby.h>
#include "mrdb.h"
-int32_t mrb_debug_set_break_line( mrb_state *, mrb_debug_context *, const char *, uint16_t );
-int32_t mrb_debug_set_break_method( mrb_state *, mrb_debug_context *, const char *, const char * );
-int32_t mrb_debug_get_breaknum( mrb_state *, mrb_debug_context * );
-int32_t mrb_debug_get_break_all( mrb_state *, mrb_debug_context *, uint32_t, mrb_debug_breakpoint bp[]);
-int32_t mrb_debug_get_break( mrb_state *, mrb_debug_context *, uint32_t, mrb_debug_breakpoint * );
-int32_t mrb_debug_delete_break( mrb_state *, mrb_debug_context *, uint32_t );
-int32_t mrb_debug_delete_break_all( mrb_state *, mrb_debug_context * );
-int32_t mrb_debug_enable_break( mrb_state *, mrb_debug_context *, uint32_t );
-int32_t mrb_debug_enable_break_all( mrb_state *, mrb_debug_context * );
-int32_t mrb_debug_disable_break( mrb_state *, mrb_debug_context *, uint32_t );
-int32_t mrb_debug_disable_break_all( mrb_state *, mrb_debug_context * );
-int32_t mrb_debug_check_breakpoint_line( mrb_state *, mrb_debug_context *, const char *, uint16_t );
-int32_t mrb_debug_check_breakpoint_method( mrb_state *, mrb_debug_context *, struct RClass *, mrb_sym, mrb_bool* );
+int32_t mrb_debug_set_break_line(mrb_state *, mrb_debug_context *, const char *, uint16_t);
+int32_t mrb_debug_set_break_method(mrb_state *, mrb_debug_context *, const char *, const char *);
+int32_t mrb_debug_get_breaknum(mrb_state *, mrb_debug_context *);
+int32_t mrb_debug_get_break_all(mrb_state *, mrb_debug_context *, uint32_t, mrb_debug_breakpoint bp[]);
+int32_t mrb_debug_get_break(mrb_state *, mrb_debug_context *, uint32_t, mrb_debug_breakpoint *);
+int32_t mrb_debug_delete_break(mrb_state *, mrb_debug_context *, uint32_t);
+int32_t mrb_debug_delete_break_all(mrb_state *, mrb_debug_context *);
+int32_t mrb_debug_enable_break(mrb_state *, mrb_debug_context *, uint32_t);
+int32_t mrb_debug_enable_break_all(mrb_state *, mrb_debug_context *);
+int32_t mrb_debug_disable_break(mrb_state *, mrb_debug_context *, uint32_t);
+int32_t mrb_debug_disable_break_all(mrb_state *, mrb_debug_context *);
+int32_t mrb_debug_check_breakpoint_line(mrb_state *, mrb_debug_context *, const char *, uint16_t);
+int32_t mrb_debug_check_breakpoint_method(mrb_state *, mrb_debug_context *, struct RClass *, mrb_sym, mrb_bool*);
#endif /* APIBREAK_H_ */
diff --git a/mrbgems/mruby-bin-debugger/tools/mrdb/cmdbreak.c b/mrbgems/mruby-bin-debugger/tools/mrdb/cmdbreak.c
index 57c1d5682..6bbe4cfbb 100644
--- a/mrbgems/mruby-bin-debugger/tools/mrdb/cmdbreak.c
+++ b/mrbgems/mruby-bin-debugger/tools/mrdb/cmdbreak.c
@@ -70,12 +70,12 @@ parse_breakpoint_no(char* args)
char* ps = args;
uint32_t l;
- if((*ps == '0')||(strlen(ps) >= BPNO_LETTER_NUM)) {
+ if ((*ps == '0')||(strlen(ps) >= BPNO_LETTER_NUM)) {
return 0;
}
- while( !(ISBLANK(*ps)||ISCNTRL(*ps)) ) {
- if(!ISDIGIT(*ps)) {
+ while (!(ISBLANK(*ps)||ISCNTRL(*ps))) {
+ if (!ISDIGIT(*ps)) {
return 0;
}
ps++;
@@ -90,7 +90,7 @@ exe_set_command_all(mrb_state *mrb, mrdb_state *mrdb, all_command_func func)
{
int32_t ret = MRB_DEBUG_OK;
- if(mrdb->wcnt == 1) {
+ if (mrdb->wcnt == 1) {
ret = func(mrb, mrdb->dbg);
print_api_common_error(ret);
return TRUE;
@@ -109,15 +109,15 @@ exe_set_command_select(mrb_state *mrb, mrdb_state *mrdb, select_command_func fun
for(i=1; i<mrdb->wcnt; i++) {
ps = mrdb->words[i];
bpno = parse_breakpoint_no(ps);
- if(bpno == 0) {
+ if (bpno == 0) {
printf(BREAK_ERR_MSG_INVALIDBPNO, ps);
break;
}
ret = func(mrb, mrdb->dbg, (uint32_t)bpno);
- if(ret == MRB_DEBUG_BREAK_INVALID_NO) {
+ if (ret == MRB_DEBUG_BREAK_INVALID_NO) {
printf(BREAK_ERR_MSG_NOBPNO, bpno);
}
- else if(ret != MRB_DEBUG_OK) {
+ else if (ret != MRB_DEBUG_OK) {
print_api_common_error(ret);
}
}
@@ -128,24 +128,24 @@ check_bptype(char* args)
{
char* ps = args;
- if(ISBLANK(*ps)||ISCNTRL(*ps)) {
+ if (ISBLANK(*ps)||ISCNTRL(*ps)) {
puts(BREAK_ERR_MSG_BLANK);
return MRB_DEBUG_BPTYPE_NONE;
}
- if(!ISDIGIT(*ps)) {
+ if (!ISDIGIT(*ps)) {
return MRB_DEBUG_BPTYPE_METHOD;
}
- while( !(ISBLANK(*ps)||ISCNTRL(*ps)) ) {
- if(!ISDIGIT(*ps)) {
+ while (!(ISBLANK(*ps)||ISCNTRL(*ps))) {
+ if (!ISDIGIT(*ps)) {
printf(BREAK_ERR_MSG_INVALIDSTR, args);
return MRB_DEBUG_BPTYPE_NONE;
}
ps++;
}
- if((*args == '0')||(strlen(args) >= LINENO_MAX_DIGIT)) {
+ if ((*args == '0')||(strlen(args) >= LINENO_MAX_DIGIT)) {
puts(BREAK_ERR_MSG_RANGEOVER);
return MRB_DEBUG_BPTYPE_NONE;
}
@@ -158,12 +158,12 @@ print_breakpoint(mrb_debug_breakpoint *bp)
{
const char* enable_letter[] = {BREAK_INFO_MSG_DISABLE, BREAK_INFO_MSG_ENABLE};
- if(bp->type == MRB_DEBUG_BPTYPE_LINE) {
+ if (bp->type == MRB_DEBUG_BPTYPE_LINE) {
printf(BREAK_INFO_MSG_LINEBREAK,
bp->bpno, enable_letter[bp->enable], bp->point.linepoint.file, bp->point.linepoint.lineno);
}
else {
- if(bp->point.methodpoint.class_name == NULL) {
+ if (bp->point.methodpoint.class_name == NULL) {
printf(BREAK_INFO_MSG_METHODBREAK_NOCLASS,
bp->bpno, enable_letter[bp->enable], bp->point.methodpoint.method_name);
}
@@ -183,18 +183,18 @@ info_break_all(mrb_state *mrb, mrdb_state *mrdb)
mrb_debug_breakpoint *bp_list;
bpnum = mrb_debug_get_breaknum(mrb, mrdb->dbg);
- if(bpnum < 0) {
+ if (bpnum < 0) {
print_api_common_error(bpnum);
return;
}
- else if(bpnum == 0) {
+ else if (bpnum == 0) {
puts(BREAK_ERR_MSG_NOBPNO_INFOALL);
return;
}
bp_list = (mrb_debug_breakpoint*)mrb_malloc(mrb, bpnum * sizeof(mrb_debug_breakpoint));
ret = mrb_debug_get_break_all(mrb, mrdb->dbg, (uint32_t)bpnum, bp_list);
- if(ret < 0) {
+ if (ret < 0) {
print_api_common_error(ret);
return;
}
@@ -219,21 +219,21 @@ info_break_select(mrb_state *mrb, mrdb_state *mrdb)
for(i=2; i<mrdb->wcnt; i++) {
ps = mrdb->words[i];
bpno = parse_breakpoint_no(ps);
- if(bpno == 0) {
+ if (bpno == 0) {
puts(BREAK_ERR_MSG_INVALIDBPNO_INFO);
break;
}
ret = mrb_debug_get_break(mrb, mrdb->dbg, bpno, &bp);
- if(ret == MRB_DEBUG_BREAK_INVALID_NO) {
+ if (ret == MRB_DEBUG_BREAK_INVALID_NO) {
printf(BREAK_ERR_MSG_NOBPNO_INFO, bpno);
break;
}
- else if(ret != MRB_DEBUG_OK) {
+ else if (ret != MRB_DEBUG_OK) {
print_api_common_error(ret);
break;
}
- else if(isFirst == TRUE) {
+ else if (isFirst == TRUE) {
isFirst = FALSE;
puts(BREAK_INFO_MSG_HEADER);
}
@@ -250,17 +250,18 @@ parse_breakcommand(mrdb_state *mrdb, const char **file, uint32_t *line, char **c
mrb_debug_bptype type;
uint32_t l;
- if(mrdb->wcnt <= 1) {
+ if (mrdb->wcnt <= 1) {
puts(BREAK_ERR_MSG_BLANK);
return MRB_DEBUG_BPTYPE_NONE;
}
args = mrdb->words[1];
- if((body = strrchr(args, ':')) == NULL) {
+ if ((body = strrchr(args, ':')) == NULL) {
body = args;
type = check_bptype(body);
- } else {
- if(body == args) {
+ }
+ else {
+ if (body == args) {
printf(BREAK_ERR_MSG_INVALIDSTR, args);
return MRB_DEBUG_BPTYPE_NONE;
}
@@ -271,26 +272,29 @@ parse_breakcommand(mrdb_state *mrdb, const char **file, uint32_t *line, char **c
switch(type) {
case MRB_DEBUG_BPTYPE_LINE:
STRTOUL(l, body);
- if( l <= 65535 ) {
+ if (l <= 65535) {
*line = l;
*file = (body == args)? mrb_debug_get_filename(dbg->irep, (uint32_t)(dbg->pc - dbg->irep->iseq)): args;
- } else {
+ }
+ else {
puts(BREAK_ERR_MSG_RANGEOVER);
type = MRB_DEBUG_BPTYPE_NONE;
}
break;
case MRB_DEBUG_BPTYPE_METHOD:
- if(body == args) {
+ if (body == args) {
/* method only */
- if( ISUPPER(*body)||ISLOWER(*body)||(*body == '_') ) {
+ if (ISUPPER(*body)||ISLOWER(*body)||(*body == '_')) {
*method = body;
*cname = NULL;
- } else {
+ }
+ else {
printf(BREAK_ERR_MSG_INVALIDMETHOD, args);
type = MRB_DEBUG_BPTYPE_NONE;
}
- } else {
- if( ISUPPER(*args) ) {
+ }
+ else {
+ if (ISUPPER(*args)) {
switch(*body) {
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
*cname = args;
break;
}
- } else {
+ }
+ else {
printf(BREAK_ERR_MSG_INVALIDCLASS, args);
type = MRB_DEBUG_BPTYPE_NONE;
}
@@ -343,12 +348,15 @@ dbgcmd_break(mrb_state *mrb, mrdb_state *mrdb)
if (ret >= 0) {
if (type == MRB_DEBUG_BPTYPE_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);
- } else {
+ }
+ else {
printf(BREAK_SET_MSG_CLASS_METHOD, ret, cname, method);
}
- } else {
+ }
+ else {
switch (ret) {
case MRB_DEBUG_BREAK_INVALID_LINENO:
printf(BREAK_ERR_MSG_INVALIDLINENO, line, file);
@@ -379,7 +387,7 @@ dbgcmd_break(mrb_state *mrb, mrdb_state *mrdb)
dbgcmd_state
dbgcmd_info_break(mrb_state *mrb, mrdb_state *mrdb)
{
- if(mrdb->wcnt == 2) {
+ if (mrdb->wcnt == 2) {
info_break_all(mrb, mrdb);
}
else {
@@ -395,7 +403,7 @@ dbgcmd_delete(mrb_state *mrb, mrdb_state *mrdb)
mrb_bool ret = FALSE;
ret = exe_set_command_all(mrb, mrdb, mrb_debug_delete_break_all);
- if(ret != TRUE) {
+ if (ret != TRUE) {
exe_set_command_select(mrb, mrdb, mrb_debug_delete_break);
}
@@ -408,7 +416,7 @@ dbgcmd_enable(mrb_state *mrb, mrdb_state *mrdb)
mrb_bool ret = FALSE;
ret = exe_set_command_all(mrb, mrdb, mrb_debug_enable_break_all);
- if(ret != TRUE) {
+ if (ret != TRUE) {
exe_set_command_select(mrb, mrdb, mrb_debug_enable_break);
}
@@ -421,7 +429,7 @@ dbgcmd_disable(mrb_state *mrb, mrdb_state *mrdb)
mrb_bool ret = FALSE;
ret = exe_set_command_all(mrb, mrdb, mrb_debug_disable_break_all);
- if(ret != TRUE) {
+ if (ret != TRUE) {
exe_set_command_select(mrb, mrdb, mrb_debug_disable_break);
}
return DBGST_PROMPT;
diff --git a/mrbgems/mruby-bin-debugger/tools/mrdb/cmdmisc.c b/mrbgems/mruby-bin-debugger/tools/mrdb/cmdmisc.c
index b4aeb62d4..5984b623b 100644
--- a/mrbgems/mruby-bin-debugger/tools/mrdb/cmdmisc.c
+++ b/mrbgems/mruby-bin-debugger/tools/mrdb/cmdmisc.c
@@ -333,7 +333,7 @@ check_cmd_pattern(const char *pattern, const char *cmd)
if (pattern == NULL || cmd == NULL) {
return FALSE;
}
- if((lbracket = strchr(pattern, '[')) == NULL) {
+ if ((lbracket = strchr(pattern, '[')) == NULL) {
return !strcmp(pattern, cmd);
}
if ((rbracket = strchr(pattern, ']')) == NULL) {
diff --git a/mrbgems/mruby-bin-debugger/tools/mrdb/cmdrun.c b/mrbgems/mruby-bin-debugger/tools/mrdb/cmdrun.c
index 171c6a0f7..cb4c738fc 100644
--- a/mrbgems/mruby-bin-debugger/tools/mrdb/cmdrun.c
+++ b/mrbgems/mruby-bin-debugger/tools/mrdb/cmdrun.c
@@ -11,11 +11,12 @@ dbgcmd_run(mrb_state *mrb, mrdb_state *mrdb)
{
mrb_debug_context *dbg = mrdb->dbg;
- if( dbg->xm == DBG_INIT ){
+ if (dbg->xm == DBG_INIT){
dbg->xm = DBG_RUN;
- } else {
+ }
+ else {
dbg->xm = DBG_QUIT;
- if( dbg->xphase == DBG_PHASE_RUNNING ){
+ if (dbg->xphase == DBG_PHASE_RUNNING){
struct RClass *exc;
puts("Start it from the beginning.");
exc = mrb_define_class(mrb, "DebuggerRestart", mrb_class_get(mrb, "Exception"));
@@ -32,15 +33,16 @@ dbgcmd_continue(mrb_state *mrb, mrdb_state *mrdb)
mrb_debug_context *dbg = mrdb->dbg;
int ccnt = 1;
- if( mrdb->wcnt > 1 ){
+ if (mrdb->wcnt > 1){
sscanf(mrdb->words[1], "%d", &ccnt);
}
dbg->ccnt = (uint16_t)(ccnt > 0 ? ccnt : 1); /* count of continue */
- if( dbg->xphase == DBG_PHASE_AFTER_RUN ){
+ if (dbg->xphase == DBG_PHASE_AFTER_RUN){
puts("The program is not running.");
dbg->xm = DBG_QUIT;
- } else {
+ }
+ else {
dbg->xm = DBG_RUN;
}
return DBGST_CONTINUE;
diff --git a/mrbgems/mruby-bin-debugger/tools/mrdb/mrdb.c b/mrbgems/mruby-bin-debugger/tools/mrdb/mrdb.c
index 04503dcf9..3177d7a75 100644
--- a/mrbgems/mruby-bin-debugger/tools/mrdb/mrdb.c
+++ b/mrbgems/mruby-bin-debugger/tools/mrdb/mrdb.c
@@ -406,7 +406,7 @@ print_info_stopped_break(mrb_state *mrb, mrdb_state *mrdb)
const char *class_name;
ret = mrb_debug_get_break(mrb, mrdb->dbg, mrdb->dbg->stopped_bpno, &bp);
- if(ret == 0) {
+ if (ret == 0) {
switch(bp.type) {
case MRB_DEBUG_BPTYPE_LINE:
file = bp.point.linepoint.file;
@@ -416,13 +416,13 @@ print_info_stopped_break(mrb_state *mrb, mrdb_state *mrdb)
case MRB_DEBUG_BPTYPE_METHOD:
method_name = bp.point.methodpoint.method_name;
class_name = bp.point.methodpoint.class_name;
- if(class_name == NULL) {
+ if (class_name == NULL) {
printf("Breakpoint %d, %s\n", bp.bpno, method_name);
}
else {
printf("Breakpoint %d, %s:%s\n", bp.bpno, class_name, method_name);
}
- if(mrdb->dbg->isCfunc) {
+ if (mrdb->dbg->isCfunc) {
printf("Stopped before calling the C function.\n");
}
break;
@@ -445,7 +445,7 @@ print_info_stopped_code(mrb_state *mrb, mrdb_state *mrdb)
{
char* file = mrb_debug_get_source(mrb, mrdb, mrdb->srcpath, mrdb->dbg->prvfile);
uint16_t lineno = mrdb->dbg->prvline;
- if(file != NULL) {
+ if (file != NULL) {
mrb_debug_list(mrb, mrdb->dbg, file, lineno, lineno);
mrb_free(mrb, file);
}
@@ -531,9 +531,9 @@ check_method_breakpoint(mrb_state *mrb, mrb_irep *irep, mrb_code *pc, mrb_value
sym = 0;
break;
}
- if(sym != 0) {
+ if (sym != 0) {
dbg->method_bpno = mrb_debug_check_breakpoint_method(mrb, dbg, c, sym, &isCfunc);
- if(isCfunc) {
+ if (isCfunc) {
bpno = dbg->method_bpno;
dbg->method_bpno = 0;
}
@@ -557,7 +557,7 @@ mrb_code_fetch_hook(mrb_state *mrb, mrb_irep *irep, mrb_code *pc, mrb_value *reg
dbg->pc = pc;
dbg->regs = regs;
- if(dbg->xphase == DBG_PHASE_RESTART) {
+ if (dbg->xphase == DBG_PHASE_RESTART) {
dbg->root_irep = irep;
dbg->prvfile = NULL;
dbg->prvline = 0;
@@ -582,7 +582,7 @@ mrb_code_fetch_hook(mrb_state *mrb, mrb_irep *irep, mrb_code *pc, mrb_value *reg
if (!file || (dbg->prvfile == file && dbg->prvline == line)) {
return;
}
- if((intptr_t)(dbg->prvci) < (intptr_t)(mrb->c->ci)) {
+ if ((intptr_t)(dbg->prvci) < (intptr_t)(mrb->c->ci)) {
return;
}
dbg->prvci = NULL;
@@ -623,7 +623,7 @@ mrb_code_fetch_hook(mrb_state *mrb, mrb_irep *irep, mrb_code *pc, mrb_value *reg
dbg->prvfile = file;
dbg->prvline = line;
- if(dbg->bm == BRK_BREAK && --dbg->ccnt > 0) {
+ if (dbg->bm == BRK_BREAK && --dbg->ccnt > 0) {
return;
}
dbg->break_hook(mrb, dbg);
@@ -646,7 +646,7 @@ mrb_debug_break_hook(mrb_state *mrb, mrb_debug_context *dbg)
st = cmd->func(mrb, mrdb);
- if( (st == DBGST_CONTINUE) || (st == DBGST_RESTART) ) break;
+ if ((st == DBGST_CONTINUE) || (st == DBGST_RESTART)) break;
}
return dbg->xm;
}
@@ -683,7 +683,7 @@ main(int argc, char **argv)
mrb_assert(mrdb && mrdb->dbg);
mrdb->srcpath = args.srcpath;
- if(mrdb->dbg->xm == DBG_QUIT) {
+ if (mrdb->dbg->xm == DBG_QUIT) {
mrdb->dbg->xphase = DBG_PHASE_RESTART;
}
else {
@@ -750,7 +750,7 @@ main(int argc, char **argv)
break;
}
- if( cmd->func(mrb, mrdb) == DBGST_RESTART ) goto l_restart;
+ if ( cmd->func(mrb, mrdb) == DBGST_RESTART ) goto l_restart;
}
cleanup(mrb, &args);
diff --git a/mrbgems/mruby-compiler/core/codegen.c b/mrbgems/mruby-compiler/core/codegen.c
index 75c42eefb..64f4702a7 100644
--- a/mrbgems/mruby-compiler/core/codegen.c
+++ b/mrbgems/mruby-compiler/core/codegen.c
@@ -2445,7 +2445,8 @@ codegen(codegen_scope *s, node *tree, int val)
if (p2) {
off = new_lit(s, mrb_str_new_cstr(s->mrb, p2));
genop(s, MKOP_ABx(OP_STRING, cursp(), off));
- } else {
+ }
+ else {
genop(s, MKOP_A(OP_LOADNIL, cursp()));
}
argc++;
diff --git a/mrbgems/mruby-compiler/core/parse.y b/mrbgems/mruby-compiler/core/parse.y
index 41984b186..226701b52 100644
--- a/mrbgems/mruby-compiler/core/parse.y
+++ b/mrbgems/mruby-compiler/core/parse.y
@@ -4124,12 +4124,14 @@ parse_string(parser_state *p)
}
if (flag > flags) {
dup = strndup(flags, (size_t)(flag - flags));
- } else {
+ }
+ else {
dup = NULL;
}
if (enc) {
encp = strndup(&enc, 1);
- } else {
+ }
+ else {
encp = NULL;
}
pylval.nd = new_regx(p, s, dup, encp);
diff --git a/mrbgems/mruby-sprintf/src/sprintf.c b/mrbgems/mruby-sprintf/src/sprintf.c
index a7de2a5b8..3d96573a7 100644
--- a/mrbgems/mruby-sprintf/src/sprintf.c
+++ b/mrbgems/mruby-sprintf/src/sprintf.c
@@ -750,7 +750,8 @@ retry:
mrb_int tmp_n = len;
RSTRING(result)->flags &= ~MRB_STR_EMBED_LEN_MASK;
RSTRING(result)->flags |= tmp_n << MRB_STR_EMBED_LEN_SHIFT;
- } else {
+ }
+ else {
RSTRING(result)->as.heap.len = blen;
}
if (flags&(FPREC|FWIDTH)) {
diff --git a/mrbgems/mruby-string-ext/src/string.c b/mrbgems/mruby-string-ext/src/string.c
index 7e87b3db4..402dbf987 100644
--- a/mrbgems/mruby-string-ext/src/string.c
+++ b/mrbgems/mruby-string-ext/src/string.c
@@ -387,7 +387,8 @@ mrb_str_succ_bang(mrb_state *mrb, mrb_value self)
if (e < b) {
e = p + l - 1;
result = mrb_str_new_lit(mrb, "");
- } else {
+ }
+ else {
// find leading letter of the ascii/number
b = e;
while (b > p) {
@@ -405,7 +406,8 @@ mrb_str_succ_bang(mrb_state *mrb, mrb_value self)
if (*e == 0xff) {
mrb_str_cat_lit(mrb, result, "\x01");
(*e) = 0;
- } else
+ }
+ else
(*e)++;
break;
}
@@ -413,13 +415,16 @@ mrb_str_succ_bang(mrb_state *mrb, mrb_value self)
if (*e == '9') {
if (e == b) prepend = "1";
*e = '0';
- } else if (*e == 'z') {
+ }
+ else if (*e == 'z') {
if (e == b) prepend = "a";
*e = 'a';
- } else if (*e == 'Z') {
+ }
+ else if (*e == 'Z') {
if (e == b) prepend = "A";
*e = 'A';
- } else {
+ }
+ else {
(*e)++;
break;
}
diff --git a/mrbgems/mruby-time/src/time.c b/mrbgems/mruby-time/src/time.c
index de94f7137..aae1e2626 100644
--- a/mrbgems/mruby-time/src/time.c
+++ b/mrbgems/mruby-time/src/time.c
@@ -17,7 +17,8 @@
double round(double x) {
if (x >= 0.0) {
return (double)((int)(x + 0.5));
- } else {
+ }
+ else {
return (double)((int)(x - 0.5));
}
}
diff --git a/src/backtrace.c b/src/backtrace.c
index 1d6621e2d..d634123b4 100644
--- a/src/backtrace.c
+++ b/src/backtrace.c
@@ -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"));
if (mrb_nil_p(lastpc)) {
code = NULL;
- } else {
+ }
+ else {
code = (mrb_code*)mrb_cptr(lastpc);
}
diff --git a/src/class.c b/src/class.c
index 7798ded77..7cb544b43 100644
--- a/src/class.c
+++ b/src/class.c
@@ -554,7 +554,8 @@ mrb_get_args(mrb_state *mrb, const char *format, ...)
argc = a->len;
array_argv = TRUE;
- } else {
+ }
+ else {
array_argv = FALSE;
}
@@ -951,7 +952,8 @@ include_class_new(mrb_state *mrb, struct RClass *m, struct RClass *super)
ic->super = super;
if (m->tt == MRB_TT_ICLASS) {
ic->c = m->c;
- } else {
+ }
+ else {
ic->c = m;
}
return ic;
@@ -2225,7 +2227,7 @@ mrb_mod_module_function(mrb_state *mrb, mrb_value mod)
mrb_check_type(mrb, mod, MRB_TT_MODULE);
mrb_get_args(mrb, "*", &argv, &argc);
- if(argc == 0) {
+ if (argc == 0) {
/* set MODFUNC SCOPE if implemented */
return mod;
}
diff --git a/src/debug.c b/src/debug.c
index cc2d37034..d2bcd7d5e 100644
--- a/src/debug.c
+++ b/src/debug.c
@@ -19,7 +19,8 @@ get_file(mrb_irep_debug_info *info, uint32_t pc)
if (!(pc < (*it)->start_pos)) {
ret = it + 1;
count -= step + 1;
- } else { count = step; }
+ }
+ else { count = step; }
}
--ret;
@@ -86,7 +87,8 @@ mrb_debug_get_line(mrb_irep *irep, uint32_t pc)
if (!(pc < it->start_pos)) {
ret = it + 1;
count -= step + 1;
- } else { count = step; }
+ }
+ else { count = step; }
}
--ret;
diff --git a/src/dump.c b/src/dump.c
index 45c595d3b..bb9ed8c75 100644
--- a/src/dump.c
+++ b/src/dump.c
@@ -407,7 +407,8 @@ write_lineno_record_1(mrb_state *mrb, mrb_irep *irep, uint8_t* bin)
if (irep->filename) {
filename_len = strlen(irep->filename);
- } else {
+ }
+ else {
filename_len = 0;
}
mrb_assert_int_fit(size_t, filename_len, uint16_t, UINT16_MAX);
diff --git a/src/gc.c b/src/gc.c
index 5003f4b91..ecf25d637 100644
--- a/src/gc.c
+++ b/src/gc.c
@@ -109,6 +109,7 @@ typedef struct {
struct RRange range;
struct RData data;
struct RProc proc;
+ struct REnv env;
struct RException exc;
#ifdef MRB_WORD_BOXING
struct RFloat floatv;
diff --git a/src/numeric.c b/src/numeric.c
index aa6f86cb9..2117fcc3c 100644
--- a/src/numeric.c
+++ b/src/numeric.c
@@ -944,7 +944,8 @@ lshift(mrb_state *mrb, mrb_int val, mrb_int width)
(val > (MRB_INT_MAX >> width))) {
goto bit_overflow;
}
- } else {
+ }
+ else {
if ((width > NUMERIC_SHIFT_WIDTH_MAX) ||
(val < (MRB_INT_MIN >> width))) {
goto bit_overflow;
diff --git a/src/proc.c b/src/proc.c
index a75774667..ab22bc1fa 100644
--- a/src/proc.c
+++ b/src/proc.c
@@ -61,6 +61,7 @@ closure_setup(mrb_state *mrb, struct RProc *p, int nlocals)
e = mrb->c->ci->env;
}
p->env = e;
+ mrb_field_write_barrier(mrb, (struct RBasic *)p, (struct RBasic *)p->env);
}
struct RProc *
diff --git a/src/state.c b/src/state.c
index 11b71dd63..2a02debef 100644
--- a/src/state.c
+++ b/src/state.c
@@ -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);
if (mrb->atexit_stack_len == 0) {
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);
}
#endif
diff --git a/src/string.c b/src/string.c
index 11abdc051..742046361 100644
--- a/src/string.c
+++ b/src/string.c
@@ -63,7 +63,8 @@ str_new(mrb_state *mrb, const char *p, size_t len)
if (p) {
memcpy(s->as.ary, p, len);
}
- } else {
+ }
+ else {
if (len >= MRB_INT_MAX) {
mrb_raise(mrb, E_ARGUMENT_ERROR, "string size too big");
}
@@ -2029,7 +2030,8 @@ mrb_str_split_m(mrb_state *mrb, mrb_value str)
if (pat_len > 0) {
end = mrb_memsearch(RSTRING_PTR(spat), pat_len, RSTRING_PTR(str)+idx, str_len - idx);
if (end < 0) break;
- } else {
+ }
+ else {
end = chars2bytes(str, idx, 1);
}
mrb_ary_push(mrb, result, byte_subseq(mrb, str, idx, end));
@@ -2852,7 +2854,8 @@ mrb_float_read(const char *string, char **endPtr)
if (*p == '-') {
sign = TRUE;
p += 1;
- } else {
+ }
+ else {
if (*p == '+') {
p += 1;
}
@@ -2888,24 +2891,28 @@ mrb_float_read(const char *string, char **endPtr)
p -= mantSize;
if (decPt < 0) {
decPt = mantSize;
- } else {
+ }
+ else {
mantSize -= 1; /* One of the digits was the point. */
}
if (mantSize > 18) {
if (decPt - 18 > 29999) {
fracExp = 29999;
- } else {
+ }
+ else {
fracExp = decPt - 18;
}
mantSize = 18;
- } else {
+ }
+ else {
fracExp = decPt - mantSize;
}
if (mantSize == 0) {
fraction = 0.0;
p = string;
goto done;
- } else {
+ }
+ else {
int frac1, frac2;
frac1 = 0;
for ( ; mantSize > 9; mantSize -= 1)
@@ -2942,7 +2949,8 @@ mrb_float_read(const char *string, char **endPtr)
if (*p == '-') {
expSign = TRUE;
p += 1;
- } else {
+ }
+ else {
if (*p == '+') {
p += 1;
}
@@ -2958,7 +2966,8 @@ mrb_float_read(const char *string, char **endPtr)
}
if (expSign) {
exp = fracExp - exp;
- } else {
+ }
+ else {
exp = fracExp + exp;
}
@@ -2972,7 +2981,8 @@ mrb_float_read(const char *string, char **endPtr)
if (exp < 0) {
expSign = TRUE;
exp = -exp;
- } else {
+ }
+ else {
expSign = FALSE;
}
if (exp > maxExponent) {
@@ -2987,7 +2997,8 @@ mrb_float_read(const char *string, char **endPtr)
}
if (expSign) {
fraction /= dblExp;
- } else {
+ }
+ else {
fraction *= dblExp;
}
diff --git a/src/vm.c b/src/vm.c
index 93b6c8564..31093ade9 100644
--- a/src/vm.c
+++ b/src/vm.c
@@ -1203,7 +1203,7 @@ RETRY_TRY_BLOCK:
else {
mrb_value blk = regs[bidx];
if (!mrb_nil_p(blk) && mrb_type(blk) != MRB_TT_PROC) {
- if(bidx >= mrb->c->ci->nregs) {
+ if (bidx >= mrb->c->ci->nregs) {
stack_extend(mrb, bidx+1, mrb->c->ci->nregs);
mrb->c->ci->nregs = bidx+1;
}
@@ -1365,7 +1365,7 @@ RETRY_TRY_BLOCK:
else {
stack_extend(mrb, irep->nregs, ci->argc+2);
}
- if(m->env) {
+ if (m->env) {
regs[0] = m->env->stack[0];
}
pc = irep->iseq;
@@ -1442,7 +1442,7 @@ RETRY_TRY_BLOCK:
}
blk = regs[bidx];
if (!mrb_nil_p(blk) && mrb_type(blk) != MRB_TT_PROC) {
- if(bidx >= ci->nregs) {
+ if (bidx >= ci->nregs) {
stack_extend(mrb, bidx+1, ci->nregs);
ci->nregs = bidx+1;
}