Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: dangan249/MacRuby
...
head fork: MacRuby/MacRuby
  • 13 commits
  • 21 files changed
  • 0 commit comments
  • 1 contributor
View
17 array.c
@@ -1396,13 +1396,14 @@ ary_rotate(VALUE ary, long cnt)
VALUE
rary_rotate_bang(VALUE ary, SEL sel, int argc, VALUE *argv)
{
- VALUE n;
long cnt = 1;
- rb_scan_args(argc, argv, "01", &n);
- if (!NIL_P(n)) {
- cnt = NUM2LONG(n);
+ switch (argc) {
+ case 1: cnt = NUM2LONG(argv[0]);
+ case 0: break;
+ default: rb_scan_args(argc, argv, "01", NULL);
}
+
rb_ary_modify(ary);
ary_rotate(ary, cnt);
return ary;
@@ -1427,12 +1428,12 @@ VALUE
rary_rotate(VALUE ary, SEL sel, int argc, VALUE *argv)
{
VALUE rotated;
- VALUE n;
long cnt = 1;
- rb_scan_args(argc, argv, "01", &n);
- if (!NIL_P(n)) {
- cnt = NUM2LONG(n);
+ switch (argc) {
+ case 1: cnt = NUM2LONG(argv[0]);
+ case 0: break;
+ default: rb_scan_args(argc, argv, "01", NULL);
}
rotated = rb_ary_dup(ary);
View
2  bignum.c
@@ -2495,7 +2495,7 @@ bigdivrem(VALUE x, VALUE y, volatile VALUE *divp, volatile VALUE *modp)
if (modp) { /* normalize remainder */
*modp = zz = rb_big_clone(z);
zds = BDIGITS(zz);
- while (--ny && !zds[ny]); ++ny;
+ while (--ny && !zds[ny]){} ++ny;
if (dd) {
t2 = 0; i = ny;
while(i--) {
View
6 dispatcher.cpp
@@ -394,7 +394,7 @@ extern "C"
void *
rb_vm_undefined_imp(void *rcv, SEL sel)
{
- method_missing((VALUE)rcv, sel, NULL, NULL, NULL, METHOD_MISSING_DEFAULT);
+ method_missing((VALUE)rcv, sel, NULL, 0, NULL, METHOD_MISSING_DEFAULT);
return NULL; // never reached
}
@@ -402,7 +402,7 @@ extern "C"
void *
rb_vm_removed_imp(void *rcv, SEL sel)
{
- method_missing((VALUE)rcv, sel, NULL, NULL, NULL, METHOD_MISSING_DEFAULT);
+ method_missing((VALUE)rcv, sel, NULL, 0, NULL, METHOD_MISSING_DEFAULT);
return NULL; // never reached
}
@@ -1147,7 +1147,7 @@ vm_block_eval(RoxorVM *vm, rb_vm_block_t *b, SEL sel, VALUE self,
&& (arity.min > 1
|| (arity.min == 1 && arity.min != arity.max))) {
// Expand the array.
- const long ary_len = RARRAY_LEN(argv[0]);
+ const int ary_len = RARRAY_LENINT(argv[0]);
if (ary_len > 0) {
new_argv = (VALUE *)RARRAY_PTR(argv[0]);
}
View
2  enumerator.c
@@ -294,7 +294,7 @@ enumerator_block_call(VALUE obj, VALUE (*func)(ANYARGS), VALUE arg)
e = enumerator_ptr(obj);
if (e->args != 0) {
- argc = RARRAY_LEN(e->args);
+ argc = RARRAY_LENINT(e->args);
argv = RARRAY_PTR(e->args);
}
return rb_objc_block_call(e->obj, e->sel, argc, (VALUE *)argv,
View
13 error.c
@@ -581,12 +581,15 @@ exc_equal(VALUE exc, SEL sel, VALUE obj)
if (rb_obj_class(exc) != rb_obj_class(obj)) {
SEL sel_message = sel_registerName("message");
SEL sel_backtrace = sel_registerName("backtrace");
- if (!rb_vm_respond_to(obj, sel_message, false)
- || !rb_vm_respond_to(obj, sel_backtrace, false)) {
+
+ mesg = rb_vm_check_call(obj, sel_message, 0, NULL);
+ if (mesg == Qundef) {
+ return Qfalse;
+ }
+ backtrace = rb_vm_check_call(obj, sel_backtrace, 0, NULL);
+ if (backtrace == Qundef) {
return Qfalse;
}
- mesg = rb_vm_call(obj, sel_message, 0, NULL);
- backtrace = rb_vm_call(obj, sel_backtrace, 0, NULL);
}
else {
mesg = rb_attr_get(obj, id_mesg);
@@ -1115,7 +1118,7 @@ Init_Exception(void)
rb_objc_define_method(*(VALUE *)rb_cNameErrorMesg, "!", name_err_mesg_new, 3);
rb_objc_define_method(rb_cNameErrorMesg, "==", name_err_mesg_equal, 1);
rb_objc_define_method(rb_cNameErrorMesg, "to_str", name_err_mesg_to_str, 0);
- rb_objc_define_method(rb_cNameErrorMesg, "_dump", name_err_mesg_to_str, 0);
+ rb_objc_define_method(rb_cNameErrorMesg, "_dump", name_err_mesg_to_str, 1);
rb_objc_define_method(*(VALUE *)rb_cNameErrorMesg, "_load", name_err_mesg_load, 1);
rb_eNoMethodError = rb_define_class("NoMethodError", rb_eNameError);
rb_objc_define_method(rb_eNoMethodError, "initialize", nometh_err_initialize, -1);
View
8 eval.c
@@ -357,7 +357,7 @@ VALUE
rb_make_exception(int argc, VALUE *argv)
{
VALUE mesg;
- ID exception;
+ SEL sel_exception;
int n;
mesg = Qnil;
@@ -382,11 +382,11 @@ rb_make_exception(int argc, VALUE *argv)
case 3:
n = 1;
exception_call:
- exception = rb_intern("exception");
- if (!rb_respond_to(argv[0], exception)) {
+ sel_exception = sel_registerName("exception");
+ mesg = rb_vm_check_call(argv[0], sel_exception, n, argv+1);
+ if (mesg == Qundef) {
rb_raise(rb_eTypeError, "exception class/object expected");
}
- mesg = rb_funcall(argv[0], exception, n, argv[1]);
break;
default:
rb_raise(rb_eArgError, "wrong number of arguments");
View
2  ext/iconv/iconv.c
@@ -243,7 +243,7 @@ iconv_create(VALUE to, VALUE from, struct rb_iconv_opt_t *opt, int *idx)
VALUE error = rb_str_new2(inval ? "invalid encoding " : "iconv");
VALUE format = rb_str_new2("%s(\"%s\", \"%s\")");
VALUE format_args = rb_ary_new3(3, error, to, from);
- VALUE msg = rb_str_format(RARRAY_LEN(format_args),
+ VALUE msg = rb_str_format(RARRAY_LENINT(format_args),
RARRAY_PTR(format_args), format);
s = RSTRING_PTR(msg);
View
16 ext/socket/socket.c
@@ -620,7 +620,7 @@ bsock_setsockopt(VALUE sock, SEL sel, VALUE lev, VALUE optname, VALUE val)
default:
StringValue(val);
v = RSTRING_PTR(val);
- vlen = RSTRING_LEN(val);
+ vlen = RSTRING_LENINT(val);
break;
}
@@ -3322,7 +3322,7 @@ sock_connect(VALUE sock, SEL sel, VALUE addr)
addr = rb_str_new4(addr);
GetOpenFile(sock, fptr);
fd = fptr->fd;
- n = ruby_connect(fd, (struct sockaddr*)RSTRING_PTR(addr), RSTRING_LEN(addr), 0);
+ n = ruby_connect(fd, (struct sockaddr*)RSTRING_PTR(addr), RSTRING_LENINT(addr), 0);
if (n < 0) {
rb_sys_fail("connect(2)");
}
@@ -3382,7 +3382,7 @@ sock_connect_nonblock(VALUE sock, SEL sel, VALUE addr)
addr = rb_str_new4(addr);
GetOpenFile(sock, fptr);
rb_io_set_nonblock(fptr);
- n = connect(fptr->fd, (struct sockaddr*)RSTRING_PTR(addr), RSTRING_LEN(addr));
+ n = connect(fptr->fd, (struct sockaddr*)RSTRING_PTR(addr), RSTRING_LENINT(addr));
if (n < 0) {
if (errno == EINPROGRESS) {
rb_mod_sys_fail(rb_mWaitWritable, "connect(2) would block");
@@ -3486,7 +3486,7 @@ sock_bind(VALUE sock, SEL sel, VALUE addr)
SockAddrStringValue(addr);
GetOpenFile(sock, fptr);
- if (bind(fptr->fd, (struct sockaddr*)RSTRING_PTR(addr), RSTRING_LEN(addr)) < 0)
+ if (bind(fptr->fd, (struct sockaddr*)RSTRING_PTR(addr), RSTRING_LENINT(addr)) < 0)
rb_sys_fail("bind(2)");
return INT2FIX(0);
@@ -4096,7 +4096,7 @@ sock_s_gethostbyaddr(VALUE self, SEL sel, int argc, VALUE *argv)
t = AF_INET6;
}
#endif
- h = gethostbyaddr(RSTRING_PTR(addr), RSTRING_LEN(addr), t);
+ h = gethostbyaddr(RSTRING_PTR(addr), RSTRING_LENINT(addr), t);
if (h == NULL) {
#ifdef HAVE_HSTRERROR
extern int h_errno;
@@ -4573,7 +4573,7 @@ sock_s_unpack_sockaddr_un(VALUE self, SEL sel, VALUE addr)
rb_raise(rb_eTypeError, "too long sockaddr_un - %ld longer than %ld",
RSTRING_LEN(addr), sizeof(struct sockaddr_un));
}
- sun_path = unixpath(sockaddr, RSTRING_LEN(addr));
+ sun_path = unixpath(sockaddr, RSTRING_LENINT(addr));
if (sizeof(struct sockaddr_un) == RSTRING_LEN(addr) &&
sun_path == sockaddr->sun_path &&
sun_path + strlen(sun_path) == RSTRING_PTR(addr) + RSTRING_LEN(addr)) {
@@ -5289,7 +5289,7 @@ addrinfo_initialize(VALUE self, SEL sel, int argc, VALUE *argv)
VALUE afamily = rb_ary_entry(sockaddr_ary, 0);
int af;
StringValue(afamily);
- if (family_to_int((char *)RSTRING_PTR(afamily), RSTRING_LEN(afamily), &af) == -1)
+ if (family_to_int((char *)RSTRING_PTR(afamily), RSTRING_LENINT(afamily), &af) == -1)
rb_raise(rb_eSocket, "unknown address family: %s", StringValueCStr(afamily));
switch (af) {
case AF_INET: /* ["AF_INET", 46102, "localhost.localdomain", "127.0.0.1"] */
@@ -5335,7 +5335,7 @@ addrinfo_initialize(VALUE self, SEL sel, int argc, VALUE *argv)
else {
StringValue(sockaddr_arg);
sockaddr_ptr = (struct sockaddr *)RSTRING_PTR(sockaddr_arg);
- sockaddr_len = RSTRING_LEN(sockaddr_arg);
+ sockaddr_len = RSTRING_LENINT(sockaddr_arg);
init_addrinfo(rai, sockaddr_ptr, sockaddr_len,
i_pfamily, i_socktype, i_protocol,
canonname, inspectname);
View
11 file.c
@@ -108,14 +108,9 @@ rb_get_path_check(VALUE obj, int level)
rb_insecure_operation();
}
- if (rb_vm_respond_to(obj, selToPath, true)) {
- tmp = rb_vm_call(obj, selToPath, 0, NULL);
- }
- else {
- tmp = rb_check_string_type(obj);
- if (NIL_P(tmp)) {
- tmp = obj;
- }
+ tmp = rb_vm_check_call(obj, selToPath, 0, NULL);
+ if (tmp == Qundef) {
+ tmp = obj;
}
StringValue(tmp);
View
11 icu-1060/unicode/unistr.h
@@ -3247,6 +3247,12 @@ class U_COMMON_API UnicodeString : public Replaceable
} fUnion;
};
+#if defined(__clang__)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wunknown-pragmas"
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wreturn-type-c-linkage"
+#endif
/**
* Create a new UnicodeString with the concatenation of two others.
*
@@ -3258,6 +3264,11 @@ class U_COMMON_API UnicodeString : public Replaceable
U_COMMON_API UnicodeString U_EXPORT2
operator+ (const UnicodeString &s1, const UnicodeString &s2);
+#if defined(__clang__)
+#pragma clang diagnostic pop
+#pragma clang diagnostic pop
+#endif
+
//========================================
// Inline members
//========================================
View
1  include/ruby/ruby.h
@@ -480,6 +480,7 @@ VALUE rb_ary_elt(VALUE, long);
void rb_ary_elt_set(VALUE, long, VALUE);
#define RARRAY_LEN(a) (rb_ary_len((VALUE)a))
+#define RARRAY_LENINT(a) (rb_long2int(RARRAY_LEN(a)))
#define RARRAY_AT(a,i) (rb_ary_elt((VALUE)a, (long)i))
/* IMPORTANT: try to avoid using RARRAY_PTR if necessary, because it's
* a _much_ slower operation than RARRAY_AT. RARRAY_PTR is only provided for
View
3  io.c
@@ -3115,7 +3115,8 @@ rb_io_init_copy(VALUE dest, SEL sel, VALUE origin)
VALUE
rb_io_printf(VALUE out, SEL sel, int argc, VALUE *argv)
{
- return rb_io_write(out, rb_f_sprintf(argc, argv));
+ rb_io_write(out, rb_f_sprintf(argc, argv));
+ return Qnil;
}
/*
View
9 object.c
@@ -2500,7 +2500,8 @@ convert_type(VALUE val, const char *tname, const char *method, int raise)
// if (!rb_obj_respond_to(val, m, Qtrue)) {
SEL sel = sel_registerName(method);
- if (!rb_vm_respond_to(val, sel, true)) {
+ VALUE result = rb_vm_check_call(val, sel, 0, NULL);
+ if (result == Qundef) {
if (raise) {
rb_raise(rb_eTypeError, "can't convert %s into %s",
NIL_P(val) ? "nil" :
@@ -2509,11 +2510,9 @@ convert_type(VALUE val, const char *tname, const char *method, int raise)
rb_obj_classname(val),
tname);
}
- else {
- return Qnil;
- }
+ return Qnil;
}
- return rb_vm_call(val, sel, 0, NULL);
+ return result;
}
VALUE
View
3  rational.c
@@ -2012,9 +2012,6 @@ make_patterns(void)
#define id_split rb_intern("split")
#define f_split(x,y) rb_funcall(x, id_split, 1, y)
-#define id_strip rb_intern("strip")
-#define f_strip(x) rb_funcall(x, id_strip, 0)
-
#include <ctype.h>
static VALUE
View
2  spec/frozen/tags/macruby/core/array/rotate_tags.txt
@@ -1,2 +0,0 @@
-fails:Array#rotate with an argument n raises a TypeError if not passed an integer-like argument
-fails:Array#rotate! with an argument n raises a TypeError if not passed an integer-like argument
View
3  string.c
@@ -1471,6 +1471,7 @@ rb_str_xcopy_uchars(VALUE str, long *len_p)
UChar *chars = NULL;
long len = 0;
+ str = (VALUE)str_need_string(str);
if (IS_RSTR(str)) {
rb_str_t *rstr = RSTR(str);
len = str_length(rstr);
@@ -2636,7 +2637,7 @@ rstr_format(VALUE str, SEL sel, VALUE arg)
VALUE tmp = rb_check_array_type(arg);
if (!NIL_P(tmp)) {
- return rb_str_format(RARRAY_LEN(tmp), RARRAY_PTR(tmp), str);
+ return rb_str_format(RARRAY_LENINT(tmp), RARRAY_PTR(tmp), str);
}
return rb_str_format(1, &arg, str);
}
View
2  struct.c
@@ -376,7 +376,7 @@ struct_alloc(VALUE klass)
VALUE
rb_struct_alloc(VALUE klass, VALUE values)
{
- return rb_class_new_instance(RARRAY_LEN(values), (VALUE *)RARRAY_PTR(values), klass);
+ return rb_class_new_instance(RARRAY_LENINT(values), (VALUE *)RARRAY_PTR(values), klass);
}
VALUE
View
4 test-mri/test/ruby/test_exception.rb
@@ -225,6 +225,8 @@ def test_errat
end
def test_safe4
+ skip("[BUG : #842] SecurityError Level 4")
+
cmd = proc{raise SystemExit}
safe0_p = proc{|*args| args}
@@ -292,6 +294,8 @@ def test_set_backtrace
end
def test_exit_success_p
+ skip("[BUG : #???] Should raise an exception when call exit within begin/rescue block")
+
begin
exit
rescue SystemExit => e
View
12 time.c
@@ -678,10 +678,7 @@ num_exact(VALUE v)
goto typeerror;
default:
- tmp = Qundef;
- if (rb_vm_respond_to(v, sel_to_r, true)) {
- tmp = rb_vm_call(v, sel_to_r, 0, NULL);
- }
+ tmp = rb_vm_check_call(v, sel_to_r, 0, NULL);
if (tmp != Qundef) {
if (rb_respond_to(v, rb_intern("to_str"))) goto typeerror;
v = tmp;
@@ -1502,7 +1499,7 @@ calc_wday(int year, int month, int day)
static VALUE
guess_local_offset(struct vtm *vtm_utc, int *isdst_ret, const char **zone_ret)
{
- struct tm tm;
+ struct tm tm = {0}; // avoid warning for gcc
long gmtoff;
const char *zone;
time_t t;
@@ -2381,10 +2378,7 @@ time_timespec(VALUE num, int interval)
default:
i = INT2FIX(1);
- ary = Qundef;
- if (rb_vm_respond_to(num, sel_divmod, true)) {
- ary = rb_vm_call(num, sel_divmod, 0, NULL);
- }
+ ary = rb_vm_check_call(num, sel_divmod, 1, &i);
if (ary != Qundef && !NIL_P(ary = rb_check_array_type(ary))) {
i = rb_ary_entry(ary, 0);
f = rb_ary_entry(ary, 1);
View
9 vm.h
@@ -692,6 +692,15 @@ rb_vm_method_call(rb_vm_method_t *m, rb_vm_block_t *block, int argc,
argc, argv);
}
+static inline VALUE
+rb_vm_check_call(VALUE self, SEL sel, int argc, const VALUE *argv)
+{
+ if (!rb_vm_respond_to(self, sel, true)) {
+ return Qundef;
+ }
+ return rb_vm_call(self, sel, argc, argv);
+}
+
VALUE rb_vm_yield_args(void *vm, int argc, const VALUE *argv);
static inline VALUE
View
6 vm_eval.c
@@ -78,7 +78,7 @@ rb_apply(VALUE recv, ID mid, VALUE args)
int argc;
VALUE *argv;
- argc = RARRAY_LEN(args); /* Assigns LONG, but argc is INT */
+ argc = RARRAY_LENINT(args);
argv = ALLOCA_N(VALUE, argc);
MEMCPY(argv, RARRAY_PTR(args), VALUE, argc);
return rb_call(recv, mid, argc, argv, CALL_FCALL, false);
@@ -220,7 +220,7 @@ rb_yield_splat(VALUE values)
if (NIL_P(tmp)) {
rb_raise(rb_eArgError, "not an array");
}
- return rb_vm_yield(RARRAY_LEN(tmp), RARRAY_PTR(tmp));
+ return rb_vm_yield(RARRAY_LENINT(tmp), RARRAY_PTR(tmp));
}
static VALUE
@@ -461,7 +461,7 @@ rb_eval_cmd(VALUE cmd, VALUE arg, int level)
if (TYPE(cmd) != T_STRING) {
rb_set_safe_level_force(level);
- val = rb_funcall2(cmd, rb_intern("call"), RARRAY_LEN(arg),
+ val = rb_funcall2(cmd, rb_intern("call"), RARRAY_LENINT(arg),
RARRAY_PTR(arg));
rb_set_safe_level_force(safe);
return val;

No commit comments for this range

Something went wrong with that request. Please try again.