From e07cb859cc882adc05f818466b45e75f1d5a1e39 Mon Sep 17 00:00:00 2001 From: nobu Date: Sat, 18 Jul 2009 08:05:32 +0000 Subject: * suppressed shorten-64-to-32 warnings. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24195 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- bignum.c | 12 ++++++------ class.c | 8 ++++---- dir.c | 4 ++-- encoding.c | 17 +++++++++-------- enum.c | 4 ++-- enumerator.c | 10 +++++----- eval.c | 12 +++++++----- file.c | 10 +++++----- gc.c | 32 ++++++++++++++++---------------- hash.c | 4 ++-- io.c | 38 +++++++++++++++++++------------------- load.c | 36 ++++++++++++++++++------------------ marshal.c | 36 ++++++++++++++++++------------------ numeric.c | 18 +++++++++--------- object.c | 35 +++++++++++++++++++---------------- proc.c | 20 ++++++++++---------- 16 files changed, 151 insertions(+), 145 deletions(-) diff --git a/bignum.c b/bignum.c index f2853ebe7b..bd9e0c8cae 100644 --- a/bignum.c +++ b/bignum.c @@ -1051,7 +1051,7 @@ big2ulong(VALUE x, const char *type, int check) VALUE rb_big2ulong_pack(VALUE x) { - VALUE num = big2ulong(x, "unsigned long", Qfalse); + VALUE num = big2ulong(x, "unsigned long", FALSE); if (!RBIGNUM_SIGN(x)) { return (VALUE)(-(SIGNED_VALUE)num); } @@ -1061,7 +1061,7 @@ rb_big2ulong_pack(VALUE x) VALUE rb_big2ulong(VALUE x) { - VALUE num = big2ulong(x, "unsigned long", Qtrue); + VALUE num = big2ulong(x, "unsigned long", TRUE); if (!RBIGNUM_SIGN(x)) { if ((SIGNED_VALUE)num < 0) { @@ -1075,7 +1075,7 @@ rb_big2ulong(VALUE x) SIGNED_VALUE rb_big2long(VALUE x) { - VALUE num = big2ulong(x, "long", Qtrue); + VALUE num = big2ulong(x, "long", TRUE); if ((SIGNED_VALUE)num < 0 && (RBIGNUM_SIGN(x) || (SIGNED_VALUE)num != LONG_MIN)) { @@ -2902,7 +2902,7 @@ rb_big_lshift(VALUE x, VALUE y) if (!NIL_P(t)) return t; neg = 1; } - shift = big2ulong(y, "long", Qtrue); + shift = big2ulong(y, "long", TRUE); break; } y = rb_to_int(y); @@ -2968,7 +2968,7 @@ rb_big_rshift(VALUE x, VALUE y) else { neg = 1; } - shift = big2ulong(y, "long", Qtrue); + shift = big2ulong(y, "long", TRUE); break; } y = rb_to_int(y); @@ -3056,7 +3056,7 @@ rb_big_aref(VALUE x, VALUE y) out_of_range: return RBIGNUM_SIGN(x) ? INT2FIX(0) : INT2FIX(1); } - shift = big2ulong(y, "long", Qfalse); + shift = big2ulong(y, "long", FALSE); } else { i = NUM2LONG(y); diff --git a/class.c b/class.c index 3c7b1f0595..b04f00c549 100644 --- a/class.c +++ b/class.c @@ -491,7 +491,7 @@ rb_include_module(VALUE klass, VALUE module) OBJ_INFECT(klass, module); c = klass; while (module) { - int superclass_seen = Qfalse; + int superclass_seen = FALSE; if (RCLASS_M_TBL(klass) == RCLASS_M_TBL(module)) rb_raise(rb_eArgError, "cyclic include detected"); @@ -507,7 +507,7 @@ rb_include_module(VALUE klass, VALUE module) } break; case T_CLASS: - superclass_seen = Qtrue; + superclass_seen = TRUE; break; } } @@ -694,7 +694,7 @@ class_instance_method_list(int argc, VALUE *argv, VALUE mod, int (*func) (ID, lo st_table *list; if (argc == 0) { - recur = Qtrue; + recur = TRUE; } else { VALUE r; @@ -975,7 +975,7 @@ rb_define_alias(VALUE klass, const char *name1, const char *name2) void rb_define_attr(VALUE klass, const char *name, int read, int write) { - rb_attr(klass, rb_intern(name), read, write, Qfalse); + rb_attr(klass, rb_intern(name), read, write, FALSE); } #include diff --git a/dir.c b/dir.c index f3ffc45f4f..c97c702dac 100644 --- a/dir.c +++ b/dir.c @@ -701,7 +701,7 @@ static VALUE chdir_yield(struct chdir_data *args) { dir_chdir(args->new_path); - args->done = Qtrue; + args->done = TRUE; chdir_blocking++; if (chdir_thread == Qnil) chdir_thread = rb_thread_current(); @@ -788,7 +788,7 @@ dir_s_chdir(int argc, VALUE *argv, VALUE obj) args.old_path = rb_tainted_str_new2(cwd); xfree(cwd); args.new_path = path; - args.done = Qfalse; + args.done = FALSE; return rb_ensure(chdir_yield, (VALUE)&args, chdir_restore, (VALUE)&args); } dir_chdir(path); diff --git a/encoding.c b/encoding.c index 2f0b9797db..5e54ce7218 100644 --- a/encoding.c +++ b/encoding.c @@ -539,16 +539,16 @@ rb_enc_find(const char *name) static inline int enc_capable(VALUE obj) { - if (SPECIAL_CONST_P(obj)) return Qfalse; + if (SPECIAL_CONST_P(obj)) return FALSE; switch (BUILTIN_TYPE(obj)) { case T_STRING: case T_REGEXP: case T_FILE: - return Qtrue; + return TRUE; case T_DATA: - if (RDATA(obj)->dmark == enc_mark) return Qtrue; + if (RDATA(obj)->dmark == enc_mark) return TRUE; default: - return Qfalse; + return FALSE; } } @@ -744,7 +744,7 @@ rb_enc_mbclen(const char *p, const char *e, rb_encoding *enc) return MBCLEN_CHARFOUND_LEN(n); else { int min = rb_enc_mbminlen(enc); - return min <= e-p ? min : e-p; + return min <= e-p ? min : (int)(e-p); } } @@ -756,7 +756,7 @@ rb_enc_precise_mbclen(const char *p, const char *e, rb_encoding *enc) return ONIGENC_CONSTRUCT_MBCLEN_NEEDMORE(1); n = ONIGENC_PRECISE_MBC_ENC_LEN(enc, (UChar*)p, (UChar*)e); if (e-p < n) - return ONIGENC_CONSTRUCT_MBCLEN_NEEDMORE(n-(e-p)); + return ONIGENC_CONSTRUCT_MBCLEN_NEEDMORE(n-(int)(e-p)); return n; } @@ -1071,10 +1071,11 @@ struct default_encoding { static int enc_set_default_encoding(struct default_encoding *def, VALUE encoding, const char *name) { - int overridden = Qfalse; + int overridden = FALSE; + if (def->index != -2) /* Already set */ - overridden = Qtrue; + overridden = TRUE; if (NIL_P(encoding)) { def->index = -1; diff --git a/enum.c b/enum.c index 3379cf2c75..715969d060 100644 --- a/enum.c +++ b/enum.c @@ -1568,13 +1568,13 @@ enum_zip(int argc, VALUE *argv, VALUE obj) NODE *memo; VALUE result = Qnil; VALUE args = rb_ary_new4(argc, argv); - int allary = Qtrue; + int allary = TRUE; argv = RARRAY_PTR(args); for (i=0; iargs) { - argc = RARRAY_LEN(e->args); + argc = RARRAY_LENINT(e->args); argv = RARRAY_PTR(e->args); } return rb_block_call(e->obj, e->meth, argc, argv, @@ -430,7 +430,7 @@ enumerator_with_index(int argc, VALUE *argv, VALUE obj) memo = NIL_P(memo) ? 0 : (VALUE)NUM2LONG(memo); e = enumerator_ptr(obj); if (e->args) { - argc = RARRAY_LEN(e->args); + argc = RARRAY_LENINT(e->args); argv = RARRAY_PTR(e->args); } else { @@ -486,7 +486,7 @@ enumerator_with_object(VALUE obj, VALUE memo) RETURN_ENUMERATOR(obj, 1, &memo); e = enumerator_ptr(obj); if (e->args) { - argc = RARRAY_LEN(e->args); + argc = RARRAY_LENINT(e->args); argv = RARRAY_PTR(e->args); } rb_block_call(e->obj, e->meth, argc, argv, @@ -616,8 +616,8 @@ inspect_enumerator(VALUE obj, VALUE dummy, int recur) rb_str_concat(str, rb_inspect(arg)); rb_str_buf_cat2(str, argc > 0 ? ", " : ")"); - if (OBJ_TAINTED(arg)) tainted = Qtrue; - if (OBJ_UNTRUSTED(arg)) untrusted = Qtrue; + if (OBJ_TAINTED(arg)) tainted = TRUE; + if (OBJ_UNTRUSTED(arg)) untrusted = TRUE; } } diff --git a/eval.c b/eval.c index 6d6b6acd00..94978a9e90 100644 --- a/eval.c +++ b/eval.c @@ -15,6 +15,8 @@ #include "iseq.h" #include "gc.h" +#define numberof(array) (int)(sizeof(array) / sizeof((array)[0])) + VALUE proc_invoke(VALUE, VALUE, VALUE, VALUE); VALUE rb_binding_new(void); NORETURN(void rb_raise_jump(VALUE)); @@ -157,7 +159,7 @@ ruby_cleanup(volatile int ex) POP_TAG(); rb_thread_stop_timer_thread(); - for (nerr = 0; nerr < sizeof(errs) / sizeof(errs[0]); ++nerr) { + for (nerr = 0; nerr < numberof(errs); ++nerr) { VALUE err = errs[nerr]; if (!RTEST(err)) continue; @@ -534,10 +536,10 @@ rb_block_given_p(void) if ((th->cfp->lfp[0] & 0x02) == 0 && GC_GUARDED_PTR_REF(th->cfp->lfp[0])) { - return Qtrue; + return TRUE; } else { - return Qfalse; + return FALSE; } } @@ -577,13 +579,13 @@ rb_rescue2(VALUE (* b_proc) (ANYARGS), VALUE data1, th->cfp = cfp; /* restore */ if (state == TAG_RAISE) { - int handle = Qfalse; + int handle = FALSE; VALUE eclass; va_init_list(args, data2); while ((eclass = va_arg(args, VALUE)) != 0) { if (rb_obj_is_kind_of(th->errinfo, eclass)) { - handle = Qtrue; + handle = TRUE; break; } } diff --git a/file.c b/file.c index f9dfc620ee..a212668f95 100644 --- a/file.c +++ b/file.c @@ -885,7 +885,7 @@ group_member(GETGROUPS_T gid) { #ifndef _WIN32 if (getgid() == gid || getegid() == gid) - return Qtrue; + return TRUE; # ifdef HAVE_GETGROUPS # ifndef NGROUPS @@ -902,11 +902,11 @@ group_member(GETGROUPS_T gid) anum = getgroups(NGROUPS, gary); while (--anum >= 0) if (gary[anum] == gid) - return Qtrue; + return TRUE; } # endif #endif - return Qfalse; + return FALSE; } #endif @@ -4543,7 +4543,7 @@ static int fpath_check(const char *path) { #if ENABLE_PATH_CHECK - return path_check_0(rb_str_new2(path), Qfalse); + return path_check_0(rb_str_new2(path), FALSE); #else return 1; #endif @@ -4564,7 +4564,7 @@ rb_path_check(const char *path) if (!p) p = pend; for (;;) { - if (!path_check_0(rb_str_new(p0, p - p0), Qtrue)) { + if (!path_check_0(rb_str_new(p0, p - p0), TRUE)) { return 0; /* not safe */ } p0 = p + 1; diff --git a/gc.c b/gc.c index d7b1291d33..ef0804df71 100644 --- a/gc.c +++ b/gc.c @@ -541,7 +541,7 @@ gc_profile_enable(void) { rb_objspace_t *objspace = &rb_objspace; - objspace->profile.run = Qtrue; + objspace->profile.run = TRUE; return Qnil; } @@ -559,7 +559,7 @@ gc_profile_disable(void) { rb_objspace_t *objspace = &rb_objspace; - objspace->profile.run = Qfalse; + objspace->profile.run = FALSE; return Qnil; } @@ -788,7 +788,7 @@ rb_gc_enable(void) rb_objspace_t *objspace = &rb_objspace; int old = dont_gc; - dont_gc = Qfalse; + dont_gc = FALSE; return old; } @@ -810,7 +810,7 @@ rb_gc_disable(void) rb_objspace_t *objspace = &rb_objspace; int old = dont_gc; - dont_gc = Qtrue; + dont_gc = TRUE; return old; } @@ -987,9 +987,9 @@ heaps_increment(rb_objspace_t *objspace) if (heaps_inc > 0) { assign_heap_slot(objspace, &freelist, lifetime_normal); heaps_inc--; - return Qtrue; + return TRUE; } - return Qfalse; + return FALSE; } #define LONGLIFE_ALLOCATE_HEAPS_MIN 10 @@ -1335,8 +1335,8 @@ is_pointer_to_heap(rb_objspace_t *objspace, void *ptr) register struct heaps_slot *heap; register size_t hi, lo, mid; - if (p < lomem || p > himem) return Qfalse; - if ((VALUE)p % sizeof(RVALUE) != 0) return Qfalse; + if (p < lomem || p > himem) return FALSE; + if ((VALUE)p % sizeof(RVALUE) != 0) return FALSE; /* check if p looks like a pointer using bsearch*/ lo = 0; @@ -1346,14 +1346,14 @@ is_pointer_to_heap(rb_objspace_t *objspace, void *ptr) heap = &heaps[mid]; if (heap->slot <= p) { if (p < heap->slot + heap->limit) - return Qtrue; + return TRUE; lo = mid + 1; } else { hi = mid; } } - return Qfalse; + return FALSE; } VALUE @@ -1997,7 +1997,7 @@ gc_sweep(rb_objspace_t *objspace) malloc_increase = 0; if (freed < free_min) { if (!heaps_inc && objspace->heap.longlife_used) - objspace->flags.longlife_collection = Qtrue; + objspace->flags.longlife_collection = TRUE; set_heaps_increment(objspace); heaps_increment(objspace); } @@ -2065,7 +2065,7 @@ gc_sweep_for_longlife(rb_objspace_t *objspace) } remembered_set_recycle(objspace); - objspace->flags.longlife_collection = Qfalse; + objspace->flags.longlife_collection = FALSE; objspace->profile.longlife_objects = objspace->profile.longlife_objects - freed; } @@ -2305,7 +2305,7 @@ garbage_collect(rb_objspace_t *objspace) if (GC_NOTIFY) printf("start garbage_collect()\n"); if (!heaps) { - return Qfalse; + return FALSE; } if (dont_gc || during_gc) { @@ -2315,7 +2315,7 @@ garbage_collect(rb_objspace_t *objspace) heaps_increment(objspace); } } - return Qtrue; + return TRUE; } during_gc++; objspace->count++; @@ -2379,7 +2379,7 @@ garbage_collect(rb_objspace_t *objspace) GC_PROF_TIMER_STOP; if (GC_NOTIFY) printf("end garbage_collect()\n"); - return Qtrue; + return TRUE; } int @@ -2425,7 +2425,7 @@ rb_gc_start(void) { rb_objspace_t *objspace = &rb_objspace; if (objspace->heap.longlife_used) { - objspace->flags.longlife_collection = Qtrue; + objspace->flags.longlife_collection = TRUE; } rb_gc(); return Qnil; diff --git a/hash.c b/hash.c index da47b55bea..c4eac855f3 100644 --- a/hash.c +++ b/hash.c @@ -1516,7 +1516,7 @@ hash_equal(VALUE hash1, VALUE hash2, int eql) static VALUE rb_hash_equal(VALUE hash1, VALUE hash2) { - return hash_equal(hash1, hash2, Qfalse); + return hash_equal(hash1, hash2, FALSE); } /* @@ -1530,7 +1530,7 @@ rb_hash_equal(VALUE hash1, VALUE hash2) static VALUE rb_hash_eql(VALUE hash1, VALUE hash2) { - return hash_equal(hash1, hash2, Qtrue); + return hash_equal(hash1, hash2, TRUE); } static int diff --git a/io.c b/io.c index b1d985e4f5..e2de4a69b1 100644 --- a/io.c +++ b/io.c @@ -628,7 +628,7 @@ rb_io_wait_readable(int f) case ERESTART: #endif rb_thread_wait_fd(f); - return Qtrue; + return TRUE; case EAGAIN: #if defined(EWOULDBLOCK) && EWOULDBLOCK != EAGAIN @@ -642,10 +642,10 @@ rb_io_wait_readable(int f) #else rb_thread_select(f + 1, rb_fd_ptr(&rfds), NULL, NULL, NULL); #endif - return Qtrue; + return TRUE; default: - return Qfalse; + return FALSE; } } @@ -673,7 +673,7 @@ rb_io_wait_writable(int f) case ERESTART: #endif rb_thread_fd_writable(f); - return Qtrue; + return TRUE; case EAGAIN: #if defined(EWOULDBLOCK) && EWOULDBLOCK != EAGAIN @@ -687,10 +687,10 @@ rb_io_wait_writable(int f) #else rb_thread_select(f + 1, NULL, rb_fd_ptr(&wfds), NULL, NULL); #endif - return Qtrue; + return TRUE; default: - return Qfalse; + return FALSE; } } @@ -2217,7 +2217,7 @@ swallow(rb_io_t *fptr, int term) const char *p = READ_DATA_PENDING_PTR(fptr); int i; if (cnt > sizeof buf) cnt = sizeof buf; - if (*p != term) return Qtrue; + if (*p != term) return TRUE; i = (int)cnt; while (--i && *++p == term); if (!read_buffered_data(buf, cnt - i, fptr)) /* must not fail */ @@ -2226,7 +2226,7 @@ swallow(rb_io_t *fptr, int term) rb_thread_wait_fd(fptr->fd); rb_io_check_closed(fptr); } while (io_fillbuf(fptr) == 0); - return Qfalse; + return FALSE; } static VALUE @@ -3434,7 +3434,7 @@ rb_io_fptr_finalize(rb_io_t *fptr) fptr->pathv = Qnil; fptr->write_lock = 0; if (0 <= fptr->fd) - rb_io_fptr_cleanup(fptr, Qtrue); + rb_io_fptr_cleanup(fptr, TRUE); if (fptr->rbuf) { free(fptr->rbuf); fptr->rbuf = 0; @@ -3474,7 +3474,7 @@ rb_io_close(VALUE io) if (io != write_io) { write_fptr = RFILE(write_io)->fptr; if (write_fptr && 0 <= write_fptr->fd) { - rb_io_fptr_cleanup(write_fptr, Qtrue); + rb_io_fptr_cleanup(write_fptr, TRUE); } } @@ -3483,7 +3483,7 @@ rb_io_close(VALUE io) if (fptr->fd < 0) return Qnil; fd = fptr->fd; - rb_io_fptr_cleanup(fptr, Qfalse); + rb_io_fptr_cleanup(fptr, FALSE); rb_thread_fd_close(fd); if (fptr->pid) { @@ -3613,7 +3613,7 @@ rb_io_close_read(VALUE io) write_io = GetWriteIO(io); if (io != write_io) { rb_io_t *wfptr; - rb_io_fptr_cleanup(fptr, Qfalse); + rb_io_fptr_cleanup(fptr, FALSE); GetOpenFile(write_io, wfptr); RFILE(io)->fptr = wfptr; RFILE(write_io)->fptr = NULL; @@ -5114,7 +5114,7 @@ pipe_open_v(int argc, VALUE *argv, const char *modestr, int fmode, convconfig_t { VALUE prog; struct rb_exec_arg earg; - prog = rb_exec_arg_init(argc, argv, Qfalse, &earg); + prog = rb_exec_arg_init(argc, argv, FALSE, &earg); return pipe_open(&earg, prog, modestr, fmode, convconfig); } @@ -5134,7 +5134,7 @@ pipe_open_s(VALUE prog, const char *modestr, int fmode, convconfig_t *convconfig return pipe_open(0, 0, modestr, fmode, convconfig); } - rb_exec_arg_init(argc, argv, Qtrue, &earg); + rb_exec_arg_init(argc, argv, TRUE, &earg); return pipe_open(&earg, prog, modestr, fmode, convconfig); } @@ -5548,18 +5548,18 @@ static VALUE rb_f_open(int argc, VALUE *argv) { ID to_open = 0; - int redirect = Qfalse; + int redirect = FALSE; if (argc >= 1) { CONST_ID(to_open, "to_open"); if (rb_respond_to(argv[0], to_open)) { - redirect = Qtrue; + redirect = TRUE; } else { VALUE tmp = argv[0]; FilePathValue(tmp); if (NIL_P(tmp)) { - redirect = Qtrue; + redirect = TRUE; } else { VALUE cmd = check_pipe_command(tmp); @@ -6683,7 +6683,7 @@ argf_next_argv(VALUE argf) } else { ARGF.next_p = 1; - return Qfalse; + return FALSE; } } else if (ARGF.next_p == -1) { @@ -6694,7 +6694,7 @@ argf_next_argv(VALUE argf) rb_stdout = orig_stdout; } } - return Qtrue; + return TRUE; } static VALUE diff --git a/load.c b/load.c index 9a5498e4da..38a78e46dc 100644 --- a/load.c +++ b/load.c @@ -225,17 +225,17 @@ rb_feature_provided(const char *feature, const char **loading) } if (ext && !strchr(ext, '/')) { if (IS_RBEXT(ext)) { - if (rb_feature_p(feature, ext, Qtrue, Qfalse, loading)) return Qtrue; - return Qfalse; + if (rb_feature_p(feature, ext, Qtrue, Qfalse, loading)) return TRUE; + return FALSE; } else if (IS_SOEXT(ext) || IS_DLEXT(ext)) { - if (rb_feature_p(feature, ext, Qfalse, Qfalse, loading)) return Qtrue; - return Qfalse; + if (rb_feature_p(feature, ext, Qfalse, Qfalse, loading)) return TRUE; + return FALSE; } } - if (rb_feature_p(feature, feature + strlen(feature), Qtrue, Qfalse, loading)) - return Qtrue; - return Qfalse; + if (rb_feature_p(feature, feature + strlen(feature), TRUE, FALSE, loading)) + return TRUE; + return FALSE; } static void @@ -259,7 +259,7 @@ rb_load_internal(VALUE fname, int wrap) rb_thread_t *th = GET_THREAD(); volatile VALUE wrapper = th->top_wrapper; volatile VALUE self = th->top_self; - volatile int loaded = Qfalse; + volatile int loaded = FALSE; volatile int mild_compile_error; #ifndef __GNUC__ rb_thread_t *volatile th0 = th; @@ -287,7 +287,7 @@ rb_load_internal(VALUE fname, int wrap) th->mild_compile_error++; node = (NODE *)rb_load_file(RSTRING_PTR(fname)); - loaded = Qtrue; + loaded = TRUE; iseq = rb_iseq_new_top(node, rb_str_new2(""), fname, Qfalse); th->mild_compile_error--; rb_iseq_eval(iseq); @@ -451,20 +451,20 @@ search_required(VALUE fname, volatile VALUE *path, int safe_level) ext = strrchr(ftptr = RSTRING_PTR(fname), '.'); if (ext && !strchr(ext, '/')) { if (IS_RBEXT(ext)) { - if (rb_feature_p(ftptr, ext, Qtrue, Qfalse, &loading)) { + if (rb_feature_p(ftptr, ext, TRUE, FALSE, &loading)) { if (loading) *path = rb_str_new2(loading); return 'r'; } if ((tmp = rb_find_file_safe(fname, safe_level)) != 0) { ext = strrchr(ftptr = RSTRING_PTR(tmp), '.'); - if (!rb_feature_p(ftptr, ext, Qtrue, Qtrue, &loading) || loading) + if (!rb_feature_p(ftptr, ext, TRUE, TRUE, &loading) || loading) *path = tmp; return 'r'; } return 0; } else if (IS_SOEXT(ext)) { - if (rb_feature_p(ftptr, ext, Qfalse, Qfalse, &loading)) { + if (rb_feature_p(ftptr, ext, FALSE, FALSE, &loading)) { if (loading) *path = rb_str_new2(loading); return 's'; } @@ -482,26 +482,26 @@ search_required(VALUE fname, volatile VALUE *path, int safe_level) OBJ_FREEZE(tmp); if ((tmp = rb_find_file_safe(tmp, safe_level)) != 0) { ext = strrchr(ftptr = RSTRING_PTR(tmp), '.'); - if (!rb_feature_p(ftptr, ext, Qfalse, Qtrue, &loading) || loading) + if (!rb_feature_p(ftptr, ext, FALSE, TRUE, &loading) || loading) *path = tmp; return 's'; } #endif } else if (IS_DLEXT(ext)) { - if (rb_feature_p(ftptr, ext, Qfalse, Qfalse, &loading)) { + if (rb_feature_p(ftptr, ext, FALSE, FALSE, &loading)) { if (loading) *path = rb_str_new2(loading); return 's'; } if ((tmp = rb_find_file_safe(fname, safe_level)) != 0) { ext = strrchr(ftptr = RSTRING_PTR(tmp), '.'); - if (!rb_feature_p(ftptr, ext, Qfalse, Qtrue, &loading) || loading) + if (!rb_feature_p(ftptr, ext, FALSE, TRUE, &loading) || loading) *path = tmp; return 's'; } } } - else if ((ft = rb_feature_p(ftptr, 0, Qfalse, Qfalse, &loading)) == 'r') { + else if ((ft = rb_feature_p(ftptr, 0, FALSE, FALSE, &loading)) == 'r') { if (loading) *path = rb_str_new2(loading); return 'r'; } @@ -512,14 +512,14 @@ search_required(VALUE fname, volatile VALUE *path, int safe_level) if (ft) break; ftptr = RSTRING_PTR(tmp); - return rb_feature_p(ftptr, 0, Qfalse, Qtrue, 0); + return rb_feature_p(ftptr, 0, FALSE, TRUE, 0); default: if (ft) break; case 1: ext = strrchr(ftptr = RSTRING_PTR(tmp), '.'); - if (rb_feature_p(ftptr, ext, !--type, Qtrue, &loading) && !loading) + if (rb_feature_p(ftptr, ext, !--type, TRUE, &loading) && !loading) break; *path = tmp; } diff --git a/marshal.c b/marshal.c index 5cdd2176b8..e999a2d532 100644 --- a/marshal.c +++ b/marshal.c @@ -459,7 +459,7 @@ w_uclass(VALUE obj, VALUE super, struct dump_arg *arg) { VALUE klass = CLASS_OF(obj); - w_extended(klass, arg, Qtrue); + w_extended(klass, arg, TRUE); klass = rb_class_real(klass); if (klass != super) { w_byte(TYPE_UCLASS, arg); @@ -598,8 +598,8 @@ w_object(VALUE obj, struct dump_arg *arg, int limit) w_symbol(SYM2ID(obj), arg); } else { - if (OBJ_TAINTED(obj)) arg->taint = Qtrue; - if (OBJ_UNTRUSTED(obj)) arg->untrust = Qtrue; + if (OBJ_TAINTED(obj)) arg->taint = TRUE; + if (OBJ_UNTRUSTED(obj)) arg->untrust = TRUE; if (rb_respond_to(obj, s_mdump)) { volatile VALUE v; @@ -608,7 +608,7 @@ w_object(VALUE obj, struct dump_arg *arg, int limit) v = rb_funcall(obj, s_mdump, 0, 0); check_dump_arg(arg, s_mdump); - w_class(TYPE_USRMARSHAL, obj, arg, Qfalse); + w_class(TYPE_USRMARSHAL, obj, arg, FALSE); w_object(v, arg, limit); if (hasiv) w_ivar(obj, 0, &c_arg); return; @@ -626,7 +626,7 @@ w_object(VALUE obj, struct dump_arg *arg, int limit) if ((hasiv2 = has_ivars(v, ivtbl2)) != 0 && !hasiv) { w_byte(TYPE_IVAR, arg); } - w_class(TYPE_USERDEF, obj, arg, Qfalse); + w_class(TYPE_USERDEF, obj, arg, FALSE); w_bytes(RSTRING_PTR(v), RSTRING_LEN(v), arg); if (hasiv2) { w_ivar(v, ivtbl2, &c_arg); @@ -757,7 +757,7 @@ w_object(VALUE obj, struct dump_arg *arg, int limit) break; case T_STRUCT: - w_class(TYPE_STRUCT, obj, arg, Qtrue); + w_class(TYPE_STRUCT, obj, arg, TRUE); { long len = RSTRUCT_LEN(obj); VALUE mem; @@ -773,7 +773,7 @@ w_object(VALUE obj, struct dump_arg *arg, int limit) break; case T_OBJECT: - w_class(TYPE_OBJECT, obj, arg, Qtrue); + w_class(TYPE_OBJECT, obj, arg, TRUE); w_objivar(obj, &c_arg); break; @@ -788,7 +788,7 @@ w_object(VALUE obj, struct dump_arg *arg, int limit) } v = rb_funcall(obj, s_dump_data, 0); check_dump_arg(arg, s_dump_data); - w_class(TYPE_DATA, obj, arg, Qtrue); + w_class(TYPE_DATA, obj, arg, TRUE); w_object(v, arg, limit); } break; @@ -883,8 +883,8 @@ marshal_dump(int argc, VALUE *argv) arg.dest = 0; arg.symbols = st_init_numtable(); arg.data = st_init_numtable(); - arg.taint = Qfalse; - arg.untrust = Qfalse; + arg.taint = FALSE; + arg.untrust = FALSE; arg.compat_tbl = st_init_numtable(); arg.encodings = 0; arg.str = rb_str_buf_new(0); @@ -1050,8 +1050,8 @@ r_bytes0(long len, struct load_arg *arg) if (NIL_P(str)) goto too_short; StringValue(str); if (RSTRING_LEN(str) != len) goto too_short; - if (OBJ_TAINTED(str)) arg->taint = Qtrue; - if (OBJ_UNTRUSTED(str)) arg->untrust = Qtrue; + if (OBJ_TAINTED(str)) arg->taint = TRUE; + if (OBJ_UNTRUSTED(str)) arg->untrust = TRUE; } return str; } @@ -1246,7 +1246,7 @@ r_object0(struct load_arg *arg, int *ivp, VALUE extmod) case TYPE_IVAR: { - int ivar = Qtrue; + int ivar = TRUE; v = r_object0(arg, &ivar, extmod); if (ivar) r_ivar(v, arg); @@ -1396,7 +1396,7 @@ r_object0(struct load_arg *arg, int *ivp, VALUE extmod) v = rb_reg_new("", 0, options); if (ivp) { r_ivar(v, arg); - *ivp = Qfalse; + *ivp = FALSE; } if (rb_enc_get_index(v) != rb_usascii_encindex()) rb_enc_copy(str, v); @@ -1493,7 +1493,7 @@ r_object0(struct load_arg *arg, int *ivp, VALUE extmod) data = r_string(arg); if (ivp) { r_ivar(data, arg); - *ivp = Qfalse; + *ivp = FALSE; } v = rb_funcall(klass, s_load, 1, data); check_load_arg(arg, s_load); @@ -1542,10 +1542,10 @@ r_object0(struct load_arg *arg, int *ivp, VALUE extmod) { VALUE klass = path2class(r_unique(arg)); if (rb_respond_to(klass, s_alloc)) { - static int warn = Qtrue; + static int warn = TRUE; if (warn) { rb_warn("define `allocate' instead of `_alloc'"); - warn = Qfalse; + warn = FALSE; } v = rb_funcall(klass, s_alloc, 0); check_load_arg(arg, s_alloc); @@ -1667,7 +1667,7 @@ marshal_load(int argc, VALUE *argv) if (rb_respond_to(port, s_binmode)) { rb_funcall2(port, s_binmode, 0, 0); } - arg.taint = Qtrue; + arg.taint = TRUE; } else { rb_raise(rb_eTypeError, "instance of IO needed"); diff --git a/numeric.c b/numeric.c index 53da949609..3330e26933 100644 --- a/numeric.c +++ b/numeric.c @@ -159,25 +159,25 @@ do_coerce(VALUE *x, VALUE *y, int err) if (err) { rb_raise(rb_eTypeError, "coerce must return [x, y]"); } - return Qfalse; + return FALSE; } *x = RARRAY_PTR(ary)[0]; *y = RARRAY_PTR(ary)[1]; - return Qtrue; + return TRUE; } VALUE rb_num_coerce_bin(VALUE x, VALUE y, ID func) { - do_coerce(&x, &y, Qtrue); + do_coerce(&x, &y, TRUE); return rb_funcall(x, func, 1, y); } VALUE rb_num_coerce_cmp(VALUE x, VALUE y, ID func) { - if (do_coerce(&x, &y, Qfalse)) + if (do_coerce(&x, &y, FALSE)) return rb_funcall(x, func, 1, y); return Qnil; } @@ -187,7 +187,7 @@ rb_num_coerce_relop(VALUE x, VALUE y, ID func) { VALUE c, x0 = x, y0 = y; - if (!do_coerce(&x, &y, Qfalse) || + if (!do_coerce(&x, &y, FALSE) || NIL_P(c = rb_funcall(x, func, 1, y))) { rb_cmperr(x0, y0); return Qnil; /* not reached */ @@ -249,7 +249,7 @@ num_uminus(VALUE num) VALUE zero; zero = INT2FIX(0); - do_coerce(&zero, &num, Qtrue); + do_coerce(&zero, &num, TRUE); return rb_funcall(zero, '-', 1, num); } @@ -1491,9 +1491,9 @@ ruby_float_step(VALUE from, VALUE to, VALUE step, int excl) rb_yield(DBL2NUM(i*unit+beg)); } } - return Qtrue; + return TRUE; } - return Qfalse; + return FALSE; } /* @@ -1567,7 +1567,7 @@ num_step(int argc, VALUE *argv, VALUE from) } } } - else if (!ruby_float_step(from, to, step, Qfalse)) { + else if (!ruby_float_step(from, to, step, FALSE)) { VALUE i = from; ID cmp; diff --git a/object.c b/object.c index d86c6e49d4..b8a33f4697 100644 --- a/object.c +++ b/object.c @@ -99,7 +99,7 @@ VALUE rb_obj_hash(VALUE obj) { VALUE oid = rb_obj_id(obj); - unsigned h = rb_hash_end(rb_hash_start(NUM2LONG(oid))); + unsigned long h = rb_hash_end(rb_hash_start(NUM2LONG(oid))); return LONG2NUM(h); } @@ -1549,7 +1549,7 @@ rb_mod_attr_reader(int argc, VALUE *argv, VALUE klass) int i; for (i=0; i 20) ? (w = 20, ellipsis = "...") : (ellipsis = "")) + enum {max_width = 20}; +#define OutOfRange() ((end - p > max_width) ? \ + (w = max_width, ellipsis = "...") : \ + (w = (int)(end - p), ellipsis = "")) if (!p) return 0.0; q = p; @@ -2225,6 +2228,9 @@ rb_str_to_dbl(VALUE str, int badcheck) s = RSTRING_PTR(str); len = RSTRING_LEN(str); if (s) { + if (badcheck && memchr(s, '\0', len)) { + rb_raise(rb_eArgError, "string for Float contains null byte"); + } if (s[len]) { /* no sentinel somehow */ char *p = ALLOCA_N(char, len+1); @@ -2232,9 +2238,6 @@ rb_str_to_dbl(VALUE str, int badcheck) p[len] = '\0'; s = p; } - if (badcheck && len != strlen(s)) { - rb_raise(rb_eArgError, "string for Float contains null byte"); - } } return rb_cstr_to_dbl(s, badcheck); } @@ -2253,7 +2256,7 @@ rb_Float(VALUE val) return DBL2NUM(rb_big2dbl(val)); case T_STRING: - return DBL2NUM(rb_str_to_dbl(val, Qtrue)); + return DBL2NUM(rb_str_to_dbl(val, TRUE)); case T_NIL: rb_raise(rb_eTypeError, "can't convert nil into Float"); diff --git a/proc.c b/proc.c index 691c45b8d3..9536ee63bf 100644 --- a/proc.c +++ b/proc.c @@ -409,7 +409,7 @@ proc_new(VALUE klass, int is_lambda) if (is_lambda) { rb_proc_t *proc; GetProcPtr(procval, proc); - proc->is_lambda = Qtrue; + proc->is_lambda = TRUE; } return procval; } @@ -434,7 +434,7 @@ proc_new(VALUE klass, int is_lambda) static VALUE rb_proc_s_new(int argc, VALUE *argv, VALUE klass) { - VALUE block = proc_new(klass, Qfalse); + VALUE block = proc_new(klass, FALSE); rb_obj_call_init(block, argc, argv); return block; @@ -450,13 +450,13 @@ rb_proc_s_new(int argc, VALUE *argv, VALUE klass) VALUE rb_block_proc(void) { - return proc_new(rb_cProc, Qfalse); + return proc_new(rb_cProc, FALSE); } VALUE rb_block_lambda(void) { - return proc_new(rb_cProc, Qtrue); + return proc_new(rb_cProc, TRUE); } VALUE @@ -1095,13 +1095,13 @@ method_owner(VALUE obj) VALUE rb_obj_method(VALUE obj, VALUE vid) { - return mnew(CLASS_OF(obj), obj, rb_to_id(vid), rb_cMethod, Qfalse); + return mnew(CLASS_OF(obj), obj, rb_to_id(vid), rb_cMethod, FALSE); } VALUE rb_obj_public_method(VALUE obj, VALUE vid) { - return mnew(CLASS_OF(obj), obj, rb_to_id(vid), rb_cMethod, Qtrue); + return mnew(CLASS_OF(obj), obj, rb_to_id(vid), rb_cMethod, TRUE); } /* @@ -1139,13 +1139,13 @@ rb_obj_public_method(VALUE obj, VALUE vid) static VALUE rb_mod_instance_method(VALUE mod, VALUE vid) { - return mnew(mod, Qundef, rb_to_id(vid), rb_cUnboundMethod, Qfalse); + return mnew(mod, Qundef, rb_to_id(vid), rb_cUnboundMethod, FALSE); } static VALUE rb_mod_public_instance_method(VALUE mod, VALUE vid) { - return mnew(mod, Qundef, rb_to_id(vid), rb_cUnboundMethod, Qtrue); + return mnew(mod, Qundef, rb_to_id(vid), rb_cUnboundMethod, TRUE); } /* @@ -1232,8 +1232,8 @@ rb_mod_define_method(int argc, VALUE *argv, VALUE mod) if (BUILTIN_TYPE(proc->block.iseq) != T_NODE) { proc->block.iseq->defined_method_id = id; proc->block.iseq->klass = mod; - proc->is_lambda = Qtrue; - proc->is_from_method = Qtrue; + proc->is_lambda = TRUE; + proc->is_from_method = TRUE; } rb_add_method(mod, id, VM_METHOD_TYPE_BMETHOD, (void *)body, noex); } -- cgit v1.2.3