mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
cast style consistency
This commit is contained in:
+1
-1
@@ -49,7 +49,7 @@ mrb_ary_new_capa(mrb_state *mrb, size_t capa)
|
||||
mrb_raise(mrb, E_ARGUMENT_ERROR, "ary size too big");
|
||||
}
|
||||
|
||||
a = (struct RArray *) mrb_obj_alloc(mrb, MRB_TT_ARRAY, mrb->array_class);
|
||||
a = (struct RArray*)mrb_obj_alloc(mrb, MRB_TT_ARRAY, mrb->array_class);
|
||||
a->buf = mrb_malloc(mrb, blen);
|
||||
memset(a->buf, 0, blen);
|
||||
a->capa = capa;
|
||||
|
||||
+8
-8
@@ -108,7 +108,7 @@ make_metaclass(mrb_state *mrb, struct RClass *c)
|
||||
if (c->c->tt == MRB_TT_SCLASS) {
|
||||
return;
|
||||
}
|
||||
sc = (struct RClass *) mrb_obj_alloc(mrb, MRB_TT_SCLASS, mrb->class_class);
|
||||
sc = (struct RClass*)mrb_obj_alloc(mrb, MRB_TT_SCLASS, mrb->class_class);
|
||||
sc->mt = 0;
|
||||
if (!c->super) {
|
||||
sc->super = mrb->class_class;
|
||||
@@ -500,7 +500,7 @@ boot_defclass(mrb_state *mrb, struct RClass *super)
|
||||
{
|
||||
struct RClass *c;
|
||||
|
||||
c = (struct RClass *) mrb_obj_alloc(mrb, MRB_TT_CLASS, mrb->class_class);
|
||||
c = (struct RClass*)mrb_obj_alloc(mrb, MRB_TT_CLASS, mrb->class_class);
|
||||
c->super = super ? super : mrb->object_class;
|
||||
mrb_field_write_barrier(mrb, (struct RBasic*)c, (struct RBasic*)super);
|
||||
c->mt = kh_init(mt, mrb);
|
||||
@@ -512,7 +512,7 @@ mrb_include_module(mrb_state *mrb, struct RClass *c, struct RClass *m)
|
||||
{
|
||||
struct RClass *ic;
|
||||
|
||||
ic = (struct RClass *) mrb_obj_alloc(mrb, MRB_TT_ICLASS, mrb->class_class);
|
||||
ic = (struct RClass*)mrb_obj_alloc(mrb, MRB_TT_ICLASS, mrb->class_class);
|
||||
ic->c = m;
|
||||
ic->mt = m->mt;
|
||||
ic->iv = m->iv;
|
||||
@@ -540,7 +540,7 @@ mrb_singleton_class_ptr(mrb_state *mrb, struct RClass *c)
|
||||
if (c->tt == MRB_TT_SCLASS) {
|
||||
return c;
|
||||
}
|
||||
sc = (struct RClass *) mrb_obj_alloc(mrb, MRB_TT_SCLASS, mrb->class_class);
|
||||
sc = (struct RClass*)mrb_obj_alloc(mrb, MRB_TT_SCLASS, mrb->class_class);
|
||||
sc->mt = 0;
|
||||
sc->super = c;
|
||||
mrb_field_write_barrier(mrb, (struct RBasic*)sc, (struct RBasic*)c);
|
||||
@@ -668,7 +668,7 @@ mrb_value
|
||||
mrb_class_new_instance(mrb_state *mrb, int argc, mrb_value *argv, struct RClass * klass)
|
||||
{
|
||||
mrb_value obj;
|
||||
struct RClass * c = (struct RClass *) mrb_obj_alloc(mrb, klass->tt, klass);
|
||||
struct RClass * c = (struct RClass*)mrb_obj_alloc(mrb, klass->tt, klass);
|
||||
c->super = klass;
|
||||
obj = mrb_obj_value(c);
|
||||
mrb_obj_call_init(mrb, obj, argc, argv);
|
||||
@@ -686,7 +686,7 @@ mrb_class_new_instance_m(mrb_state *mrb, mrb_value klass)
|
||||
mrb_value obj;
|
||||
|
||||
mrb_get_args(mrb, "b*", &b, &argv, &argc);
|
||||
c = (struct RClass *) mrb_obj_alloc(mrb, k->tt, k);
|
||||
c = (struct RClass*)mrb_obj_alloc(mrb, k->tt, k);
|
||||
c->super = k;
|
||||
obj = mrb_obj_value(c);
|
||||
mrb_funcall_with_block(mrb, obj, "initialize", argc, argv, b);
|
||||
@@ -706,7 +706,7 @@ mrb_instance_new(mrb_state *mrb, mrb_value cv)
|
||||
int argc;
|
||||
|
||||
if (ttype == 0) ttype = MRB_TT_OBJECT;
|
||||
o = (struct RObject *) mrb_obj_alloc(mrb, ttype, c);
|
||||
o = (struct RObject*)mrb_obj_alloc(mrb, ttype, c);
|
||||
obj = mrb_obj_value(o);
|
||||
mrb_get_args(mrb, "b*", &b, &argv, &argc);
|
||||
mrb_funcall_with_block(mrb, obj, "initialize", argc, argv, b);
|
||||
@@ -895,7 +895,7 @@ mrb_class_new(mrb_state *mrb, struct RClass *super)
|
||||
struct RClass *
|
||||
mrb_module_new(mrb_state *mrb)
|
||||
{
|
||||
struct RClass *m = (struct RClass *) mrb_obj_alloc(mrb, MRB_TT_MODULE, mrb->module_class);
|
||||
struct RClass *m = (struct RClass*)mrb_obj_alloc(mrb, MRB_TT_MODULE, mrb->module_class);
|
||||
|
||||
return m;
|
||||
}
|
||||
|
||||
+14
-14
@@ -467,7 +467,7 @@ calc_crc_section(mrb_state *mrb, mrb_irep *irep, uint16_t *crc, int section)
|
||||
default: break;
|
||||
}
|
||||
|
||||
*crc = calc_crc_16_ccitt((unsigned char *)buf_top, (int)(buf - buf_top));
|
||||
*crc = calc_crc_16_ccitt((unsigned char*)buf_top, (int)(buf - buf_top));
|
||||
|
||||
mrb_free(mrb, buf_top);
|
||||
|
||||
@@ -481,15 +481,15 @@ write_rite_header(mrb_state *mrb, int top, char* bin, uint32_t rbds)
|
||||
uint16_t crc;
|
||||
int type = DUMP_TYPE_BIN;
|
||||
|
||||
binary_header = (rite_binary_header *)bin;
|
||||
binary_header = (rite_binary_header*)bin;
|
||||
|
||||
memcpy( binary_header, def_rite_binary_header, sizeof(*binary_header));
|
||||
|
||||
uint32_dump(rbds, (char *)binary_header->rbds, type);
|
||||
uint16_dump((uint16_t)mrb->irep_len, (char *)binary_header->nirep, type);
|
||||
uint16_dump((uint16_t)top, (char *)binary_header->sirep, type);
|
||||
uint32_dump(rbds, (char*)binary_header->rbds, type);
|
||||
uint16_dump((uint16_t)mrb->irep_len, (char*)binary_header->nirep, type);
|
||||
uint16_dump((uint16_t)top, (char*)binary_header->sirep, type);
|
||||
|
||||
crc = calc_crc_16_ccitt((unsigned char *)binary_header, sizeof(*binary_header));
|
||||
crc = calc_crc_16_ccitt((unsigned char*)binary_header, sizeof(*binary_header));
|
||||
bin += sizeof(*binary_header);
|
||||
uint16_dump(crc, bin, type);
|
||||
|
||||
@@ -511,20 +511,20 @@ dump_rite_header(mrb_state *mrb, int top, FILE* fp, uint32_t rbds)
|
||||
memcpy( &binary_header, def_rite_binary_header, sizeof(binary_header));
|
||||
|
||||
type = DUMP_TYPE_BIN;
|
||||
uint32_dump(rbds, (char *)&binary_header.rbds, type);
|
||||
uint16_dump((uint16_t)mrb->irep_len, (char *)&binary_header.nirep, type);
|
||||
uint16_dump((uint16_t)top, (char *)&binary_header.sirep, type);
|
||||
uint32_dump(rbds, (char*)&binary_header.rbds, type);
|
||||
uint16_dump((uint16_t)mrb->irep_len, (char*)&binary_header.nirep, type);
|
||||
uint16_dump((uint16_t)top, (char*)&binary_header.sirep, type);
|
||||
|
||||
crc = calc_crc_16_ccitt((unsigned char *)&binary_header, sizeof(binary_header));
|
||||
crc = calc_crc_16_ccitt((unsigned char*)&binary_header, sizeof(binary_header));
|
||||
|
||||
/* dump rbc header */
|
||||
memcpy( &file_header, def_rite_file_header, sizeof(file_header));
|
||||
|
||||
type = DUMP_TYPE_HEX;
|
||||
uint32_dump(rbds, (char *)&file_header.rbds, type);
|
||||
uint16_dump((uint16_t)mrb->irep_len, (char *)&file_header.nirep, type);
|
||||
uint16_dump((uint16_t)top, (char *)&file_header.sirep, type);
|
||||
uint16_dump(crc, (char *)&file_header.hcrc, type);
|
||||
uint32_dump(rbds, (char*)&file_header.rbds, type);
|
||||
uint16_dump((uint16_t)mrb->irep_len, (char*)&file_header.nirep, type);
|
||||
uint16_dump((uint16_t)top, (char*)&file_header.sirep, type);
|
||||
uint16_dump(crc, (char*)&file_header.hcrc, type);
|
||||
|
||||
if (fwrite(&file_header, sizeof(file_header), 1, fp) != 1)
|
||||
return MRB_DUMP_WRITE_FAULT;
|
||||
|
||||
+10
-10
@@ -274,8 +274,8 @@ enc_register(mrb_state *mrb, const char *name, mrb_encoding *encoding)
|
||||
return enc_register_at(mrb, index - 1, name, encoding);
|
||||
}
|
||||
|
||||
static void set_encoding_const(mrb_state *mrb, const char *, mrb_encoding *);
|
||||
int mrb_enc_registered(const char *name);
|
||||
static void set_encoding_const(mrb_state *, const char*, mrb_encoding*);
|
||||
int mrb_enc_registered(const char*);
|
||||
|
||||
static void
|
||||
enc_check_duplication(mrb_state *mrb, const char *name)
|
||||
@@ -939,11 +939,11 @@ st_foreachNew(mrb_state *mrb, st_table *tbl, enum st_retval (*func)(ANYARGS), vo
|
||||
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;
|
||||
mrb_value *arg = (mrb_value*)args;
|
||||
int iargs = mrb_fixnum(arg[0]);
|
||||
//if ((int)idx == (int)arg[0]) {
|
||||
if ((int)idx == iargs) {
|
||||
mrb_value str = mrb_usascii_str_new2(mrb, (char *)name);
|
||||
mrb_value str = mrb_usascii_str_new2(mrb, (char*)name);
|
||||
//OBJ_FREEZE(str);
|
||||
mrb_ary_push(mrb, arg[1], str);
|
||||
}
|
||||
@@ -992,7 +992,7 @@ enc_names(mrb_state *mrb, mrb_value self)
|
||||
static mrb_value
|
||||
enc_list(mrb_state *mrb, mrb_value klass)
|
||||
{
|
||||
struct RArray *ar = (struct RArray *)mrb_encoding_list.value.p;
|
||||
struct RArray *ar = (struct RArray*)mrb_encoding_list.value.p;
|
||||
mrb_value ary = mrb_ary_new_capa(mrb, 0);//mrb_ary_new2(0);
|
||||
//mrb_ary_replace_m(mrb, ary/*, mmrb_encoding_list*/);
|
||||
mrb_ary_replace(mrb, mrb_ary_ptr(ary), ar->buf, enc_table.count);
|
||||
@@ -1473,7 +1473,7 @@ static void
|
||||
set_encoding_const(mrb_state *mrb, const char *name, mrb_encoding *enc)
|
||||
{
|
||||
mrb_value encoding = mrb_enc_from_encoding(mrb, enc);
|
||||
char *s = (char *)name;
|
||||
char *s = (char*)name;
|
||||
int haslower = 0, hasupper = 0, valid = 0;
|
||||
|
||||
if (ISDIGIT(*s)) return;
|
||||
@@ -1514,7 +1514,7 @@ set_encoding_const(mrb_state *mrb, const char *name, mrb_encoding *enc)
|
||||
}
|
||||
}
|
||||
if (haslower) {
|
||||
for (s = (char *)name; *s; ++s) {
|
||||
for (s = (char*)name; *s; ++s) {
|
||||
if (ISLOWER(*s)) *s = ONIGENC_ASCII_CODE_TO_UPPER_CASE((int)*s);
|
||||
}
|
||||
mrb_define_const(mrb, ENCODE_CLASS, name, encoding);
|
||||
@@ -1525,7 +1525,7 @@ 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;
|
||||
mrb_value str = mrb_usascii_str_new2(mrb, (char *)name);
|
||||
mrb_value str = mrb_usascii_str_new2(mrb, (char*)name);
|
||||
//OBJ_FREEZE(str);
|
||||
mrb_ary_push(mrb, ary, str);
|
||||
return ST_CONTINUE;
|
||||
@@ -1557,7 +1557,7 @@ mrb_enc_name_list(mrb_state *mrb, mrb_value klass)
|
||||
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;
|
||||
mrb_value *p = (mrb_value*)arg;
|
||||
mrb_value aliases = p[0], ary = p[1];
|
||||
int idx = (int)orig;
|
||||
mrb_value key, str = mrb_ary_ref(mrb, ary, idx);//mrb_ary_entry(ary, idx);
|
||||
@@ -1573,7 +1573,7 @@ mrb_enc_aliases_enc_i(mrb_state *mrb, st_data_t name, st_data_t orig, st_data_t
|
||||
OBJ_FREEZE(str);
|
||||
mrb_ary_set(mrb, ary, idx, str);//rb_ary_store(ary, idx, str);
|
||||
}
|
||||
key = mrb_usascii_str_new2(mrb, (char *)name);
|
||||
key = mrb_usascii_str_new2(mrb, (char*)name);
|
||||
OBJ_FREEZE(key);
|
||||
mrb_hash_set(mrb, aliases, key, str);
|
||||
return ST_CONTINUE;
|
||||
|
||||
+1
-1
@@ -183,7 +183,7 @@ exc_equal(mrb_state *mrb, mrb_value exc)
|
||||
void
|
||||
mrb_exc_raise(mrb_state *mrb, mrb_value exc)
|
||||
{
|
||||
mrb->exc = (struct RObject *) mrb_object(exc);
|
||||
mrb->exc = (struct RObject*)mrb_object(exc);
|
||||
longjmp(*(jmp_buf*)mrb->jmp, 1);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,9 +23,9 @@ mrb_data_object_alloc(mrb_state *mrb, struct RClass *klass, void *ptr, const str
|
||||
{
|
||||
struct RData *data;
|
||||
|
||||
data = (struct RData *) mrb_obj_alloc(mrb, MRB_TT_DATA, klass);
|
||||
data = (struct RData*)mrb_obj_alloc(mrb, MRB_TT_DATA, klass);
|
||||
data->data = ptr;
|
||||
data->type = (struct mrb_data_type *) type;
|
||||
data->type = (struct mrb_data_type*) type;
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -320,7 +320,7 @@ gc_mark_children(mrb_state *mrb, struct RBasic *obj)
|
||||
|
||||
case MRB_TT_ENV:
|
||||
{
|
||||
struct REnv *e = (struct REnv *)obj;
|
||||
struct REnv *e = (struct REnv*)obj;
|
||||
|
||||
if (e->cioff < 0) {
|
||||
int i, len;
|
||||
@@ -427,7 +427,7 @@ obj_free(mrb_state *mrb, struct RBasic *obj)
|
||||
|
||||
case MRB_TT_ENV:
|
||||
{
|
||||
struct REnv *e = (struct REnv *)obj;
|
||||
struct REnv *e = (struct REnv*)obj;
|
||||
|
||||
if (e->cioff < 0) {
|
||||
mrb_free(mrb, e->stack);
|
||||
@@ -456,7 +456,7 @@ obj_free(mrb_state *mrb, struct RBasic *obj)
|
||||
|
||||
case MRB_TT_DATA:
|
||||
{
|
||||
struct RData *d = (struct RData *)obj;
|
||||
struct RData *d = (struct RData*)obj;
|
||||
if (d->type->dfree) {
|
||||
d->type->dfree(mrb, d->data);
|
||||
}
|
||||
@@ -1020,7 +1020,7 @@ test_gc_gray_mark(void)
|
||||
puts("test_gc_gray_mark");
|
||||
|
||||
puts(" in MRB_TT_CLASS");
|
||||
obj = (struct RBasic *)mrb->object_class;
|
||||
obj = (struct RBasic*)mrb->object_class;
|
||||
paint_gray(obj);
|
||||
gray_num = gc_gray_mark(mrb, obj);
|
||||
gc_assert(is_black(obj));
|
||||
@@ -1087,10 +1087,10 @@ test_incremental_gc(void)
|
||||
incremental_gc(mrb, max);
|
||||
gc_assert(mrb->gc_state == GC_STATE_NONE);
|
||||
|
||||
free = (RVALUE *)mrb->heaps->freelist;
|
||||
free = (RVALUE*)mrb->heaps->freelist;
|
||||
while (free) {
|
||||
freed++;
|
||||
free = (RVALUE *)free->as.free.next;
|
||||
free = (RVALUE*)free->as.free.next;
|
||||
}
|
||||
|
||||
gc_assert(mrb->live == live);
|
||||
|
||||
+2
-2
@@ -100,7 +100,7 @@ mrb_hash_new_capa(mrb_state *mrb, size_t capa)
|
||||
{
|
||||
struct RHash *h;
|
||||
|
||||
h = (struct RHash *) mrb_obj_alloc(mrb, MRB_TT_HASH, mrb->hash_class);
|
||||
h = (struct RHash*)mrb_obj_alloc(mrb, MRB_TT_HASH, mrb->hash_class);
|
||||
h->ht = kh_init(ht, mrb);
|
||||
kh_resize(ht, h->ht, capa);
|
||||
h->iv = 0;
|
||||
@@ -197,7 +197,7 @@ mrb_hash_dup(mrb_state *mrb, mrb_value hash)
|
||||
khash_t(ht) *h, *ret_h;
|
||||
khiter_t k, ret_k;
|
||||
|
||||
ret = (struct RHash *) mrb_obj_alloc(mrb, MRB_TT_HASH, mrb->hash_class);
|
||||
ret = (struct RHash*)mrb_obj_alloc(mrb, MRB_TT_HASH, mrb->hash_class);
|
||||
ret->ht = kh_init(ht, mrb);
|
||||
|
||||
if (!RHASH_EMPTY_P(hash)) {
|
||||
|
||||
+9
-9
@@ -22,15 +22,15 @@ void mrb_init_string(mrb_state*);
|
||||
void mrb_init_regexp(mrb_state*);
|
||||
void mrb_init_encoding(mrb_state*);
|
||||
void mrb_init_exception(mrb_state*);
|
||||
void mrb_init_time(mrb_state *);
|
||||
void mrb_init_io(mrb_state *);
|
||||
void mrb_init_file(mrb_state *);
|
||||
void mrb_init_thread(mrb_state *);
|
||||
void mrb_init_struct(mrb_state *);
|
||||
void mrb_init_gc(mrb_state *);
|
||||
void mrb_init_print(mrb_state *mrb);
|
||||
void mrb_init_mrblib(mrb_state *mrb);
|
||||
void mrb_init_math(mrb_state *mrb);
|
||||
void mrb_init_time(mrb_state*);
|
||||
void mrb_init_io(mrb_state*);
|
||||
void mrb_init_file(mrb_state*);
|
||||
void mrb_init_thread(mrb_state*);
|
||||
void mrb_init_struct(mrb_state*);
|
||||
void mrb_init_gc(mrb_state*);
|
||||
void mrb_init_print(mrb_state*);
|
||||
void mrb_init_mrblib(mrb_state*);
|
||||
void mrb_init_math(mrb_state*);
|
||||
|
||||
void
|
||||
mrb_init_core(mrb_state *mrb)
|
||||
|
||||
+2
-2
@@ -367,7 +367,7 @@ mrb_singleton_class_clone(mrb_state *mrb, mrb_value obj)
|
||||
//struct clone_method_data data;
|
||||
/* copy singleton(unnamed) class */
|
||||
//VALUE clone = class_alloc(RBASIC(klass)->flags, 0);
|
||||
struct RClass *clone = (struct RClass *) mrb_obj_alloc(mrb, klass->tt, mrb->class_class);
|
||||
struct RClass *clone = (struct RClass*)mrb_obj_alloc(mrb, klass->tt, mrb->class_class);
|
||||
//clone->super = objklass->super;
|
||||
|
||||
if ((mrb_type(obj) == MRB_TT_CLASS) ||
|
||||
@@ -452,7 +452,7 @@ mrb_obj_clone(mrb_state *mrb, mrb_value self)
|
||||
if (mrb_special_const_p(self)) {
|
||||
mrb_raise(mrb, E_TYPE_ERROR, "can't clone %s", mrb_obj_classname(mrb, self));
|
||||
}
|
||||
clone = (struct RObject *) mrb_obj_alloc(mrb, self.tt, mrb_obj_class(mrb, self));
|
||||
clone = (struct RObject*)mrb_obj_alloc(mrb, self.tt, mrb_obj_class(mrb, self));
|
||||
clone->c = mrb_singleton_class_clone(mrb, self);
|
||||
init_copy(mrb, mrb_obj_value(clone), self);
|
||||
//1-9-2 no bug mrb_funcall(mrb, clone, "initialize_clone", 1, self);
|
||||
|
||||
+4
-4
@@ -319,7 +319,7 @@ read_rite_header(mrb_state *mrb, unsigned char *bin, rite_binary_header* bin_he
|
||||
return MRB_DUMP_INVALID_FILE_HEADER; //Instruction set version check
|
||||
}
|
||||
|
||||
crc = calc_crc_16_ccitt((unsigned char *)bin_header, sizeof(*bin_header)); //Calculate CRC
|
||||
crc = calc_crc_16_ccitt((unsigned char*)bin_header, sizeof(*bin_header)); //Calculate CRC
|
||||
if (crc != bin_to_uint16(bin)) {
|
||||
return MRB_DUMP_INVALID_FILE_HEADER; //CRC error
|
||||
}
|
||||
@@ -376,7 +376,7 @@ read_rite_irep_record(mrb_state *mrb, unsigned char *src, mrb_irep *irep, uint32
|
||||
src += MRB_DUMP_SIZE_OF_LONG;
|
||||
}
|
||||
}
|
||||
crc = calc_crc_16_ccitt((unsigned char *)pStart, src - pStart); //Calculate CRC
|
||||
crc = calc_crc_16_ccitt((unsigned char*)pStart, src - pStart); //Calculate CRC
|
||||
if (crc != bin_to_uint16(src)) { //iseq CRC
|
||||
ret = MRB_DUMP_INVALID_IREP;
|
||||
goto error_exit;
|
||||
@@ -439,7 +439,7 @@ read_rite_irep_record(mrb_state *mrb, unsigned char *src, mrb_irep *irep, uint32
|
||||
}
|
||||
}
|
||||
}
|
||||
crc = calc_crc_16_ccitt((unsigned char *)pStart, src - pStart); //Calculate CRC
|
||||
crc = calc_crc_16_ccitt((unsigned char*)pStart, src - pStart); //Calculate CRC
|
||||
if (crc != bin_to_uint16(src)) { //pool CRC
|
||||
ret = MRB_DUMP_INVALID_IREP;
|
||||
goto error_exit;
|
||||
@@ -480,7 +480,7 @@ read_rite_irep_record(mrb_state *mrb, unsigned char *src, mrb_irep *irep, uint32
|
||||
irep->syms[i] = mrb_intern(mrb, buf);
|
||||
}
|
||||
}
|
||||
crc = calc_crc_16_ccitt((unsigned char *)pStart, src - pStart); //Calculate CRC
|
||||
crc = calc_crc_16_ccitt((unsigned char*)pStart, src - pStart); //Calculate CRC
|
||||
if (crc != bin_to_uint16(src)) { //syms CRC
|
||||
ret = MRB_DUMP_INVALID_IREP;
|
||||
goto error_exit;
|
||||
|
||||
+3
-3
@@ -15,7 +15,7 @@ mrb_proc_new(mrb_state *mrb, mrb_irep *irep)
|
||||
{
|
||||
struct RProc *p;
|
||||
|
||||
p = (struct RProc *) mrb_obj_alloc(mrb, MRB_TT_PROC, mrb->proc_class);
|
||||
p = (struct RProc*)mrb_obj_alloc(mrb, MRB_TT_PROC, mrb->proc_class);
|
||||
p->body.irep = irep;
|
||||
p->target_class = (mrb->ci) ? mrb->ci->target_class : 0;
|
||||
p->env = 0;
|
||||
@@ -30,7 +30,7 @@ mrb_closure_new(mrb_state *mrb, mrb_irep *irep)
|
||||
struct REnv *e;
|
||||
|
||||
if (!mrb->ci->env) {
|
||||
e = (struct REnv *) mrb_obj_alloc(mrb, MRB_TT_ENV, (struct RClass *) mrb->ci->proc->env);
|
||||
e = (struct REnv*)mrb_obj_alloc(mrb, MRB_TT_ENV, (struct RClass*)mrb->ci->proc->env);
|
||||
e->flags= (unsigned int)mrb->ci->proc->body.irep->nlocals;
|
||||
e->mid = mrb->ci->mid;
|
||||
e->cioff = mrb->ci - mrb->cibase;
|
||||
@@ -49,7 +49,7 @@ mrb_proc_new_cfunc(mrb_state *mrb, mrb_func_t func)
|
||||
{
|
||||
struct RProc *p;
|
||||
|
||||
p = (struct RProc *) mrb_obj_alloc(mrb, MRB_TT_PROC, mrb->proc_class);
|
||||
p = (struct RProc*)mrb_obj_alloc(mrb, MRB_TT_PROC, mrb->proc_class);
|
||||
p->body.func = func;
|
||||
p->flags |= MRB_PROC_CFUNC;
|
||||
|
||||
|
||||
+1
-1
@@ -37,7 +37,7 @@ mrb_range_new(mrb_state *mrb, mrb_value beg, mrb_value end, int excl)
|
||||
{
|
||||
struct RRange *r;
|
||||
|
||||
r = (struct RRange *) mrb_obj_alloc(mrb, MRB_TT_RANGE, RANGE_CLASS);
|
||||
r = (struct RRange*)mrb_obj_alloc(mrb, MRB_TT_RANGE, RANGE_CLASS);
|
||||
r->edges = mrb_malloc(mrb, sizeof(struct mrb_range_edges));
|
||||
r->edges->beg = beg;
|
||||
r->edges->end = end;
|
||||
|
||||
@@ -49,9 +49,9 @@ typedef char onig_errmsg_buffer[ONIG_MAX_ERROR_MESSAGE_LEN];
|
||||
#define mrb_bug printf
|
||||
#define KCODE_FIXED FL_USER4
|
||||
#define scan_oct(s,l,e) (int)ruby_scan_oct(s,l,e)
|
||||
unsigned long ruby_scan_oct(const char *, size_t, size_t *);
|
||||
unsigned long ruby_scan_oct(const char*, size_t, size_t*);
|
||||
#define scan_hex(s,l,e) (int)ruby_scan_hex(s,l,e)
|
||||
unsigned long ruby_scan_hex(const char *, size_t, size_t *);
|
||||
unsigned long ruby_scan_hex(const char*, size_t, size_t*);
|
||||
|
||||
static mrb_value mrb_match_to_a(mrb_state *mrb, mrb_value match);
|
||||
static mrb_value mrb_reg_preprocess(mrb_state *mrb, const char *p, const char *end, mrb_encoding *enc,
|
||||
@@ -88,7 +88,7 @@ mrb_reg_s_new_instance(mrb_state *mrb, /*int argc, mrb_value *argv, */mrb_value
|
||||
struct RRegexp *re;
|
||||
|
||||
mrb_get_args(mrb, "*", &argv, &argc);
|
||||
re = (struct RRegexp *) mrb_obj_alloc(mrb, MRB_TT_REGEX, REGEX_CLASS);
|
||||
re = (struct RRegexp*)mrb_obj_alloc(mrb, MRB_TT_REGEX, REGEX_CLASS);
|
||||
re->ptr = 0;
|
||||
re->src = 0;
|
||||
re->usecnt = 0;
|
||||
@@ -1665,7 +1665,7 @@ match_alloc(mrb_state *mrb)
|
||||
{
|
||||
struct RMatch* m;
|
||||
|
||||
m = (struct RMatch *) mrb_obj_alloc(mrb, MRB_TT_MATCH, MATCH_CLASS);
|
||||
m = (struct RMatch*)mrb_obj_alloc(mrb, MRB_TT_MATCH, MATCH_CLASS);
|
||||
|
||||
m->str = 0;
|
||||
m->rmatch = 0;
|
||||
@@ -2453,7 +2453,7 @@ mrb_reg_s_alloc(mrb_state *mrb, mrb_value dummy)
|
||||
|
||||
//NEWOBJ(re, struct RRegexp);
|
||||
//OBJSETUP(re, klass, T_REGEXP);
|
||||
re = (struct RRegexp *) mrb_obj_alloc(mrb, MRB_TT_REGEX, REGEX_CLASS);
|
||||
re = (struct RRegexp*)mrb_obj_alloc(mrb, MRB_TT_REGEX, REGEX_CLASS);
|
||||
|
||||
re->ptr = 0;
|
||||
re->src = 0;
|
||||
@@ -2506,7 +2506,7 @@ static int
|
||||
match_inspect_name_iter(const OnigUChar *name, const OnigUChar *name_end,
|
||||
int back_num, int *back_refs, OnigRegex regex, void *arg0)
|
||||
{
|
||||
struct backref_name_tag *arg = (struct backref_name_tag *)arg0;
|
||||
struct backref_name_tag *arg = (struct backref_name_tag*)arg0;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < back_num; i++) {
|
||||
@@ -2548,11 +2548,11 @@ mrb_match_inspect(mrb_state *mrb, mrb_value match)
|
||||
mrb_str_buf_cat(mrb, str, " ", strlen(" "));//mrb_str_buf_cat2(str, " ");
|
||||
if (0 < i) {
|
||||
if (names[i].name)
|
||||
mrb_str_buf_cat(mrb, str, (const char *)names[i].name, names[i].len);
|
||||
mrb_str_buf_cat(mrb, str, (const char*)names[i].name, names[i].len);
|
||||
else {
|
||||
//mrb_str_catf(mrb, str, "%d", i);
|
||||
sprintf(buf, "%d", i);
|
||||
mrb_str_buf_cat(mrb, str, (const char *)buf, strlen(buf));
|
||||
mrb_str_buf_cat(mrb, str, (const char*)buf, strlen(buf));
|
||||
}
|
||||
mrb_str_buf_cat(mrb, str, ":", strlen(":"));//mrb_str_buf_cat2(str, ":");
|
||||
}
|
||||
|
||||
+2
-2
@@ -1298,9 +1298,9 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
|
||||
(int )(end - str), (int )(sstart - str));
|
||||
#endif
|
||||
|
||||
STACK_PUSH_ENSURED(STK_ALT, (UChar *)FinishCode); /* bottom stack */
|
||||
STACK_PUSH_ENSURED(STK_ALT, (UChar*)FinishCode); /* bottom stack */
|
||||
best_len = ONIG_MISMATCH;
|
||||
s = (UChar* )sstart;
|
||||
s = (UChar*)sstart;
|
||||
while (1) {
|
||||
#ifdef ONIG_DEBUG_MATCH
|
||||
if (s) {
|
||||
|
||||
+6
-6
@@ -317,8 +317,8 @@ str_end_cmp(st_data_t xp, st_data_t yp)
|
||||
const UChar *p, *q;
|
||||
int c;
|
||||
|
||||
x = (const st_str_end_key *)xp;
|
||||
y = (const st_str_end_key *)yp;
|
||||
x = (const st_str_end_key*)xp;
|
||||
y = (const st_str_end_key*)yp;
|
||||
if ((x->end - x->s) != (y->end - y->s))
|
||||
return 1;
|
||||
|
||||
@@ -337,7 +337,7 @@ str_end_cmp(st_data_t xp, st_data_t yp)
|
||||
static st_index_t
|
||||
str_end_hash(st_data_t xp)
|
||||
{
|
||||
const st_str_end_key *x = (const st_str_end_key *)xp;
|
||||
const st_str_end_key *x = (const st_str_end_key*)xp;
|
||||
const UChar *p;
|
||||
st_index_t val = 0;
|
||||
|
||||
@@ -2799,12 +2799,12 @@ onig_syntax_warn(ScanEnv *env, const char *fmt, ...)
|
||||
va_start(args, fmt);
|
||||
onig_vsnprintf_with_pattern(buf, WARN_BUFSIZE, env->enc,
|
||||
env->pattern, env->pattern_end,
|
||||
(const UChar *)fmt, args);
|
||||
(const UChar*)fmt, args);
|
||||
va_end(args);
|
||||
if (env->sourcefile == NULL)
|
||||
mrb_warn("%s", (char *)buf);
|
||||
mrb_warn("%s", (char*)buf);
|
||||
else
|
||||
mrb_compile_warn(env->sourcefile, env->sourceline, "%s", (char *)buf);
|
||||
mrb_compile_warn(env->sourcefile, env->sourceline, "%s", (char*)buf);
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -29,7 +29,7 @@ static struct st_hash_type type_numhash = {
|
||||
};
|
||||
|
||||
/* extern int strcmp(const char *, const char *); */
|
||||
static st_index_t strhash(const char *);
|
||||
static st_index_t strhash(const char*);
|
||||
static struct st_hash_type type_strhash = {
|
||||
strcmp,
|
||||
strhash,
|
||||
@@ -41,7 +41,7 @@ static const struct st_hash_type type_strcasehash = {
|
||||
strcasehash,
|
||||
};
|
||||
|
||||
static void rehash(st_table *);
|
||||
static void rehash(st_table*);
|
||||
|
||||
#ifdef RUBY
|
||||
#define malloc xmalloc
|
||||
@@ -542,7 +542,7 @@ st_strncasecmp(const char *s1, const char *s2, size_t n)
|
||||
static st_index_t
|
||||
strcasehash(st_data_t arg)
|
||||
{
|
||||
register const char *string = (const char *)arg;
|
||||
register const char *string = (const char*)arg;
|
||||
register st_index_t hval = FNV1_32A_INIT;
|
||||
|
||||
/*
|
||||
|
||||
+7
-7
@@ -291,7 +291,7 @@ mrb_str_capacity(mrb_value str)
|
||||
}
|
||||
#endif //INCLUDE_ENCODING
|
||||
|
||||
#define mrb_obj_alloc_string(mrb) ((struct RString *) mrb_obj_alloc((mrb), MRB_TT_STRING, (mrb)->string_class))
|
||||
#define mrb_obj_alloc_string(mrb) ((struct RString*)mrb_obj_alloc((mrb), MRB_TT_STRING, (mrb)->string_class))
|
||||
|
||||
static inline mrb_value
|
||||
str_alloc(mrb_state *mrb)
|
||||
@@ -413,11 +413,11 @@ mrb_enc_nth(mrb_state *mrb, const char *p, const char *e, long nth, mrb_encoding
|
||||
while (p < e && 0 < nth) {
|
||||
e2 = p + nth;
|
||||
if (e < e2)
|
||||
return (char *)e;
|
||||
return (char*)e;
|
||||
if (ISASCII(*p)) {
|
||||
p2 = search_nonascii(p, e2);
|
||||
if (!p2)
|
||||
return (char *)e2;
|
||||
return (char*)e2;
|
||||
nth -= p2 - p;
|
||||
p = p2;
|
||||
}
|
||||
@@ -426,8 +426,8 @@ mrb_enc_nth(mrb_state *mrb, const char *p, const char *e, long nth, mrb_encoding
|
||||
nth--;
|
||||
}
|
||||
if (nth != 0)
|
||||
return (char *)e;
|
||||
return (char *)p;
|
||||
return (char*)e;
|
||||
return (char*)p;
|
||||
}
|
||||
else {
|
||||
while (p<e && nth--) {
|
||||
@@ -448,7 +448,7 @@ str_nth(mrb_state *mrb, const char *p, const char *e, long nth, mrb_encoding *en
|
||||
}
|
||||
if (!p) return 0;
|
||||
if (p > e) p = e;
|
||||
return (char *)p;
|
||||
return (char*)p;
|
||||
}
|
||||
|
||||
/* char offset to byte offset */
|
||||
@@ -4702,7 +4702,7 @@ mrb_str_vcatf(mrb_state *mrb, mrb_value str, const char *fmt, va_list ap)
|
||||
//StringValue(str);
|
||||
mrb_string_value(mrb, &str);
|
||||
mrb_str_modify(mrb, str);
|
||||
mrb_str_resize(mrb, str, (char *)RSTRING_END(str) - RSTRING_PTR(str));
|
||||
mrb_str_resize(mrb, str, (char*)RSTRING_END(str) - RSTRING_PTR(str));
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
+46
-46
@@ -191,7 +191,7 @@ make_transcoder_entry(const char *sname, const char *dname)
|
||||
val = (st_data_t)st_init_strcasetable();
|
||||
st_add_direct(transcoder_table, (st_data_t)sname, val);
|
||||
}
|
||||
table2 = (st_table *)val;
|
||||
table2 = (st_table*)val;
|
||||
if (!st_lookup(table2, (st_data_t)dname, &val)) {
|
||||
transcoder_entry_t *entry = malloc(sizeof(transcoder_entry_t));
|
||||
entry->sname = sname;
|
||||
@@ -201,7 +201,7 @@ make_transcoder_entry(const char *sname, const char *dname)
|
||||
val = (st_data_t)entry;
|
||||
st_add_direct(table2, (st_data_t)dname, val);
|
||||
}
|
||||
return (transcoder_entry_t *)val;
|
||||
return (transcoder_entry_t*)val;
|
||||
}
|
||||
|
||||
static transcoder_entry_t *
|
||||
@@ -213,11 +213,11 @@ get_transcoder_entry(const char *sname, const char *dname)
|
||||
if (!st_lookup(transcoder_table, (st_data_t)sname, &val)) {
|
||||
return NULL;
|
||||
}
|
||||
table2 = (st_table *)val;
|
||||
table2 = (st_table*)val;
|
||||
if (!st_lookup(table2, (st_data_t)dname, &val)) {
|
||||
return NULL;
|
||||
}
|
||||
return (transcoder_entry_t *)val;
|
||||
return (transcoder_entry_t*)val;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -276,8 +276,8 @@ typedef struct {
|
||||
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;
|
||||
search_path_bfs_t *bfs = (search_path_bfs_t *)arg;
|
||||
const char *dname = (const char*)key;
|
||||
search_path_bfs_t *bfs = (search_path_bfs_t*)arg;
|
||||
search_path_queue_t *q;
|
||||
|
||||
if (st_lookup(bfs->visited, (st_data_t)dname, &val)) {
|
||||
@@ -328,7 +328,7 @@ transcode_search_path(mrb_state *mrb, const char *sname, const char *dname,
|
||||
xfree(q);
|
||||
continue;
|
||||
}
|
||||
table2 = (st_table *)val;
|
||||
table2 = (st_table*)val;
|
||||
|
||||
if (st_lookup(table2, (st_data_t)dname, &val)) {
|
||||
st_add_direct(bfs.visited, (st_data_t)dname, (st_data_t)q->enc);
|
||||
@@ -361,7 +361,7 @@ transcode_search_path(mrb_state *mrb, const char *sname, const char *dname,
|
||||
if (!val)
|
||||
break;
|
||||
pathlen++;
|
||||
enc = (const char *)val;
|
||||
enc = (const char*)val;
|
||||
}
|
||||
depth = pathlen;
|
||||
enc = dname;
|
||||
@@ -369,8 +369,8 @@ transcode_search_path(mrb_state *mrb, const char *sname, const char *dname,
|
||||
st_lookup(bfs.visited, (st_data_t)enc, &val);
|
||||
if (!val)
|
||||
break;
|
||||
callback(mrb, (const char *)val, enc, --depth, arg);
|
||||
enc = (const char *)val;
|
||||
callback(mrb, (const char*)val, enc, --depth, arg);
|
||||
enc = (const char*)val;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1037,7 +1037,7 @@ mrb_econv_open0(mrb_state *mrb, const char *sname, const char *dname, int ecflag
|
||||
struct trans_open_t toarg;
|
||||
toarg.entries = NULL;
|
||||
toarg.num_additional = 0;
|
||||
num_trans = transcode_search_path(mrb, sname, dname, trans_open_i, (void *)&toarg);
|
||||
num_trans = transcode_search_path(mrb, sname, dname, trans_open_i, (void*)&toarg);
|
||||
entries = toarg.entries;
|
||||
if (num_trans < 0) {
|
||||
xfree(entries);
|
||||
@@ -1457,7 +1457,7 @@ output_hex_charref(mrb_state *mrb, mrb_econv_t *ec)
|
||||
u += p[3];
|
||||
snprintf(charef_buf, sizeof(charef_buf), "&#x%X;", u);
|
||||
|
||||
ret = mrb_econv_insert_output(mrb, ec, (unsigned char *)charef_buf, strlen(charef_buf), "US-ASCII");
|
||||
ret = mrb_econv_insert_output(mrb, ec, (unsigned char*)charef_buf, strlen(charef_buf), "US-ASCII");
|
||||
if (ret == -1)
|
||||
goto fail;
|
||||
|
||||
@@ -1466,12 +1466,12 @@ output_hex_charref(mrb_state *mrb, mrb_econv_t *ec)
|
||||
}
|
||||
|
||||
if (utf_allocated)
|
||||
xfree((void *)utf);
|
||||
xfree((void*)utf);
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
if (utf_allocated)
|
||||
xfree((void *)utf);
|
||||
xfree((void*)utf);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -1738,7 +1738,7 @@ mrb_econv_close(mrb_econv_t *ec)
|
||||
int i;
|
||||
|
||||
if (ec->replacement_allocated) {
|
||||
xfree((void *)ec->replacement_str);
|
||||
xfree((void*)ec->replacement_str);
|
||||
}
|
||||
for (i = 0; i < ec->num_trans; i++) {
|
||||
mrb_transcoding_close(ec->elems[i].tc);
|
||||
@@ -1802,8 +1802,8 @@ struct asciicompat_encoding_t {
|
||||
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;
|
||||
transcoder_entry_t *entry = (transcoder_entry_t *)val;
|
||||
struct asciicompat_encoding_t *data = (struct asciicompat_encoding_t*)arg;
|
||||
transcoder_entry_t *entry = (transcoder_entry_t*)val;
|
||||
const mrb_transcoder *tr;
|
||||
|
||||
if (DECORATOR_P(entry->sname, entry->dname))
|
||||
@@ -1825,7 +1825,7 @@ mrb_econv_asciicompat_encoding(const char *ascii_incompat_name)
|
||||
|
||||
if (!st_lookup(transcoder_table, (st_data_t)ascii_incompat_name, &v))
|
||||
return NULL;
|
||||
table2 = (st_table *)v;
|
||||
table2 = (st_table*)v;
|
||||
|
||||
/*
|
||||
* Assumption:
|
||||
@@ -1872,9 +1872,9 @@ mrb_econv_substr_append(mrb_state *mrb, mrb_econv_t *ec, mrb_value src, long off
|
||||
mrb_str_resize(mrb, dst, new_capa);
|
||||
mrb_str_set_len(mrb, dst, dlen);
|
||||
}
|
||||
ss = sp = (const unsigned char *)RSTRING_PTR(src) + off;
|
||||
ss = sp = (const unsigned char*)RSTRING_PTR(src) + off;
|
||||
se = ss + len;
|
||||
ds = (unsigned char *)RSTRING_PTR(dst);
|
||||
ds = (unsigned char*)RSTRING_PTR(dst);
|
||||
de = ds + mrb_str_capacity(dst);
|
||||
dp = ds += dlen;
|
||||
res = mrb_econv_convert(mrb, ec, &sp, se, &dp, de, flags);
|
||||
@@ -2088,7 +2088,7 @@ make_econv_exception(mrb_state *mrb, mrb_econv_t *ec)
|
||||
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;
|
||||
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);
|
||||
@@ -2138,7 +2138,7 @@ set_encs:
|
||||
return exc;
|
||||
}
|
||||
if (ec->last_error.result == econv_undefined_conversion) {
|
||||
mrb_value bytes = mrb_str_new(mrb, (const char *)ec->last_error.error_bytes_start,
|
||||
mrb_value bytes = mrb_str_new(mrb, (const char*)ec->last_error.error_bytes_start,
|
||||
ec->last_error.error_bytes_len);
|
||||
mrb_value dumped = mrb_nil_value();
|
||||
int idx;
|
||||
@@ -2146,7 +2146,7 @@ set_encs:
|
||||
mrb_encoding *utf8 = mrb_utf8_encoding(mrb);
|
||||
const char *start, *end;
|
||||
int n;
|
||||
start = (const char *)ec->last_error.error_bytes_start;
|
||||
start = (const char*)ec->last_error.error_bytes_start;
|
||||
end = start + ec->last_error.error_bytes_len;
|
||||
n = mrb_enc_precise_mbclen(start, end, utf8);
|
||||
if (MBCLEN_CHARFOUND_P(n) &&
|
||||
@@ -2227,10 +2227,10 @@ make_replacement(mrb_state *mrb, mrb_econv_t *ec)
|
||||
if (*ins_enc) {
|
||||
tr = tc->transcoder;
|
||||
enc = mrb_enc_find(mrb, tr->dst_encoding);
|
||||
replacement = (const unsigned char *)get_replacement_character(ins_enc, &len, &repl_enc);
|
||||
replacement = (const unsigned char*)get_replacement_character(ins_enc, &len, &repl_enc);
|
||||
}
|
||||
else {
|
||||
replacement = (unsigned char *)"?";
|
||||
replacement = (unsigned char*)"?";
|
||||
len = 1;
|
||||
repl_enc = "";
|
||||
}
|
||||
@@ -2265,7 +2265,7 @@ mrb_econv_set_replacement(mrb_state *mrb, mrb_econv_t *ec,
|
||||
}
|
||||
|
||||
if (ec->replacement_allocated) {
|
||||
xfree((void *)ec->replacement_str);
|
||||
xfree((void*)ec->replacement_str);
|
||||
}
|
||||
ec->replacement_allocated = 1;
|
||||
ec->replacement_str = str2;
|
||||
@@ -2324,14 +2324,14 @@ transcode_loop(mrb_state *mrb,
|
||||
|
||||
if (!mrb_nil_p(fallback) && ret == econv_undefined_conversion) {
|
||||
mrb_value rep = mrb_enc_str_new(mrb,
|
||||
(const char *)ec->last_error.error_bytes_start,
|
||||
(const char*)ec->last_error.error_bytes_start,
|
||||
ec->last_error.error_bytes_len,
|
||||
mrb_enc_find(mrb, ec->last_error.source_encoding));
|
||||
rep = mrb_hash_getWithDef(mrb, fallback, rep, Qundef);//mrb_hash_lookup2(fallback, rep, Qundef);
|
||||
if (!mrb_obj_equal(mrb, rep, Qundef)) {
|
||||
//StringValue(rep);
|
||||
mrb_string_value(mrb, &rep);
|
||||
ret = mrb_econv_insert_output(mrb, ec, (const unsigned char *)RSTRING_PTR(rep),
|
||||
ret = mrb_econv_insert_output(mrb, ec, (const unsigned char*)RSTRING_PTR(rep),
|
||||
RSTRING_LEN(rep), mrb_enc_name(mrb_enc_get(mrb, rep)));
|
||||
if ((int)ret == -1) {
|
||||
mrb_raise(mrb, E_ARGUMENT_ERROR, "too big fallback string");
|
||||
@@ -2365,7 +2365,7 @@ static unsigned char *
|
||||
str_transcoding_resize(mrb_state *mrb, mrb_value destination, size_t len, size_t new_len)
|
||||
{
|
||||
mrb_str_resize(mrb, destination, new_len);
|
||||
return (unsigned char *)RSTRING_PTR(destination);
|
||||
return (unsigned char*)RSTRING_PTR(destination);
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -2500,7 +2500,7 @@ mrb_econv_open_opts(mrb_state *mrb, const char *source_encoding, const char *des
|
||||
mrb_encoding *enc = mrb_enc_get(mrb, replacement);
|
||||
|
||||
ret = mrb_econv_set_replacement(mrb, ec,
|
||||
(const unsigned char *)RSTRING_PTR(replacement),
|
||||
(const unsigned char*)RSTRING_PTR(replacement),
|
||||
RSTRING_LEN(replacement),
|
||||
mrb_enc_name(enc));
|
||||
if (ret == -1) {
|
||||
@@ -2627,17 +2627,17 @@ str_transcode0(mrb_state *mrb, int argc, mrb_value *argv, mrb_value *self, int e
|
||||
}
|
||||
}
|
||||
|
||||
fromp = sp = (unsigned char *)RSTRING_PTR(str);
|
||||
fromp = sp = (unsigned char*)RSTRING_PTR(str);
|
||||
slen = RSTRING_LEN(str);
|
||||
blen = slen + 30; /* len + margin */
|
||||
dest = mrb_str_tmp_new(mrb, blen);
|
||||
bp = (unsigned char *)RSTRING_PTR(dest);
|
||||
bp = (unsigned char*)RSTRING_PTR(dest);
|
||||
|
||||
transcode_loop(mrb, &fromp, &bp, (sp+slen), (bp+blen), dest, str_transcoding_resize, sname, dname, ecflags, ecopts);
|
||||
if (fromp != sp+slen) {
|
||||
mrb_raise(mrb, E_ARGUMENT_ERROR, "not fully converted, %td bytes left", sp+slen-fromp);
|
||||
}
|
||||
buf = (unsigned char *)RSTRING_PTR(dest);
|
||||
buf = (unsigned char*)RSTRING_PTR(dest);
|
||||
*bp = '\0';
|
||||
mrb_str_set_len(mrb, dest, bp - buf);
|
||||
|
||||
@@ -3081,7 +3081,7 @@ struct mrb_econv_init_by_convpath_t {
|
||||
static void
|
||||
mrb_econv_init_by_convpath_i(mrb_state *mrb, const char *sname, const char *dname, int depth, void *arg)
|
||||
{
|
||||
struct mrb_econv_init_by_convpath_t *a = (struct mrb_econv_init_by_convpath_t *)arg;
|
||||
struct mrb_econv_init_by_convpath_t *a = (struct mrb_econv_init_by_convpath_t*)arg;
|
||||
int ret;
|
||||
|
||||
if (a->ret == -1)
|
||||
@@ -3528,17 +3528,17 @@ mrb_value econv_primitive_cnvproc(mrb_state *mrb, int argc, mrb_value *argv, mrb
|
||||
ip = is = NULL;
|
||||
}
|
||||
else {
|
||||
ip = (const unsigned char *)RSTRING_PTR(input);
|
||||
ip = (const unsigned char*)RSTRING_PTR(input);
|
||||
is = ip + RSTRING_LEN(input);
|
||||
}
|
||||
|
||||
op = (unsigned char *)RSTRING_PTR(output) + output_byteoffset;
|
||||
op = (unsigned char*)RSTRING_PTR(output) + output_byteoffset;
|
||||
os = op + output_bytesize;
|
||||
|
||||
res = mrb_econv_convert(mrb, ec, &ip, is, &op, os, flags);
|
||||
mrb_str_set_len(mrb, output, op-(unsigned char *)RSTRING_PTR(output));
|
||||
mrb_str_set_len(mrb, output, op-(unsigned char*)RSTRING_PTR(output));
|
||||
if (!mrb_nil_p(input))
|
||||
mrb_str_drop_bytes(mrb, input, ip - (unsigned char *)RSTRING_PTR(input));
|
||||
mrb_str_drop_bytes(mrb, input, ip - (unsigned char*)RSTRING_PTR(input));
|
||||
|
||||
if (mrb_nil_p(output_bytesize_v) && res == econv_destination_buffer_full) {
|
||||
if (LONG_MAX / 2 < output_bytesize)
|
||||
@@ -3870,10 +3870,10 @@ econv_primitive_errinfo(mrb_state *mrb, mrb_value self)
|
||||
mrb_ary_set(mrb, ary, 2, mrb_str_new2(mrb, ec->last_error.destination_encoding));//rb_ary_store(ary, 2, mrb_str_new2(mrb, ec->last_error.destination_encoding));
|
||||
|
||||
if (ec->last_error.error_bytes_start) {
|
||||
//rb_ary_store(ary, 3, mrb_str_new(mrb, (const char *)ec->last_error.error_bytes_start, ec->last_error.error_bytes_len));
|
||||
mrb_ary_set(mrb, ary, 3, mrb_str_new(mrb, (const char *)ec->last_error.error_bytes_start, ec->last_error.error_bytes_len));
|
||||
//rb_ary_store(ary, 4, mrb_str_new(mrb, (const char *)ec->last_error.error_bytes_start + ec->last_error.error_bytes_len, ec->last_error.readagain_len));
|
||||
mrb_ary_set(mrb, ary, 4, mrb_str_new(mrb, (const char *)ec->last_error.error_bytes_start + ec->last_error.error_bytes_len, ec->last_error.readagain_len));
|
||||
//rb_ary_store(ary, 3, mrb_str_new(mrb, (const char*)ec->last_error.error_bytes_start, ec->last_error.error_bytes_len));
|
||||
mrb_ary_set(mrb, ary, 3, mrb_str_new(mrb, (const char*)ec->last_error.error_bytes_start, ec->last_error.error_bytes_len));
|
||||
//rb_ary_store(ary, 4, mrb_str_new(mrb, (const char*)ec->last_error.error_bytes_start + ec->last_error.error_bytes_len, ec->last_error.readagain_len));
|
||||
mrb_ary_set(mrb, ary, 4, mrb_str_new(mrb, (const char*)ec->last_error.error_bytes_start + ec->last_error.error_bytes_len, ec->last_error.readagain_len));
|
||||
}
|
||||
|
||||
return ary;
|
||||
@@ -3927,7 +3927,7 @@ econv_insert_output(mrb_state *mrb, mrb_value self)
|
||||
insert_enc = mrb_econv_encoding_to_insert_output(ec);
|
||||
string = mrb_str_encode(mrb, string, mrb_enc_from_encoding(mrb, mrb_enc_find(mrb, insert_enc)), 0, mrb_nil_value());
|
||||
|
||||
ret = mrb_econv_insert_output(mrb, ec, (const unsigned char *)RSTRING_PTR(string), RSTRING_LEN(string), insert_enc);
|
||||
ret = mrb_econv_insert_output(mrb, ec, (const unsigned char*)RSTRING_PTR(string), RSTRING_LEN(string), insert_enc);
|
||||
if (ret == -1) {
|
||||
mrb_raise(mrb, E_ARGUMENT_ERROR, "too big string");
|
||||
}
|
||||
@@ -3984,7 +3984,7 @@ econv_putback(mrb_state *mrb, /*int argc, mrb_value *argv,*/ mrb_value self)
|
||||
}
|
||||
|
||||
str = mrb_str_new(mrb, NULL, n);
|
||||
mrb_econv_putback(ec, (unsigned char *)RSTRING_PTR(str), n);
|
||||
mrb_econv_putback(ec, (unsigned char*)RSTRING_PTR(str), n);
|
||||
|
||||
if (ec->source_encoding) {
|
||||
mrb_enc_associate(mrb, str, ec->source_encoding);
|
||||
@@ -4050,7 +4050,7 @@ econv_get_replacement(mrb_state *mrb, mrb_value self)
|
||||
}
|
||||
|
||||
enc = mrb_enc_find(mrb, ec->replacement_enc);
|
||||
return mrb_enc_str_new(mrb, (const char *)ec->replacement_str, (long)ec->replacement_len, enc);
|
||||
return mrb_enc_str_new(mrb, (const char*)ec->replacement_str, (long)ec->replacement_len, enc);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -4078,7 +4078,7 @@ econv_set_replacement(mrb_state *mrb, mrb_value self)
|
||||
enc = mrb_enc_get(mrb, string);
|
||||
|
||||
ret = mrb_econv_set_replacement(mrb, ec,
|
||||
(const unsigned char *)RSTRING_PTR(string),
|
||||
(const unsigned char*)RSTRING_PTR(string),
|
||||
RSTRING_LEN(string),
|
||||
mrb_enc_name(enc));
|
||||
|
||||
|
||||
+1
-1
@@ -377,7 +377,7 @@ mrb_st_lookup(struct kh_iv *table, mrb_sym id, khiter_t *value)
|
||||
khiter_t k;
|
||||
|
||||
if (table) {
|
||||
h = (khash_t(iv) *)table;
|
||||
h = (khash_t(iv)*)table;
|
||||
k = kh_get(iv, h, id);
|
||||
if (k != kh_end(h)) {
|
||||
if (value != 0) *value = k;//kh_value(h, k);
|
||||
|
||||
@@ -279,7 +279,7 @@ localjump_error(mrb_state *mrb, const char *kind)
|
||||
|
||||
snprintf(buf, 256, "unexpected %s", kind);
|
||||
exc = mrb_exc_new(mrb, E_LOCALJUMP_ERROR, buf, strlen(buf));
|
||||
mrb->exc = (struct RObject *) mrb_object(exc);
|
||||
mrb->exc = (struct RObject*)mrb_object(exc);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -298,7 +298,7 @@ argnum_error(mrb_state *mrb, int num)
|
||||
mrb->ci->argc, num);
|
||||
}
|
||||
exc = mrb_exc_new(mrb, E_ARGUMENT_ERROR, buf, strlen(buf));
|
||||
mrb->exc = (struct RObject *) mrb_object(exc);
|
||||
mrb->exc = (struct RObject*)mrb_object(exc);
|
||||
}
|
||||
|
||||
#define SET_TRUE_VALUE(r) {\
|
||||
@@ -625,7 +625,7 @@ mrb_run(mrb_state *mrb, struct RProc *proc, mrb_value self)
|
||||
|
||||
CASE(OP_RAISE) {
|
||||
/* A raise(R(A)) */
|
||||
mrb->exc = (struct RObject *) mrb_object(regs[GETARG_A(i)]);
|
||||
mrb->exc = (struct RObject*)mrb_object(regs[GETARG_A(i)]);
|
||||
goto L_RAISE;
|
||||
}
|
||||
|
||||
@@ -1573,7 +1573,7 @@ mrb_run(mrb_state *mrb, struct RProc *proc, mrb_value self)
|
||||
mrb_value msg = pool[GETARG_Bx(i)];
|
||||
mrb_value exc = mrb_exc_new3(mrb, mrb->eRuntimeError_class, msg);
|
||||
|
||||
mrb->exc = (struct RObject *) mrb_object(exc);
|
||||
mrb->exc = (struct RObject*)mrb_object(exc);
|
||||
goto L_RAISE;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user