Commit 4507985c authored by cremno's avatar cremno

use mrb_bool, FALSE and TRUE more

It doesn't matter to me if one is using FALSE/TRUE instead of 1/0
but I prefer a type (alias) which emphasizes boolean vars to int.
I changed 1/0 to FALSE/TRUE anyway.
parent 7c9a1acc
......@@ -119,7 +119,8 @@ struct mrb_parser_state {
unsigned int cmdarg_stack;
int paren_nest;
int lpar_beg;
int in_def, in_single, cmd_start;
int in_def, in_single;
mrb_bool cmd_start:1;
mrb_ast_node *locals;
mrb_ast_node *pb;
......@@ -138,7 +139,7 @@ struct mrb_parser_state {
size_t nwarn;
mrb_ast_node *tree;
int capture_errors;
mrb_bool capture_errors:1;
struct mrb_parser_message error_buffer[10];
struct mrb_parser_message warn_buffer[10];
......
......@@ -26,7 +26,7 @@ struct RRange {
#define mrb_range_value(p) mrb_obj_value((void*)(p))
mrb_value mrb_range_new(mrb_state*, mrb_value, mrb_value, int);
mrb_int mrb_range_beg_len(mrb_state *mrb, mrb_value range, mrb_int *begp, mrb_int *lenp, mrb_int len);
mrb_bool mrb_range_beg_len(mrb_state *mrb, mrb_value range, mrb_int *begp, mrb_int *lenp, mrb_int len);
#if defined(__cplusplus)
} /* extern "C" { */
......
......@@ -55,8 +55,8 @@ int mrb_str_offset(mrb_state *mrb, mrb_value str, int pos);
mrb_value mrb_str_dup(mrb_state *mrb, mrb_value str);
mrb_value mrb_str_intern(mrb_state *mrb, mrb_value self);
mrb_value mrb_str_cat_cstr(mrb_state *, mrb_value, const char *);
mrb_value mrb_str_to_inum(mrb_state *mrb, mrb_value str, int base, int badcheck);
double mrb_str_to_dbl(mrb_state *mrb, mrb_value str, int badcheck);
mrb_value mrb_str_to_inum(mrb_state *mrb, mrb_value str, int base, mrb_bool badcheck);
double mrb_str_to_dbl(mrb_state *mrb, mrb_value str, mrb_bool badcheck);
mrb_value mrb_str_to_str(mrb_state *mrb, mrb_value str);
mrb_int mrb_str_hash(mrb_state *mrb, mrb_value str);
mrb_value mrb_str_buf_append(mrb_state *mrb, mrb_value str, mrb_value str2);
......
......@@ -45,7 +45,7 @@ p(mrb_state *mrb, mrb_value obj, int prompt)
static mrb_bool
is_code_block_open(struct mrb_parser_state *parser)
{
int code_block_open = FALSE;
mrb_bool code_block_open = FALSE;
/* check for heredoc */
if (parser->parsing_heredoc != NULL) return TRUE;
......@@ -251,9 +251,9 @@ main(int argc, char **argv)
mrb_value result;
struct _args args;
int n;
int code_block_open = FALSE;
mrb_bool code_block_open = FALSE;
int ai;
int first_command = 1;
mrb_bool first_command = TRUE;
unsigned int nregs;
/* new interpreter instance */
......@@ -392,7 +392,7 @@ main(int argc, char **argv)
}
mrb_parser_free(parser);
cxt->lineno++;
first_command = 0;
first_command = FALSE;
}
mrbc_context_free(mrb, cxt);
mrb_close(mrb);
......
......@@ -75,10 +75,10 @@ parse_args(mrb_state *mrb, int argc, char **argv, struct _args *args)
item = argv[0] + 1;
switch (*item++) {
case 'b':
args->mrbfile = 1;
args->mrbfile = TRUE;
break;
case 'c':
args->check_syntax = 1;
args->check_syntax = TRUE;
break;
case 'e':
if (item[0]) {
......@@ -116,7 +116,7 @@ append_cmdline:
break;
case 'v':
if (!args->verbose) mrb_show_version(mrb);
args->verbose = 1;
args->verbose = TRUE;
break;
case '-':
if (strcmp((*argv) + 2, "version") == 0) {
......@@ -124,7 +124,7 @@ append_cmdline:
exit(EXIT_SUCCESS);
}
else if (strcmp((*argv) + 2, "verbose") == 0) {
args->verbose = 1;
args->verbose = TRUE;
break;
}
else if (strcmp((*argv) + 2, "copyright") == 0) {
......@@ -144,7 +144,7 @@ append_cmdline:
printf("%s: Cannot open program file. (%s)\n", *origargv, *argv);
return 0;
}
args->fname = 1;
args->fname = TRUE;
args->cmdline = argv[0];
argc--; argv++;
}
......@@ -199,9 +199,9 @@ main(int argc, char **argv)
c = mrbc_context_new(mrb);
if (args.verbose)
c->dump_result = 1;
c->dump_result = TRUE;
if (args.check_syntax)
c->no_exec = 1;
c->no_exec = FALSE;
if (args.mrbfile) {
v = mrb_load_irep_file_cxt(mrb, args.rfp, c);
}
......
......@@ -981,7 +981,7 @@ gen_send_intern(codegen_scope *s)
push();
}
static void
gen_literal_array(codegen_scope *s, node *tree, int sym, int val)
gen_literal_array(codegen_scope *s, node *tree, mrb_bool sym, int val)
{
if (val) {
int i = 0, j = 0;
......@@ -1069,7 +1069,7 @@ readint_float(codegen_scope *s, const char *p, int base)
}
static mrb_int
readint_mrb_int(codegen_scope *s, const char *p, int base, int neg, int *overflow)
readint_mrb_int(codegen_scope *s, const char *p, int base, mrb_bool neg, mrb_bool *overflow)
{
const char *e = p + strlen(p);
mrb_int result = 0;
......@@ -1933,7 +1933,7 @@ codegen(codegen_scope *s, node *tree, int val)
int base = (intptr_t)tree->cdr->car;
mrb_int i;
mrb_code co;
int overflow;
mrb_bool overflow;
i = readint_mrb_int(s, p, base, FALSE, &overflow);
if (overflow) {
......@@ -1989,7 +1989,7 @@ codegen(codegen_scope *s, node *tree, int val)
int base = (intptr_t)tree->cdr->car;
mrb_int i;
mrb_code co;
int overflow;
mrb_bool overflow;
i = readint_mrb_int(s, p, base, TRUE, &overflow);
if (overflow) {
......
......@@ -352,7 +352,7 @@ set_backtrace(mrb_state *mrb, mrb_value info, mrb_value bt)
}
static mrb_value
make_exception(mrb_state *mrb, int argc, mrb_value *argv, int isstr)
make_exception(mrb_state *mrb, int argc, mrb_value *argv, mrb_bool isstr)
{
mrb_value mesg;
int n;
......
......@@ -834,13 +834,13 @@ incremental_sweep_phase(mrb_state *mrb, size_t limit)
RVALUE *p = page->objects;
RVALUE *e = p + MRB_HEAP_PAGE_SIZE;
size_t freed = 0;
int dead_slot = 1;
mrb_bool dead_slot = TRUE;
int full = (page->freelist == NULL);
if (is_minor_gc(mrb) && page->old) {
/* skip a slot which doesn't contain any young object */
p = e;
dead_slot = 0;
dead_slot = FALSE;
}
while (p<e) {
if (is_dead(mrb, &p->as.basic)) {
......
......@@ -998,7 +998,7 @@ mrb_hash_has_value(mrb_state *mrb, mrb_value hash)
}
static mrb_value
hash_equal(mrb_state *mrb, mrb_value hash1, mrb_value hash2, int eql)
hash_equal(mrb_state *mrb, mrb_value hash1, mrb_value hash2, mrb_bool eql)
{
khash_t(ht) *h1, *h2;
......
......@@ -48,7 +48,7 @@ static mrb_value
num_pow(mrb_state *mrb, mrb_value x)
{
mrb_value y;
int both_int = FALSE;
mrb_bool both_int = FALSE;
mrb_float d;
mrb_get_args(mrb, "o", &y);
......
......@@ -302,7 +302,7 @@ inspect_type(mrb_state *mrb, mrb_value val)
}
static mrb_value
convert_type(mrb_state *mrb, mrb_value val, const char *tname, const char *method, int raise)
convert_type(mrb_state *mrb, mrb_value val, const char *tname, const char *method, mrb_bool raise)
{
mrb_sym m = 0;
......
......@@ -3319,8 +3319,8 @@ backref_error(parser_state *p, node *n)
}
}
static int peeks(parser_state *p, const char *s);
static int skips(parser_state *p, const char *s);
static mrb_bool peeks(parser_state *p, const char *s);
static mrb_bool skips(parser_state *p, const char *s);
static inline int
nextc(parser_state *p)
......@@ -3383,7 +3383,7 @@ skip(parser_state *p, char term)
}
}
static int
static mrb_bool
peek_n(parser_state *p, int c, int n)
{
node *list = 0;
......@@ -3405,7 +3405,7 @@ peek_n(parser_state *p, int c, int n)
}
#define peek(p,c) peek_n((p), (c), 0)
static int
static mrb_bool
peeks(parser_state *p, const char *s)
{
int len = strlen(s);
......@@ -3426,7 +3426,7 @@ peeks(parser_state *p, const char *s)
return FALSE;
}
static int
static mrb_bool
skips(parser_state *p, const char *s)
{
int c;
......@@ -3855,8 +3855,8 @@ heredoc_identifier(parser_state *p)
{
int c;
int type = str_heredoc;
int indent = FALSE;
int quote = FALSE;
mrb_bool indent = FALSE;
mrb_bool quote = FALSE;
node *newnode;
parser_heredoc_info *info;
......@@ -5197,7 +5197,7 @@ mrb_parser_parse(parser_state *p, mrbc_context *c)
}
p->cmd_start = TRUE;
p->in_def = p->in_single = FALSE;
p->in_def = p->in_single = 0;
p->nerr = p->nwarn = 0;
p->lex_strterm = NULL;
......@@ -5227,7 +5227,6 @@ mrb_parser_new(mrb_state *mrb)
*p = parser_state_zero;
p->mrb = mrb;
p->pool = pool;
p->in_def = p->in_single = 0;
p->s = p->send = NULL;
#ifdef ENABLE_STDIO
......@@ -5235,9 +5234,9 @@ mrb_parser_new(mrb_state *mrb)
#endif
p->cmd_start = TRUE;
p->in_def = p->in_single = FALSE;
p->in_def = p->in_single = 0;
p->capture_errors = 0;
p->capture_errors = FALSE;
p->lineno = 1;
p->column = 0;
#if defined(PARSER_TEST) || defined(PARSER_DEBUG)
......
......@@ -257,7 +257,7 @@ mrb_range_each(mrb_state *mrb, mrb_value range)
return range;
}
mrb_int
mrb_bool
mrb_range_beg_len(mrb_state *mrb, mrb_value range, mrb_int *begp, mrb_int *lenp, mrb_int len)
{
mrb_int beg, end, b, e;
......
......@@ -2005,7 +2005,7 @@ mrb_string_value_cstr(mrb_state *mrb, mrb_value *ptr)
}
mrb_value
mrb_str_to_inum(mrb_state *mrb, mrb_value str, int base, int badcheck)
mrb_str_to_inum(mrb_state *mrb, mrb_value str, int base, mrb_bool badcheck)
{
char *s;
int len;
......@@ -2068,7 +2068,7 @@ mrb_str_to_i(mrb_state *mrb, mrb_value self)
}
double
mrb_cstr_to_dbl(mrb_state *mrb, const char * p, int badcheck)
mrb_cstr_to_dbl(mrb_state *mrb, const char * p, mrb_bool badcheck)
{
char *end;
double d;
......@@ -2137,7 +2137,7 @@ bad:
}
double
mrb_str_to_dbl(mrb_state *mrb, mrb_value str, int badcheck)
mrb_str_to_dbl(mrb_state *mrb, mrb_value str, mrb_bool badcheck)
{
char *s;
int len;
......
......@@ -308,7 +308,7 @@ static mrb_bool
symname_p(const char *name)
{
const char *m = name;
int localid = FALSE;
mrb_bool localid = FALSE;
if (!m) return FALSE;
switch (*m) {
......
......@@ -110,14 +110,14 @@ parse_args(mrb_state *mrb, int argc, char **argv, struct mrbc_args *args)
}
break;
case 'c':
args->check_syntax = 1;
args->check_syntax = TRUE;
break;
case 'v':
if (!args->verbose) mrb_show_version(mrb);
args->verbose = 1;
args->verbose = TRUE;
break;
case 'g':
args->debug_info = 1;
args->debug_info = TRUE;
break;
case 'h':
return -1;
......@@ -130,7 +130,7 @@ parse_args(mrb_state *mrb, int argc, char **argv, struct mrbc_args *args)
exit(EXIT_SUCCESS);
}
else if (strcmp(argv[i] + 2, "verbose") == 0) {
args->verbose = 1;
args->verbose = TRUE;
break;
}
else if (strcmp(argv[i] + 2, "copyright") == 0) {
......@@ -186,12 +186,12 @@ load_file(mrb_state *mrb, struct mrbc_args *args)
mrb_value result;
char *input = args->argv[args->idx];
FILE *infile;
int need_close = FALSE;
mrb_bool need_close = FALSE;
c = mrbc_context_new(mrb);
if (args->verbose)
c->dump_result = 1;
c->no_exec = 1;
c->dump_result = TRUE;
c->no_exec = TRUE;
if (input[0] == '-' && input[1] == '\0') {
infile = stdin;
}
......
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