summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2012-05-20 06:09:31 -0700
committerYukihiro "Matz" Matsumoto <[email protected]>2012-05-20 06:09:31 -0700
commitac31b58fe85363e6848cbbbdb6125cce1a2f6152 (patch)
tree7dbd5269aa3694ae69da7774a9be5cbd0aef09eb /src
parent89865740e4bc7f496d1abb306cb8d8d5effefa39 (diff)
parent606a1665c5cfff42622687d693b9362b6c1b663a (diff)
downloadmruby-ac31b58fe85363e6848cbbbdb6125cce1a2f6152.tar.gz
mruby-ac31b58fe85363e6848cbbbdb6125cce1a2f6152.zip
Merge pull request #169 from mitchblank/cplusplus
Part 1 of C++ compilability
Diffstat (limited to 'src')
-rw-r--r--src/class.c6
-rw-r--r--src/codegen.c16
-rw-r--r--src/encoding.c12
-rw-r--r--src/gc.h10
-rw-r--r--src/hash.c8
-rw-r--r--src/parse.y94
-rw-r--r--src/pool.c16
-rw-r--r--src/regcomp.c40
-rw-r--r--src/regparse.c148
-rw-r--r--src/regparse.h2
-rw-r--r--src/sprintf.c6
-rw-r--r--src/st.c4
-rw-r--r--src/st.h2
-rw-r--r--src/transcode.c119
14 files changed, 249 insertions, 234 deletions
diff --git a/src/class.c b/src/class.c
index ee8cb8f48..eda3f87a0 100644
--- a/src/class.c
+++ b/src/class.c
@@ -1003,10 +1003,10 @@ mrb_value
mrb_mod_alias(mrb_state *mrb, mrb_value mod)
{
struct RClass *c = mrb_class_ptr(mod);
- mrb_value new, old;
+ mrb_value new_value, old_value;
- mrb_get_args(mrb, "oo", &new, &old);
- mrb_alias_method(mrb, c, mrb_symbol(new), mrb_symbol(old));
+ mrb_get_args(mrb, "oo", &new_value, &old_value);
+ mrb_alias_method(mrb, c, mrb_symbol(new_value), mrb_symbol(old_value));
return mrb_nil_value();
}
diff --git a/src/codegen.c b/src/codegen.c
index 769f9e538..263490f27 100644
--- a/src/codegen.c
+++ b/src/codegen.c
@@ -20,14 +20,16 @@
typedef mrb_ast_node node;
typedef struct mrb_parser_state parser_state;
+enum looptype {
+ LOOP_NORMAL,
+ LOOP_BLOCK,
+ LOOP_FOR,
+ LOOP_BEGIN,
+ LOOP_RESCUE,
+} type;
+
struct loopinfo {
- enum looptype {
- LOOP_NORMAL,
- LOOP_BLOCK,
- LOOP_FOR,
- LOOP_BEGIN,
- LOOP_RESCUE,
- } type;
+ enum looptype type;
int pc1, pc2, pc3, acc;
int ensure_level;
struct loopinfo *prev;
diff --git a/src/encoding.c b/src/encoding.c
index 8a3bd8ef2..cfe21b581 100644
--- a/src/encoding.c
+++ b/src/encoding.c
@@ -913,11 +913,11 @@ enc_name(mrb_state *mrb, mrb_value self)
struct fn_arg {
mrb_state *mrb;
- int (*func)(ANYARGS);
+ enum st_retval (*func)(ANYARGS);
void *a;
};
-static int
+static enum st_retval
fn_i(st_data_t key, st_data_t val, st_data_t arg) {
struct fn_arg *a = (struct fn_arg*)arg;
@@ -925,7 +925,7 @@ fn_i(st_data_t key, st_data_t val, st_data_t arg) {
}
static int
-st_foreachNew(mrb_state *mrb, st_table *tbl, int (*func)(ANYARGS), void *a)
+st_foreachNew(mrb_state *mrb, st_table *tbl, enum st_retval (*func)(ANYARGS), void *a)
{
struct fn_arg arg = {
mrb,
@@ -936,7 +936,7 @@ st_foreachNew(mrb_state *mrb, st_table *tbl, int (*func)(ANYARGS), void *a)
return st_foreach(tbl, fn_i, (st_data_t)&arg);
}
-static int
+static enum st_retval
enc_names_i(mrb_state *mrb, st_data_t name, st_data_t idx, st_data_t args)
{
mrb_value *arg = (mrb_value *)args;
@@ -1521,7 +1521,7 @@ set_encoding_const(mrb_state *mrb, const char *name, mrb_encoding *enc)
}
}
}
-static int
+static enum st_retval
mrb_enc_name_list_i(mrb_state *mrb, st_data_t name, st_data_t idx, mrb_value *arg)
{
mrb_value ary = *arg;
@@ -1554,7 +1554,7 @@ mrb_enc_name_list(mrb_state *mrb, mrb_value klass)
return ary;
}
-static int
+static enum st_retval
mrb_enc_aliases_enc_i(mrb_state *mrb, st_data_t name, st_data_t orig, st_data_t arg)
{
mrb_value *p = (mrb_value *)arg;
diff --git a/src/gc.h b/src/gc.h
index 0a4bc1c51..fea761d1b 100644
--- a/src/gc.h
+++ b/src/gc.h
@@ -11,12 +11,14 @@
extern "C" {
#endif
+struct free_obj {
+ MRUBY_OBJECT_HEADER;
+ struct RBasic *next;
+};
+
typedef struct {
union {
- struct free_obj {
- MRUBY_OBJECT_HEADER;
- struct RBasic *next;
- } free;
+ struct free_obj free;
struct RBasic basic;
struct RObject object;
struct RClass klass;
diff --git a/src/hash.c b/src/hash.c
index a435b4afd..45219cb40 100644
--- a/src/hash.c
+++ b/src/hash.c
@@ -75,10 +75,10 @@ mrb_gc_mark_ht(mrb_state *mrb, struct RHash *c)
}
size_t
-mrb_gc_mark_ht_size(mrb_state *mrb, struct RClass *c)
+mrb_gc_mark_ht_size(mrb_state *mrb, struct RHash *c)
{
size_t ht_size = 0;
- khash_t(ht) *h = ((struct RHash*)c)->ht;
+ khash_t(ht) *h = c->ht;
/* ((struct RHash*)c)->ht */
if (h) ht_size += kh_size(h)*2;
@@ -87,9 +87,9 @@ mrb_gc_mark_ht_size(mrb_state *mrb, struct RClass *c)
}
void
-mrb_gc_free_ht(mrb_state *mrb, struct RClass *c)
+mrb_gc_free_ht(mrb_state *mrb, struct RHash *c)
{
- khash_t(ht) *h = ((struct RHash*)c)->ht;
+ khash_t(ht) *h = c->ht;
kh_destroy(ht, h);
}
diff --git a/src/parse.y b/src/parse.y
index 63c15e056..96f399fb0 100644
--- a/src/parse.y
+++ b/src/parse.y
@@ -813,7 +813,7 @@ var_reference(parser_state *p, node *lhs)
%lex-param {parser_state *p}
%union {
- node *node;
+ node *nd;
mrb_sym id;
int num;
unsigned int stack;
@@ -871,28 +871,28 @@ var_reference(parser_state *p, node *lhs)
keyword__ENCODING__
%token <id> tIDENTIFIER tFID tGVAR tIVAR tCONSTANT tCVAR tLABEL
-%token <node> tINTEGER tFLOAT tCHAR tREGEXP
-%token <node> tSTRING tSTRING_PART
-%token <node> tNTH_REF tBACK_REF
+%token <nd> tINTEGER tFLOAT tCHAR tREGEXP
+%token <nd> tSTRING tSTRING_PART
+%token <nd> tNTH_REF tBACK_REF
%token <num> tREGEXP_END
-%type <node> singleton string string_interp regexp
-%type <node> literal numeric cpath
-%type <node> top_compstmt top_stmts top_stmt
-%type <node> bodystmt compstmt stmts stmt expr arg primary command command_call method_call
-%type <node> expr_value arg_value primary_value
-%type <node> if_tail opt_else case_body cases opt_rescue exc_list exc_var opt_ensure
-%type <node> args call_args opt_call_args
-%type <node> paren_args opt_paren_args variable
-%type <node> command_args aref_args opt_block_arg block_arg var_ref var_lhs
-%type <node> command_asgn mrhs superclass block_call block_command
-%type <node> f_block_optarg f_block_opt
-%type <node> f_arglist f_args f_arg f_arg_item f_optarg f_marg f_marg_list f_margs
-%type <node> assoc_list assocs assoc undef_list backref for_var
-%type <node> block_param opt_block_param block_param_def f_opt
-%type <node> bv_decls opt_bv_decl bvar f_larglist lambda_body
-%type <node> brace_block cmd_brace_block do_block lhs none fitem f_bad_arg
-%type <node> mlhs mlhs_list mlhs_post mlhs_basic mlhs_item mlhs_node mlhs_inner
+%type <nd> singleton string string_interp regexp
+%type <nd> literal numeric cpath
+%type <nd> top_compstmt top_stmts top_stmt
+%type <nd> bodystmt compstmt stmts stmt expr arg primary command command_call method_call
+%type <nd> expr_value arg_value primary_value
+%type <nd> if_tail opt_else case_body cases opt_rescue exc_list exc_var opt_ensure
+%type <nd> args call_args opt_call_args
+%type <nd> paren_args opt_paren_args variable
+%type <nd> command_args aref_args opt_block_arg block_arg var_ref var_lhs
+%type <nd> command_asgn mrhs superclass block_call block_command
+%type <nd> f_block_optarg f_block_opt
+%type <nd> f_arglist f_args f_arg f_arg_item f_optarg f_marg f_marg_list f_margs
+%type <nd> assoc_list assocs assoc undef_list backref for_var
+%type <nd> block_param opt_block_param block_param_def f_opt
+%type <nd> bv_decls opt_bv_decl bvar f_larglist lambda_body
+%type <nd> brace_block cmd_brace_block do_block lhs none fitem f_bad_arg
+%type <nd> mlhs mlhs_list mlhs_post mlhs_basic mlhs_item mlhs_node mlhs_inner
%type <id> fsym sym symbol operation operation2 operation3
%type <id> cname fname op f_rest_arg f_block_arg opt_f_block_arg f_norm_arg
@@ -1007,12 +1007,12 @@ top_stmt : stmt
if (p->in_def || p->in_single) {
yyerror(p, "BEGIN in method");
}
- $<node>$ = local_switch(p);
+ $<nd>$ = local_switch(p);
}
'{' top_compstmt '}'
{
p->begin_tree = push(p->begin_tree, $4);
- local_resume(p, $<node>2);
+ local_resume(p, $<nd>2);
$$ = 0;
}
;
@@ -1980,13 +1980,13 @@ primary : literal
{
if (p->in_def || p->in_single)
yyerror(p, "class definition in method body");
- $<node>$ = local_switch(p);
+ $<nd>$ = local_switch(p);
}
bodystmt
keyword_end
{
$$ = new_class(p, $2, $3, $5);
- local_resume(p, $<node>4);
+ local_resume(p, $<nd>4);
}
| keyword_class tLSHFT expr
{
@@ -1995,54 +1995,54 @@ primary : literal
}
term
{
- $<node>$ = cons(local_switch(p), (node*)(intptr_t)p->in_single);
+ $<nd>$ = cons(local_switch(p), (node*)(intptr_t)p->in_single);
p->in_single = 0;
}
bodystmt
keyword_end
{
$$ = new_sclass(p, $3, $7);
- local_resume(p, $<node>6->car);
+ local_resume(p, $<nd>6->car);
p->in_def = $<num>4;
- p->in_single = (int)(intptr_t)$<node>6->cdr;
+ p->in_single = (int)(intptr_t)$<nd>6->cdr;
}
| keyword_module cpath
{
if (p->in_def || p->in_single)
yyerror(p, "module definition in method body");
- $<node>$ = local_switch(p);
+ $<nd>$ = local_switch(p);
}
bodystmt
keyword_end
{
$$ = new_module(p, $2, $4);
- local_resume(p, $<node>3);
+ local_resume(p, $<nd>3);
}
| keyword_def fname
{
p->in_def++;
- $<node>$ = local_switch(p);
+ $<nd>$ = local_switch(p);
}
f_arglist
bodystmt
keyword_end
{
$$ = new_def(p, $2, $4, $5);
- local_resume(p, $<node>3);
+ local_resume(p, $<nd>3);
p->in_def--;
}
| keyword_def singleton dot_or_colon {p->lstate = EXPR_FNAME;} fname
{
p->in_single++;
p->lstate = EXPR_ENDFN; /* force for args */
- $<node>$ = local_switch(p);
+ $<nd>$ = local_switch(p);
}
f_arglist
bodystmt
keyword_end
{
$$ = new_sdef(p, $2, $5, $7, $8);
- local_resume(p, $<node>6);
+ local_resume(p, $<nd>6);
p->in_single--;
}
| keyword_break
@@ -3355,7 +3355,7 @@ parse_string(parser_state *p, int term)
p->lstate = EXPR_BEG;
p->sterm = term;
p->cmd_start = TRUE;
- yylval.node = new_str(p, tok(p), toklen(p));
+ yylval.nd = new_str(p, tok(p), toklen(p));
return tSTRING_PART;
}
tokadd(p, '#');
@@ -3368,7 +3368,7 @@ parse_string(parser_state *p, int term)
tokfix(p);
p->lstate = EXPR_END;
p->sterm = 0;
- yylval.node = new_str(p, tok(p), toklen(p));
+ yylval.nd = new_str(p, tok(p), toklen(p));
return tSTRING;
}
@@ -3409,7 +3409,7 @@ parse_qstring(parser_state *p, int term)
}
tokfix(p);
- yylval.node = new_str(p, tok(p), toklen(p));
+ yylval.nd = new_str(p, tok(p), toklen(p));
p->lstate = EXPR_END;
return tSTRING;
}
@@ -3717,7 +3717,7 @@ parser_yylex(parser_state *p)
tokadd(p, c);
}
tokfix(p);
- yylval.node = new_str(p, tok(p), toklen(p));
+ yylval.nd = new_str(p, tok(p), toklen(p));
p->lstate = EXPR_END;
return tCHAR;
@@ -3894,7 +3894,7 @@ parser_yylex(parser_state *p)
no_digits();
}
else if (nondigit) goto trailing_uc;
- yylval.node = new_int(p, tok(p), 16);
+ yylval.nd = new_int(p, tok(p), 16);
return tINTEGER;
}
if (c == 'b' || c == 'B') {
@@ -3918,7 +3918,7 @@ parser_yylex(parser_state *p)
no_digits();
}
else if (nondigit) goto trailing_uc;
- yylval.node = new_int(p, tok(p), 2);
+ yylval.nd = new_int(p, tok(p), 2);
return tINTEGER;
}
if (c == 'd' || c == 'D') {
@@ -3942,7 +3942,7 @@ parser_yylex(parser_state *p)
no_digits();
}
else if (nondigit) goto trailing_uc;
- yylval.node = new_int(p, tok(p), 10);
+ yylval.nd = new_int(p, tok(p), 10);
return tINTEGER;
}
if (c == '_') {
@@ -3975,7 +3975,7 @@ parser_yylex(parser_state *p)
pushback(p, c);
tokfix(p);
if (nondigit) goto trailing_uc;
- yylval.node = new_int(p, tok(p), 8);
+ yylval.nd = new_int(p, tok(p), 8);
return tINTEGER;
}
if (nondigit) {
@@ -3992,7 +3992,7 @@ parser_yylex(parser_state *p)
}
else {
pushback(p, c);
- yylval.node = new_int(p, "0", 10);
+ yylval.nd = new_int(p, "0", 10);
return tINTEGER;
}
}
@@ -4069,10 +4069,10 @@ parser_yylex(parser_state *p)
yywarning_s(p, "float %s out of range", tok(p));
errno = 0;
}
- yylval.node = new_float(p, tok(p));
+ yylval.nd = new_float(p, tok(p));
return tFLOAT;
}
- yylval.node = new_int(p, tok(p), 10);
+ yylval.nd = new_int(p, tok(p), 10);
return tINTEGER;
}
@@ -4404,7 +4404,7 @@ parser_yylex(parser_state *p)
tokadd(p, c);
goto gvar;
}
- yylval.node = new_back_ref(p, c);
+ yylval.nd = new_back_ref(p, c);
return tBACK_REF;
case '1': case '2': case '3':
@@ -4417,7 +4417,7 @@ parser_yylex(parser_state *p)
pushback(p, c);
if (last_state == EXPR_FNAME) goto gvar;
tokfix(p);
- yylval.node = new_nth_ref(p, atoi(tok(p)));
+ yylval.nd = new_nth_ref(p, atoi(tok(p)));
return tNTH_REF;
default:
diff --git a/src/pool.c b/src/pool.c
index a367a30a5..3cbb2b163 100644
--- a/src/pool.c
+++ b/src/pool.c
@@ -8,15 +8,17 @@
#include <stddef.h>
#include <string.h>
+struct mrb_pool_page {
+ struct mrb_pool_page *next;
+ size_t offset;
+ size_t len;
+ void *last;
+ char page[1];
+};
+
struct mrb_pool {
mrb_state *mrb;
- struct mrb_pool_page {
- struct mrb_pool_page *next;
- size_t offset;
- size_t len;
- void *last;
- char page[1];
- } *pages;
+ struct mrb_pool_page *pages;
};
#undef TEST_POOL
diff --git a/src/regcomp.c b/src/regcomp.c
index 816e219c7..523124b26 100644
--- a/src/regcomp.c
+++ b/src/regcomp.c
@@ -1640,8 +1640,8 @@ compile_tree(Node* node, regex_t* reg)
switch (NCTYPE(node)->ctype) {
case ONIGENC_CTYPE_WORD:
- if (NCTYPE(node)->not != 0) op = OP_NOT_WORD;
- else op = OP_WORD;
+ if (NCTYPE(node)->is_not != 0) op = OP_NOT_WORD;
+ else op = OP_WORD;
break;
default:
return ONIGERR_TYPE_BUG;
@@ -2440,8 +2440,8 @@ is_not_included(Node* x, Node* y, regex_t* reg)
{
switch (ytype) {
case NT_CTYPE:
- if (NCTYPE(y)->ctype == NCTYPE(x)->ctype &&
- NCTYPE(y)->not != NCTYPE(x)->not)
+ if (NCTYPE(y)->ctype == NCTYPE(x)->ctype &&
+ NCTYPE(y)->is_not != NCTYPE(x)->is_not)
return 1;
else
return 0;
@@ -2473,7 +2473,7 @@ is_not_included(Node* x, Node* y, regex_t* reg)
case NT_CTYPE:
switch (NCTYPE(y)->ctype) {
case ONIGENC_CTYPE_WORD:
- if (NCTYPE(y)->not == 0) {
+ if (NCTYPE(y)->is_not == 0) {
if (IS_NULL(xc->mbuf) && !IS_NCCLASS_NOT(xc)) {
for (i = 0; i < SINGLE_BYTE_SIZE; i++) {
if (BITSET_AT(xc->bs, i)) {
@@ -2550,9 +2550,9 @@ is_not_included(Node* x, Node* y, regex_t* reg)
switch (NCTYPE(y)->ctype) {
case ONIGENC_CTYPE_WORD:
if (ONIGENC_IS_MBC_WORD(reg->enc, xs->s, xs->end))
- return NCTYPE(y)->not;
+ return NCTYPE(y)->is_not;
else
- return !(NCTYPE(y)->not);
+ return !(NCTYPE(y)->is_not);
break;
default:
break;
@@ -3038,19 +3038,21 @@ setup_subexp_call(Node* node, ScanEnv* env)
Node** nodes = SCANENV_MEM_NODES(env);
if (cn->group_num != 0) {
- int gnum = cn->group_num;
+ {
+ int gnum = cn->group_num;
#ifdef USE_NAMED_GROUP
- if (env->num_named > 0 &&
- IS_SYNTAX_BV(env->syntax, ONIG_SYN_CAPTURE_ONLY_NAMED_GROUP) &&
- !ONIG_IS_OPTION_ON(env->option, ONIG_OPTION_CAPTURE_GROUP)) {
- return ONIGERR_NUMBERED_BACKREF_OR_CALL_NOT_ALLOWED;
- }
+ if (env->num_named > 0 &&
+ IS_SYNTAX_BV(env->syntax, ONIG_SYN_CAPTURE_ONLY_NAMED_GROUP) &&
+ !ONIG_IS_OPTION_ON(env->option, ONIG_OPTION_CAPTURE_GROUP)) {
+ return ONIGERR_NUMBERED_BACKREF_OR_CALL_NOT_ALLOWED;
+ }
#endif
- if (gnum > env->num_mem) {
- onig_scan_env_set_error_string(env,
- ONIGERR_UNDEFINED_GROUP_REFERENCE, cn->name, cn->name_end);
- return ONIGERR_UNDEFINED_GROUP_REFERENCE;
+ if (gnum > env->num_mem) {
+ onig_scan_env_set_error_string(env,
+ ONIGERR_UNDEFINED_GROUP_REFERENCE, cn->name, cn->name_end);
+ return ONIGERR_UNDEFINED_GROUP_REFERENCE;
+ }
}
#ifdef USE_NAMED_GROUP
@@ -4668,7 +4670,7 @@ optimize_node_left(Node* node, NodeOptInfo* opt, OptEnv* env)
switch (NCTYPE(node)->ctype) {
case ONIGENC_CTYPE_WORD:
- if (NCTYPE(node)->not != 0) {
+ if (NCTYPE(node)->is_not != 0) {
for (i = 0; i < SINGLE_BYTE_SIZE; i++) {
if (! ONIGENC_IS_CODE_WORD(env->enc, i)) {
add_char_opt_map_info(&opt->map, (UChar )i, env->enc);
@@ -6170,7 +6172,7 @@ print_indent_tree(FILE* f, Node* node, int indent)
fprintf(f, "<ctype:%x> ", (int )node);
switch (NCTYPE(node)->ctype) {
case ONIGENC_CTYPE_WORD:
- if (NCTYPE(node)->not != 0)
+ if (NCTYPE(node)->is_not != 0)
fputs("not word", f);
else
fputs("word", f);
diff --git a/src/regparse.c b/src/regparse.c
index ee933662c..f98e82ff2 100644
--- a/src/regparse.c
+++ b/src/regparse.c
@@ -416,7 +416,7 @@ typedef st_data_t HashDataType; /* 1.6 st.h doesn't define st_data_t type */
#define NAMEBUF_SIZE_1 25
#ifdef ONIG_DEBUG
-static int
+static enum st_retval
i_print_name_entry(UChar* key, NameEntry* e, void* arg)
{
int i;
@@ -451,7 +451,7 @@ onig_print_names(FILE* fp, regex_t* reg)
}
#endif /* ONIG_DEBUG */
-static int
+static enum st_retval
i_free_name_entry(UChar* key, NameEntry* e, void* arg ARG_UNUSED)
{
xfree(e->name);
@@ -508,7 +508,7 @@ typedef struct {
OnigEncoding enc;
} INamesArg;
-static int
+static enum st_retval
i_names(UChar* key ARG_UNUSED, NameEntry* e, INamesArg* arg)
{
int r = (*(arg->func))(e->name,
@@ -541,7 +541,7 @@ onig_foreach_name(regex_t* reg,
return narg.ret;
}
-static int
+static enum st_retval
i_renumber_name(UChar* key ARG_UNUSED, NameEntry* e, GroupNumRemap* map)
{
int i;
@@ -1151,7 +1151,7 @@ node_new_cclass(void)
}
static Node*
-node_new_cclass_by_codepoint_range(int not, OnigCodePoint sb_out,
+node_new_cclass_by_codepoint_range(int is_not, OnigCodePoint sb_out,
const OnigCodePoint ranges[])
{
int n, i;
@@ -1162,7 +1162,7 @@ node_new_cclass_by_codepoint_range(int not, OnigCodePoint sb_out,
CHECK_NULL_RETURN(node);
cc = NCCLASS(node);
- if (not != 0) NCCLASS_SET_NOT(cc);
+ if (is_not != 0) NCCLASS_SET_NOT(cc);
BITSET_CLEAR(cc->bs);
if (sb_out > 0 && IS_NOT_NULL(ranges)) {
@@ -1201,14 +1201,14 @@ node_new_cclass_by_codepoint_range(int not, OnigCodePoint sb_out,
}
static Node*
-node_new_ctype(int type, int not)
+node_new_ctype(int type, int is_not)
{
Node* node = node_new();
CHECK_NULL_RETURN(node);
SET_NTYPE(node, NT_CTYPE);
- NCTYPE(node)->ctype = type;
- NCTYPE(node)->not = not;
+ NCTYPE(node)->ctype = type;
+ NCTYPE(node)->is_not = is_not;
return node;
}
@@ -2285,7 +2285,7 @@ typedef struct {
} call;
struct {
int ctype;
- int not;
+ int is_not;
} prop;
} u;
} OnigToken;
@@ -2954,45 +2954,45 @@ fetch_token_in_cc(OnigToken* tok, UChar** src, UChar* end, ScanEnv* env)
switch (c) {
case 'w':
tok->type = TK_CHAR_TYPE;
- tok->u.prop.ctype = ONIGENC_CTYPE_W;
- tok->u.prop.not = 0;
+ tok->u.prop.ctype = ONIGENC_CTYPE_W;
+ tok->u.prop.is_not = 0;
break;
case 'W':
tok->type = TK_CHAR_TYPE;
- tok->u.prop.ctype = ONIGENC_CTYPE_W;
- tok->u.prop.not = 1;
+ tok->u.prop.ctype = ONIGENC_CTYPE_W;
+ tok->u.prop.is_not = 1;
break;
case 'd':
tok->type = TK_CHAR_TYPE;
- tok->u.prop.ctype = ONIGENC_CTYPE_D;
- tok->u.prop.not = 0;
+ tok->u.prop.ctype = ONIGENC_CTYPE_D;
+ tok->u.prop.is_not = 0;
break;
case 'D':
tok->type = TK_CHAR_TYPE;
- tok->u.prop.ctype = ONIGENC_CTYPE_D;
- tok->u.prop.not = 1;
+ tok->u.prop.ctype = ONIGENC_CTYPE_D;
+ tok->u.prop.is_not = 1;
break;
case 's':
tok->type = TK_CHAR_TYPE;
- tok->u.prop.ctype = ONIGENC_CTYPE_S;
- tok->u.prop.not = 0;
+ tok->u.prop.ctype = ONIGENC_CTYPE_S;
+ tok->u.prop.is_not = 0;
break;
case 'S':
tok->type = TK_CHAR_TYPE;
- tok->u.prop.ctype = ONIGENC_CTYPE_S;
- tok->u.prop.not = 1;
+ tok->u.prop.ctype = ONIGENC_CTYPE_S;
+ tok->u.prop.is_not = 1;
break;
case 'h':
if (! IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_ESC_H_XDIGIT)) break;
tok->type = TK_CHAR_TYPE;
- tok->u.prop.ctype = ONIGENC_CTYPE_XDIGIT;
- tok->u.prop.not = 0;
+ tok->u.prop.ctype = ONIGENC_CTYPE_XDIGIT;
+ tok->u.prop.is_not = 0;
break;
case 'H':
if (! IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_ESC_H_XDIGIT)) break;
tok->type = TK_CHAR_TYPE;
- tok->u.prop.ctype = ONIGENC_CTYPE_XDIGIT;
- tok->u.prop.not = 1;
+ tok->u.prop.ctype = ONIGENC_CTYPE_XDIGIT;
+ tok->u.prop.is_not = 1;
break;
case 'p':
@@ -3002,12 +3002,12 @@ fetch_token_in_cc(OnigToken* tok, UChar** src, UChar* end, ScanEnv* env)
IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_ESC_P_BRACE_CHAR_PROPERTY)) {
PINC;
tok->type = TK_CHAR_PROPERTY;
- tok->u.prop.not = (c == 'P' ? 1 : 0);
+ tok->u.prop.is_not = (c == 'P' ? 1 : 0);
if (IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_ESC_P_BRACE_CIRCUMFLEX_NOT)) {
PFETCH(c2);
if (c2 == '^') {
- tok->u.prop.not = (tok->u.prop.not == 0 ? 1 : 0);
+ tok->u.prop.is_not = (tok->u.prop.is_not == 0 ? 1 : 0);
}
else
PUNFETCH;
@@ -3244,15 +3244,15 @@ fetch_token(OnigToken* tok, UChar** src, UChar* end, ScanEnv* env)
case 'w':
if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_W_WORD)) break;
tok->type = TK_CHAR_TYPE;
- tok->u.prop.ctype = ONIGENC_CTYPE_W;
- tok->u.prop.not = 0;
+ tok->u.prop.ctype = ONIGENC_CTYPE_W;
+ tok->u.prop.is_not = 0;
break;
case 'W':
if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_W_WORD)) break;
tok->type = TK_CHAR_TYPE;
- tok->u.prop.ctype = ONIGENC_CTYPE_W;
- tok->u.prop.not = 1;
+ tok->u.prop.ctype = ONIGENC_CTYPE_W;
+ tok->u.prop.is_not = 1;
break;
case 'b':
@@ -3284,43 +3284,43 @@ fetch_token(OnigToken* tok, UChar** src, UChar* end, ScanEnv* env)
case 's':
if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_S_WHITE_SPACE)) break;
tok->type = TK_CHAR_TYPE;
- tok->u.prop.ctype = ONIGENC_CTYPE_S;
- tok->u.prop.not = 0;
+ tok->u.prop.ctype = ONIGENC_CTYPE_S;
+ tok->u.prop.is_not = 0;
break;
case 'S':
if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_S_WHITE_SPACE)) break;
tok->type = TK_CHAR_TYPE;
- tok->u.prop.ctype = ONIGENC_CTYPE_S;
- tok->u.prop.not = 1;
+ tok->u.prop.ctype = ONIGENC_CTYPE_S;
+ tok->u.prop.is_not = 1;
break;
case 'd':
if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_D_DIGIT)) break;
tok->type = TK_CHAR_TYPE;
- tok->u.prop.ctype = ONIGENC_CTYPE_D;
- tok->u.prop.not = 0;
+ tok->u.prop.ctype = ONIGENC_CTYPE_D;
+ tok->u.prop.is_not = 0;
break;
case 'D':
if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_D_DIGIT)) break;
tok->type = TK_CHAR_TYPE;
- tok->u.prop.ctype = ONIGENC_CTYPE_D;
- tok->u.prop.not = 1;
+ tok->u.prop.ctype = ONIGENC_CTYPE_D;
+ tok->u.prop.is_not = 1;
break;
case 'h':
if (! IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_ESC_H_XDIGIT)) break;
tok->type = TK_CHAR_TYPE;
- tok->u.prop.ctype = ONIGENC_CTYPE_XDIGIT;
- tok->u.prop.not = 0;
+ tok->u.prop.ctype = ONIGENC_CTYPE_XDIGIT;
+ tok->u.prop.is_not = 0;
break;
case 'H':
if (! IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_ESC_H_XDIGIT)) break;
tok->type = TK_CHAR_TYPE;
- tok->u.prop.ctype = ONIGENC_CTYPE_XDIGIT;
- tok->u.prop.not = 1;
+ tok->u.prop.ctype = ONIGENC_CTYPE_XDIGIT;
+ tok->u.prop.is_not = 1;
break;
case 'A':
@@ -3574,12 +3574,12 @@ fetch_token(OnigToken* tok, UChar** src, UChar* end, ScanEnv* env)
IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_ESC_P_BRACE_CHAR_PROPERTY)) {
PINC;
tok->type = TK_CHAR_PROPERTY;
- tok->u.prop.not = (c == 'P' ? 1 : 0);
+ tok->u.prop.is_not = (c == 'P' ? 1 : 0);
if (IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_ESC_P_BRACE_CIRCUMFLEX_NOT)) {
PFETCH(c);
if (c == '^') {
- tok->u.prop.not = (tok->u.prop.not == 0 ? 1 : 0);
+ tok->u.prop.is_not = (tok->u.prop.is_not == 0 ? 1 : 0);
}
else
PUNFETCH;
@@ -3773,7 +3773,7 @@ fetch_token(OnigToken* tok, UChar** src, UChar* end, ScanEnv* env)
}
static int
-add_ctype_to_cc_by_range(CClassNode* cc, int ctype ARG_UNUSED, int not,
+add_ctype_to_cc_by_range(CClassNode* cc, int ctype ARG_UNUSED, int is_not,
ScanEnv* env,
OnigCodePoint sb_out, const OnigCodePoint mbr[])
{
@@ -3782,7 +3782,7 @@ add_ctype_to_cc_by_range(CClassNode* cc, int ctype ARG_UNUSED, int not,
int n = ONIGENC_CODE_RANGE_NUM(mbr);
- if (not == 0) {
+ if (is_not == 0) {
for (i = 0; i < n; i++) {
for (j = ONIGENC_CODE_RANGE_FROM(mbr, i);
j <= ONIGENC_CODE_RANGE_TO(mbr, i); j++) {
@@ -3846,7 +3846,7 @@ add_ctype_to_cc_by_range(CClassNode* cc, int ctype ARG_UNUSED, int not,
}
static int
-add_ctype_to_cc(CClassNode* cc, int ctype, int not, ScanEnv* env)
+add_ctype_to_cc(CClassNode* cc, int ctype, int is_not, ScanEnv* env)
{
int c, r;
const OnigCodePoint *ranges;
@@ -3858,7 +3858,7 @@ add_ctype_to_cc(CClassNode* cc, int ctype, int not, ScanEnv* env)
case ONIGENC_CTYPE_S:
case ONIGENC_CTYPE_W:
ctype ^= ONIGENC_CTYPE_SPECIAL_MASK;
- if (not != 0) {
+ if (is_not != 0) {
for (c = 0; c < SINGLE_BYTE_SIZE; c++) {
if (! ONIGENC_IS_ASCII_CODE_CTYPE((OnigCodePoint )c, ctype))
BITSET_SET_BIT_CHKDUP(cc->bs, c);
@@ -3877,7 +3877,7 @@ add_ctype_to_cc(CClassNode* cc, int ctype, int not, ScanEnv* env)
r = ONIGENC_GET_CTYPE_CODE_RANGE(enc, ctype, &sb_out, &ranges);
if (r == 0) {
- return add_ctype_to_cc_by_range(cc, ctype, not, env, sb_out, ranges);
+ return add_ctype_to_cc_by_range(cc, ctype, is_not, env, sb_out, ranges);
}
else if (r != ONIG_NO_SUPPORT_CONFIG) {
return r;
@@ -3896,7 +3896,7 @@ add_ctype_to_cc(CClassNode* cc, int ctype, int not, ScanEnv* env)
case ONIGENC_CTYPE_XDIGIT:
case ONIGENC_CTYPE_ASCII:
case ONIGENC_CTYPE_ALNUM:
- if (not != 0) {
+ if (is_not != 0) {
for (c = 0; c < SINGLE_BYTE_SIZE; c++) {
if (! ONIGENC_IS_CODE_CTYPE(enc, (OnigCodePoint )c, ctype))
BITSET_SET_BIT_CHKDUP(cc->bs, c);
@@ -3913,7 +3913,7 @@ add_ctype_to_cc(CClassNode* cc, int ctype, int not, ScanEnv* env)
case ONIGENC_CTYPE_GRAPH:
case ONIGENC_CTYPE_PRINT:
- if (not != 0) {
+ if (is_not != 0) {
for (c = 0; c < SINGLE_BYTE_SIZE; c++) {
if (! ONIGENC_IS_CODE_CTYPE(enc, (OnigCodePoint )c, ctype))
BITSET_SET_BIT_CHKDUP(cc->bs, c);
@@ -3929,7 +3929,7 @@ add_ctype_to_cc(CClassNode* cc, int ctype, int not, ScanEnv* env)
break;
case ONIGENC_CTYPE_WORD:
- if (not == 0) {
+ if (is_not == 0) {
for (c = 0; c < SINGLE_BYTE_SIZE; c++) {
if (IS_CODE_SB_WORD(enc, c)) BITSET_SET_BIT_CHKDUP(cc->bs, c);
}
@@ -3977,7 +3977,7 @@ parse_posix_bracket(CClassNode* cc, UChar** src, UChar* end, ScanEnv* env)
};
const PosixBracketEntryType *pb;
- int not, i, r;
+ int is_not, i, r;
OnigCodePoint c;
OnigEncoding enc = env->enc;
UChar *p = *src;
@@ -3985,10 +3985,10 @@ parse_posix_bracket(CClassNode* cc, UChar** src, UChar* end, ScanEnv* env)
if (PPEEK_IS('^')) {
PINC;
- not = 1;
+ is_not = 1;
}
else
- not = 0;
+ is_not = 0;
if (onigenc_strlen(enc, p, end) < POSIX_BRACKET_NAME_MIN_LEN + 3)
goto not_posix_bracket;
@@ -3999,7 +3999,7 @@ parse_posix_bracket(CClassNode* cc, UChar** src, UChar* end, ScanEnv* env)
if (onigenc_with_ascii_strncmp(enc, p, end, (UChar* )":]", 2) != 0)
return ONIGERR_INVALID_POSIX_BRACKET_TYPE;
- r = add_ctype_to_cc(cc, pb->ctype, not, env);
+ r = add_ctype_to_cc(cc, pb->ctype, is_not, env);
if (r != 0) return r;
PINC; PINC;
@@ -4074,7 +4074,7 @@ parse_char_property(Node** np, OnigToken* tok, UChar** src, UChar* end,
cc = NCCLASS(*np);
r = add_ctype_to_cc(cc, ctype, 0, env);
if (r != 0) return r;
- if (tok->u.prop.not != 0) NCCLASS_SET_NOT(cc);
+ if (tok->u.prop.is_not != 0) NCCLASS_SET_NOT(cc);
return 0;
}
@@ -4356,7 +4356,7 @@ parse_char_class(Node** np, OnigToken* tok, UChar** src, UChar* end,
break;
case TK_CHAR_TYPE:
- r = add_ctype_to_cc(cc, tok->u.prop.ctype, tok->u.prop.not, env);
+ r = add_ctype_to_cc(cc, tok->u.prop.ctype, tok->u.prop.is_not, env);
if (r != 0) return r;
next_class:
@@ -4370,7 +4370,7 @@ parse_char_class(Node** np, OnigToken* tok, UChar** src, UChar* end,
ctype = fetch_char_property_to_ctype(&p, end, env);
if (ctype < 0) return ctype;
- r = add_ctype_to_cc(cc, ctype, tok->u.prop.not, env);
+ r = add_ctype_to_cc(cc, ctype, tok->u.prop.is_not, env);
if (r != 0) return r;
goto next_class;
}
@@ -4881,15 +4881,15 @@ set_quantifier(Node* qnode, Node* target, int group, ScanEnv* env)
typedef struct {
OnigEncoding enc;
- int not;
+ int is_not;
int type;
} type_cclass_key;
static int type_cclass_cmp(type_cclass_key* x, type_cclass_key* y)
{
- if (x->type != y->type) return 1;
- if (x->enc != y->enc) return 1;
- if (x->not != y->not) return 1;
+ if (x->type != y->type) return 1;
+ if (x->enc != y->enc) return 1;
+ if (x->is_not != y->is_not) return 1;
return 0;
}
@@ -4910,7 +4910,7 @@ static st_index_t type_cclass_hash(type_cclass_key* key)
val = val * 997 + (int )*p++;
}
- val += key->not;
+ val += key->is_not;
return val + (val >> 5);
}
@@ -4922,7 +4922,7 @@ static const struct st_hash_type type_type_cclass_hash = {
static st_table* OnigTypeCClassTable;
-static int
+static enum st_retval
i_free_shared_class(type_cclass_key* key, Node* node, void* arg ARG_UNUSED)
{
if (IS_NOT_NULL(node)) {
@@ -5208,12 +5208,12 @@ parse_exp(Node** np, OnigToken* tok, int term,
CHECK_NULL_RETURN_MEMERR(*np);
cc = NCCLASS(*np);
add_ctype_to_cc(cc, tok->u.prop.ctype, 0, env);
- if (tok->u.prop.not != 0) NCCLASS_SET_NOT(cc);
+ if (tok->u.prop.is_not != 0) NCCLASS_SET_NOT(cc);
}
break;
case ONIGENC_CTYPE_WORD:
- *np = node_new_ctype(tok->u.prop.ctype, tok->u.prop.not);
+ *np = node_new_ctype(tok->u.prop.ctype, tok->u.prop.is_not);
CHECK_NULL_RETURN_MEMERR(*np);
break;
@@ -5235,9 +5235,9 @@ parse_exp(Node** np, OnigToken* tok, int term,
type_cclass_key key;
type_cclass_key* new_key;
- key.enc = env->enc;
- key.not = tok->u.prop.not;
- key.type = tok->u.prop.ctype;
+ key.enc = env->enc;
+ key.is_not = tok->u.prop.is_not;
+ key.type = tok->u.prop.ctype;
THREAD_ATOMIC_START;
@@ -5257,7 +5257,7 @@ parse_exp(Node** np, OnigToken* tok, int term,
}
}
- *np = node_new_cclass_by_codepoint_range(tok->u.prop.not,
+ *np = node_new_cclass_by_codepoint_range(tok->u.prop.is_not,
sb_out, mbr);
if (IS_NULL(*np)) {
THREAD_ATOMIC_END;
@@ -5279,7 +5279,7 @@ parse_exp(Node** np, OnigToken* tok, int term,
CHECK_NULL_RETURN_MEMERR(*np);
cc = NCCLASS(*np);
add_ctype_to_cc(cc, tok->u.prop.ctype, 0, env);
- if (tok->u.prop.not != 0) NCCLASS_SET_NOT(cc);
+ if (tok->u.prop.is_not != 0) NCCLASS_SET_NOT(cc);
#ifdef USE_SHARED_CCLASS_TABLE
}
#endif
diff --git a/src/regparse.h b/src/regparse.h
index ac8758bd1..1f7855df8 100644
--- a/src/regparse.h
+++ b/src/regparse.h
@@ -247,7 +247,7 @@ typedef struct {
typedef struct {
NodeBase base;
int ctype;
- int not;
+ int is_not;
} CtypeNode;
typedef struct _Node {
diff --git a/src/sprintf.c b/src/sprintf.c
index 12d96c92d..6a86a0d04 100644
--- a/src/sprintf.c
+++ b/src/sprintf.c
@@ -191,7 +191,7 @@ mrb_fix2binstr(mrb_state *mrb, mrb_value x, int base)
} while (0)
static mrb_value
-get_hash(mrb_state *mrb, volatile mrb_value *hash, int argc, const mrb_value *argv)
+get_hash(mrb_state *mrb, mrb_value *hash, int argc, const mrb_value *argv)
{
mrb_value tmp;
@@ -497,7 +497,7 @@ mrb_str_format(mrb_state *mrb, int argc, const mrb_value *argv, mrb_value fmt)
mrb_value nextvalue;
mrb_value tmp;
mrb_value str;
- volatile mrb_value hash = mrb_undef_value();
+ mrb_value hash = mrb_undef_value();
#define CHECK_FOR_WIDTH(f) \
if ((f) & FWIDTH) { \
@@ -772,7 +772,7 @@ format_s:
case 'B':
case 'u':
{
- volatile mrb_value val = GETARG();
+ mrb_value val = GETARG();
char fbuf[32], nbuf[64], *s;
const char *prefix = 0;
int sign = 0, dots = 0;
diff --git a/src/st.c b/src/st.c
index 777a03bd2..c0597395d 100644
--- a/src/st.c
+++ b/src/st.c
@@ -404,7 +404,7 @@ st_delete(register st_table *table, register st_data_t *key, st_data_t *value)
}
int
-st_foreach(st_table *table, int (*func)(ANYARGS), st_data_t arg)
+st_foreach(st_table *table, enum st_retval (*func)(ANYARGS), st_data_t arg)
{
st_table_entry *ptr, **last, *tmp;
enum st_retval retval;
@@ -572,7 +572,7 @@ numhash(long n)
}
#if 0
-static int
+static enum st_retval
f(st_data_t key, st_data_t val, st_data_t a)
{
printf("tbl=%p key=%s val=%s\n", (st_table*)a, (char*)key, (char*)val);
diff --git a/src/st.h b/src/st.h
index 24db1fd23..2be618041 100644
--- a/src/st.h
+++ b/src/st.h
@@ -74,7 +74,7 @@ int st_delete(st_table *, st_data_t *, st_data_t *);
int st_delete_safe(st_table *, st_data_t *, st_data_t *, st_data_t);
int st_insert(st_table *, st_data_t, st_data_t);
int st_lookup(st_table *, st_data_t, st_data_t *);
-int st_foreach(st_table *, int (*)(ANYARGS), st_data_t);
+int st_foreach(st_table *, enum st_retval (*)(ANYARGS), st_data_t);
void st_add_direct(st_table *, st_data_t, st_data_t);
void st_free_table(st_table *);
void st_cleanup_safe(st_table *, st_data_t);
diff --git a/src/transcode.c b/src/transcode.c
index 42c86d167..e9d9b01ef 100644
--- a/src/transcode.c
+++ b/src/transcode.c
@@ -65,6 +65,12 @@ allocate_converted_string(mrb_state *mrb,
unsigned char *caller_dst_buf, size_t caller_dst_bufsize,
size_t *dst_len_ptr);
+union mrb_transcoding_state_t { /* opaque data for stateful encoding */
+ void *ptr;
+ char ary[sizeof(double) > sizeof(void*) ? sizeof(double) : sizeof(void*)];
+ double dummy_for_alignment;
+};
+
/* dynamic structure, one per conversion (similar to iconv_t) */
/* may carry conversion state (e.g. for iso-2022-jp) */
typedef struct mrb_transcoding {
@@ -92,11 +98,7 @@ typedef struct mrb_transcoding {
unsigned char *ptr; /* length: max_output */
} writebuf;
- union mrb_transcoding_state_t { /* opaque data for stateful encoding */
- void *ptr;
- char ary[sizeof(double) > sizeof(void*) ? sizeof(double) : sizeof(void*)];
- double dummy_for_alignment;
- } state;
+ union mrb_transcoding_state_t state;
} mrb_transcoding;
#define TRANSCODING_READBUF(tc) \
((tc)->transcoder->max_input <= (int)sizeof((tc)->readbuf.ary) ? \
@@ -271,7 +273,7 @@ typedef struct {
const char *base_enc;
} search_path_bfs_t;
-static int
+static enum st_retval
transcode_search_path_i(st_data_t key, st_data_t val, st_data_t arg)
{
const char *dname = (const char *)key;
@@ -577,10 +579,12 @@ transcode_restartable0(mrb_state *mrb,
switch (mrb_fixnum(next_info) & 0x1F) {
case NOMAP:
{
- const unsigned char *p = inchar_start;
- writebuf_off = 0;
- while (p < in_p) {
- TRANSCODING_WRITEBUF(tc)[writebuf_off++] = (unsigned char)*p++;
+ {
+ const unsigned char *p = inchar_start;
+ writebuf_off = 0;
+ while (p < in_p) {
+ TRANSCODING_WRITEBUF(tc)[writebuf_off++] = (unsigned char)*p++;
+ }
}
writebuf_len = writebuf_off;
writebuf_off = 0;
@@ -1125,16 +1129,16 @@ trans_sweep(mrb_state *mrb, mrb_econv_t *ec,
int flags,
int start)
{
- int try;
+ int should_try;
int i, f;
const unsigned char **ipp, *is, *iold;
unsigned char **opp, *os, *oold;
mrb_econv_result_t res;
- try = 1;
- while (try) {
- try = 0;
+ should_try = 1;
+ while (should_try) {
+ should_try = 0;
for (i = start; i < ec->num_trans; i++) {
mrb_econv_elem_t *te = &ec->elems[i];
@@ -1177,7 +1181,7 @@ trans_sweep(mrb_state *mrb, mrb_econv_t *ec,
oold = *opp;
te->last_result = res = mrb_transcoding_convert(mrb, te->tc, ipp, is, opp, os, f);
if (iold != *ipp || oold != *opp)
- try = 1;
+ should_try = 1;
switch (res) {
case econv_invalid_byte_sequence:
@@ -1795,7 +1799,7 @@ struct asciicompat_encoding_t {
const char *ascii_incompat_name;
};
-static int
+static enum st_retval
asciicompat_encoding_i(mrb_state *mrb, st_data_t key, st_data_t val, st_data_t arg)
{
struct asciicompat_encoding_t *data = (struct asciicompat_encoding_t *)arg;
@@ -2083,51 +2087,54 @@ make_econv_exception(mrb_state *mrb, mrb_econv_t *ec)
mrb_value mesg, exc;
if (ec->last_error.result == econv_invalid_byte_sequence ||
ec->last_error.result == econv_incomplete_input) {
- const char *err = (const char *)ec->last_error.error_bytes_start;
- size_t error_len = ec->last_error.error_bytes_len;
- mrb_value bytes = mrb_str_new(mrb, err, error_len);
- mrb_value dumped = mrb_str_dump(mrb, bytes);
- size_t readagain_len = ec->last_error.readagain_len;
- mrb_value bytes2 = mrb_nil_value();
- mrb_value dumped2;
- int idx;
- if (ec->last_error.result == econv_incomplete_input) {
- mesg = mrb_sprintf(mrb, "incomplete %s on %s",
- //StringValueCStr(dumped),
- mrb_string_value_cstr(mrb, &dumped),
- ec->last_error.source_encoding);
- }
- else if (readagain_len) {
- bytes2 = mrb_str_new(mrb, err+error_len, readagain_len);
- dumped2 = mrb_str_dump(mrb, bytes2);
- mesg = mrb_sprintf(mrb, "%s followed by %s on %s",
- //StringValueCStr(dumped),
- mrb_string_value_cstr(mrb, &dumped),
- //StringValueCStr(dumped2),
- mrb_string_value_cstr(mrb, &dumped2),
- ec->last_error.source_encoding);
- }
- else {
- mesg = mrb_sprintf(mrb, "%s on %s",
- //StringValueCStr(dumped),
- mrb_string_value_cstr(mrb, &dumped),
- ec->last_error.source_encoding);
+ {
+ const char *err = (const char *)ec->last_error.error_bytes_start;
+ size_t error_len = ec->last_error.error_bytes_len;
+ mrb_value bytes = mrb_str_new(mrb, err, error_len);
+ mrb_value dumped = mrb_str_dump(mrb, bytes);
+ size_t readagain_len = ec->last_error.readagain_len;
+ mrb_value bytes2 = mrb_nil_value();
+ mrb_value dumped2;
+ if (ec->last_error.result == econv_incomplete_input) {
+ mesg = mrb_sprintf(mrb, "incomplete %s on %s",
+ //StringValueCStr(dumped),
+ mrb_string_value_cstr(mrb, &dumped),
+ ec->last_error.source_encoding);
+ }
+ else if (readagain_len) {
+ bytes2 = mrb_str_new(mrb, err+error_len, readagain_len);
+ dumped2 = mrb_str_dump(mrb, bytes2);
+ mesg = mrb_sprintf(mrb, "%s followed by %s on %s",
+ //StringValueCStr(dumped),
+ mrb_string_value_cstr(mrb, &dumped),
+ //StringValueCStr(dumped2),
+ mrb_string_value_cstr(mrb, &dumped2),
+ ec->last_error.source_encoding);
+ }
+ else {
+ mesg = mrb_sprintf(mrb, "%s on %s",
+ //StringValueCStr(dumped),
+ mrb_string_value_cstr(mrb, &dumped),
+ ec->last_error.source_encoding);
+ }
+
+ exc = mrb_exc_new3(mrb, E_INVALIDBYTESEQUENCE_ERROR, mesg);
+ mrb_iv_set(mrb, exc, mrb_intern(mrb, "error_bytes"), bytes);
+ mrb_iv_set(mrb, exc, mrb_intern(mrb, "readagain_bytes"), bytes2);
+ mrb_iv_set(mrb, exc, mrb_intern(mrb, "incomplete_input"), ec->last_error.result == econv_incomplete_input ? mrb_true_value() : mrb_false_value());
}
- exc = mrb_exc_new3(mrb, E_INVALIDBYTESEQUENCE_ERROR, mesg);
- mrb_iv_set(mrb, exc, mrb_intern(mrb, "error_bytes"), bytes);
- mrb_iv_set(mrb, exc, mrb_intern(mrb, "readagain_bytes"), bytes2);
- mrb_iv_set(mrb, exc, mrb_intern(mrb, "incomplete_input"), ec->last_error.result == econv_incomplete_input ? mrb_true_value() : mrb_false_value());
-
set_encs:
mrb_iv_set(mrb, exc, mrb_intern(mrb, "source_encoding_name"), mrb_str_new2(mrb, ec->last_error.source_encoding));
mrb_iv_set(mrb, exc, mrb_intern(mrb, "destination_encoding_name"), mrb_str_new2(mrb, ec->last_error.destination_encoding));
- idx = mrb_enc_find_index(mrb, ec->last_error.source_encoding);
- if (0 <= idx)
- mrb_iv_set(mrb, exc, mrb_intern(mrb, "source_encoding"), mrb_enc_from_encoding(mrb, mrb_enc_from_index(mrb, idx)));
- idx = mrb_enc_find_index(mrb, ec->last_error.destination_encoding);
- if (0 <= idx)
- mrb_iv_set(mrb, exc, mrb_intern(mrb, "destination_encoding"), mrb_enc_from_encoding(mrb, mrb_enc_from_index(mrb, idx)));
+ {
+ int idx = mrb_enc_find_index(mrb, ec->last_error.source_encoding);
+ if (0 <= idx)
+ mrb_iv_set(mrb, exc, mrb_intern(mrb, "source_encoding"), mrb_enc_from_encoding(mrb, mrb_enc_from_index(mrb, idx)));
+ idx = mrb_enc_find_index(mrb, ec->last_error.destination_encoding);
+ if (0 <= idx)
+ mrb_iv_set(mrb, exc, mrb_intern(mrb, "destination_encoding"), mrb_enc_from_encoding(mrb, mrb_enc_from_index(mrb, idx)));
+ }
return exc;
}
if (ec->last_error.result == econv_undefined_conversion) {