summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/Win32API/Win32API.c10
-rw-r--r--ext/dbm/dbm.c10
-rw-r--r--ext/dl/cfunc.c6
-rw-r--r--ext/gdbm/gdbm.c10
-rw-r--r--ext/iconv/iconv.c8
-rw-r--r--ext/openssl/ossl.c2
-rw-r--r--ext/openssl/ossl_ocsp.c8
-rw-r--r--ext/openssl/ossl_ssl.c8
-rw-r--r--ext/openssl/ossl_x509cert.c8
-rw-r--r--ext/openssl/ossl_x509crl.c16
-rw-r--r--ext/openssl/ossl_x509req.c8
-rw-r--r--ext/openssl/ossl_x509revoked.c8
-rw-r--r--ext/racc/cparse/cparse.c64
-rw-r--r--ext/readline/readline.c8
-rw-r--r--ext/sdbm/init.c10
-rw-r--r--ext/socket/socket.c22
-rw-r--r--ext/syck/rubyext.c12
-rw-r--r--ext/tk/tcltklib.c45
-rw-r--r--ext/win32ole/win32ole.c18
19 files changed, 138 insertions, 143 deletions
diff --git a/ext/Win32API/Win32API.c b/ext/Win32API/Win32API.c
index 221a46df1bd..9a2de01f2d0 100644
--- a/ext/Win32API/Win32API.c
+++ b/ext/Win32API/Win32API.c
@@ -72,8 +72,8 @@ Win32API_initialize(self, dllname, proc, import, export)
case T_NIL:
break;
case T_ARRAY:
- ptr = RARRAY(import)->ptr;
- for (i = 0, len = RARRAY(import)->len; i < len; i++) {
+ ptr = RARRAY_PTR(import);
+ for (i = 0, len = RARRAY_LEN(import); i < len; i++) {
SafeStringValue(ptr[i]);
switch (*(char *)RSTRING_PTR(ptr[i])) {
case 'N': case 'n': case 'L': case 'l':
@@ -107,8 +107,8 @@ Win32API_initialize(self, dllname, proc, import, export)
break;
}
- if (16 < RARRAY(a_import)->len) {
- rb_raise(rb_eRuntimeError, "too many parameters: %d\n", RARRAY(a_import)->len);
+ if (16 < RARRAY_LEN(a_import)) {
+ rb_raise(rb_eRuntimeError, "too many parameters: %d\n", RARRAY_LEN(a_import));
}
rb_iv_set(self, "__import__", a_import);
@@ -159,7 +159,7 @@ Win32API_Call(argc, argv, obj)
VALUE obj_export = rb_iv_get(obj, "__export__");
FARPROC ApiFunction = (FARPROC)NUM2ULONG(obj_proc);
int items = rb_scan_args(argc, argv, "0*", &args);
- int nimport = RARRAY(obj_import)->len;
+ int nimport = RARRAY_LEN(obj_import);
if (items != nimport)
diff --git a/ext/dbm/dbm.c b/ext/dbm/dbm.c
index 3bc1a83103f..e89f8b1d749 100644
--- a/ext/dbm/dbm.c
+++ b/ext/dbm/dbm.c
@@ -345,8 +345,8 @@ fdbm_delete_if(VALUE obj)
GetDBM2(obj, dbmp, dbm);
}
- for (i = 0; i < RARRAY(ary)->len; i++) {
- keystr = RARRAY(ary)->ptr[i];
+ for (i = 0; i < RARRAY_LEN(ary); i++) {
+ keystr = RARRAY_PTR(ary)[i];
StringValue(keystr);
key.dptr = RSTRING_PTR(keystr);
key.dsize = RSTRING_LEN(keystr);
@@ -355,7 +355,7 @@ fdbm_delete_if(VALUE obj)
}
}
if (status) rb_jump_tag(status);
- if (n > 0) dbmp->di_size = n - RARRAY(ary)->len;
+ if (n > 0) dbmp->di_size = n - RARRAY_LEN(ary);
return obj;
}
@@ -405,10 +405,10 @@ static VALUE
update_i(VALUE pair, VALUE dbm)
{
Check_Type(pair, T_ARRAY);
- if (RARRAY(pair)->len < 2) {
+ if (RARRAY_LEN(pair) < 2) {
rb_raise(rb_eArgError, "pair must be [key, value]");
}
- fdbm_store(dbm, RARRAY(pair)->ptr[0], RARRAY(pair)->ptr[1]);
+ fdbm_store(dbm, RARRAY_PTR(pair)[0], RARRAY_PTR(pair)[1]);
return Qnil;
}
diff --git a/ext/dl/cfunc.c b/ext/dl/cfunc.c
index 458132b7843..253c78f2b15 100644
--- a/ext/dl/cfunc.c
+++ b/ext/dl/cfunc.c
@@ -226,7 +226,7 @@ rb_dlcfunc_inspect(VALUE self)
# define DECL_FUNC_CDECL(f,ret,args) ret (FUNC_CDECL(*f))(args)
# define DECL_FUNC_STDCALL(f,ret,args) ret (FUNC_STDCALL(*f))(args)
-#define CALL_CASE switch( RARRAY(ary)->len ){ \
+#define CALL_CASE switch( RARRAY_LEN(ary) ){ \
CASE(0); break; \
CASE(1); break; CASE(2); break; CASE(3); break; CASE(4); break; CASE(5); break; \
CASE(6); break; CASE(7); break; CASE(8); break; CASE(9); break; CASE(10);break; \
@@ -256,11 +256,11 @@ rb_dlcfunc_call(VALUE self, VALUE ary)
return Qnil;
}
- for( i = 0; i < RARRAY(ary)->len; i++ ){
+ for( i = 0; i < RARRAY_LEN(ary); i++ ){
if( i >= DLSTACK_SIZE ){
rb_raise(rb_eDLError, "too many arguments (stack overflow)");
}
- stack[i] = NUM2LONG(RARRAY(ary)->ptr[i]);
+ stack[i] = NUM2LONG(RARRAY_PTR(ary)[i]);
}
/* calltype == CFUNC_CDECL */
diff --git a/ext/gdbm/gdbm.c b/ext/gdbm/gdbm.c
index 8c9b5a72e54..dd7d1960d07 100644
--- a/ext/gdbm/gdbm.c
+++ b/ext/gdbm/gdbm.c
@@ -414,10 +414,10 @@ fgdbm_delete_if(VALUE obj)
GetDBM2(obj, dbmp, dbm);
}
- for (i = 0; i < RARRAY(ary)->len; i++)
- rb_gdbm_delete(obj, RARRAY(ary)->ptr[i]);
+ for (i = 0; i < RARRAY_LEN(ary); i++)
+ rb_gdbm_delete(obj, RARRAY_PTR(ary)[i]);
if (status) rb_jump_tag(status);
- if (n > 0) dbmp->di_size = n - RARRAY(ary)->len;
+ if (n > 0) dbmp->di_size = n - RARRAY_LEN(ary);
return obj;
}
@@ -508,10 +508,10 @@ static VALUE
update_i(VALUE pair, VALUE dbm)
{
Check_Type(pair, T_ARRAY);
- if (RARRAY(pair)->len < 2) {
+ if (RARRAY_LEN(pair) < 2) {
rb_raise(rb_eArgError, "pair must be [key, value]");
}
- fgdbm_store(dbm, RARRAY(pair)->ptr[0], RARRAY(pair)->ptr[1]);
+ fgdbm_store(dbm, RARRAY_PTR(pair)[0], RARRAY_PTR(pair)[1]);
return Qnil;
}
diff --git a/ext/iconv/iconv.c b/ext/iconv/iconv.c
index 0c89c2ab176..0a5d0dface5 100644
--- a/ext/iconv/iconv.c
+++ b/ext/iconv/iconv.c
@@ -350,7 +350,7 @@ iconv_convert(iconv_t cd, VALUE str, int start, int length, struct iconv_env_t*
unsigned int i;
rescue = iconv_fail(error, Qnil, Qnil, env, 0);
if (TYPE(rescue) == T_ARRAY) {
- str = RARRAY(rescue)->len > 0 ? RARRAY(rescue)->ptr[0] : Qnil;
+ str = RARRAY_LEN(rescue) > 0 ? RARRAY_PTR(rescue)[0] : Qnil;
}
if (FIXNUM_P(str) && (i = FIX2INT(str)) <= 0xff) {
char c = i;
@@ -434,9 +434,9 @@ iconv_convert(iconv_t cd, VALUE str, int start, int length, struct iconv_env_t*
str = rb_str_derive(str, inptr, inlen);
rescue = iconv_fail(error, ret, str, env, errmsg);
if (TYPE(rescue) == T_ARRAY) {
- if ((len = RARRAY(rescue)->len) > 0)
- rb_str_concat(ret, RARRAY(rescue)->ptr[0]);
- if (len > 1 && !NIL_P(str = RARRAY(rescue)->ptr[1])) {
+ if ((len = RARRAY_LEN(rescue)) > 0)
+ rb_str_concat(ret, RARRAY_PTR(rescue)[0]);
+ if (len > 1 && !NIL_P(str = RARRAY_PTR(rescue)[1])) {
StringValue(str);
inlen = length = RSTRING_LEN(str);
instart = inptr = RSTRING_PTR(str);
diff --git a/ext/openssl/ossl.c b/ext/openssl/ossl.c
index 4000e8fc58b..16e93bc9390 100644
--- a/ext/openssl/ossl.c
+++ b/ext/openssl/ossl.c
@@ -59,7 +59,7 @@ ossl_x509_ary2sk0(VALUE ary)
sk = sk_X509_new_null();
if (!sk) ossl_raise(eOSSLError, NULL);
- for (i = 0; i < RARRAY(ary)->len; i++) {
+ for (i = 0; i < RARRAY_LEN(ary); i++) {
val = rb_ary_entry(ary, i);
if (!rb_obj_is_kind_of(val, cX509Cert)) {
sk_X509_pop_free(sk, X509_free);
diff --git a/ext/openssl/ossl_ocsp.c b/ext/openssl/ossl_ocsp.c
index 45d7c6a67a7..aa6bd61b3cd 100644
--- a/ext/openssl/ossl_ocsp.c
+++ b/ext/openssl/ossl_ocsp.c
@@ -461,8 +461,8 @@ ossl_ocspbres_add_status(VALUE self, VALUE cid, VALUE status,
if(!NIL_P(ext)){
/* All ary's members should be X509Extension */
Check_Type(ext, T_ARRAY);
- for (i = 0; i < RARRAY(ext)->len; i++)
- OSSL_Check_Kind(RARRAY(ext)->ptr[i], cX509Ext);
+ for (i = 0; i < RARRAY_LEN(ext); i++)
+ OSSL_Check_Kind(RARRAY_PTR(ext)[i], cX509Ext);
}
error = 0;
@@ -490,8 +490,8 @@ ossl_ocspbres_add_status(VALUE self, VALUE cid, VALUE status,
X509_EXTENSION *x509ext;
sk_X509_EXTENSION_pop_free(single->singleExtensions, X509_EXTENSION_free);
single->singleExtensions = NULL;
- for(i = 0; i < RARRAY(ext)->len; i++){
- x509ext = DupX509ExtPtr(RARRAY(ext)->ptr[i]);
+ for(i = 0; i < RARRAY_LEN(ext); i++){
+ x509ext = DupX509ExtPtr(RARRAY_PTR(ext)[i]);
if(!OCSP_SINGLERESP_add_ext(single, x509ext, -1)){
X509_EXTENSION_free(x509ext);
error = 1;
diff --git a/ext/openssl/ossl_ssl.c b/ext/openssl/ossl_ssl.c
index 844a461449a..d956c908be8 100644
--- a/ext/openssl/ossl_ssl.c
+++ b/ext/openssl/ossl_ssl.c
@@ -349,8 +349,8 @@ ossl_sslctx_setup(VALUE self)
val = ossl_sslctx_get_client_ca(self);
if(!NIL_P(val)){
if(TYPE(val) == T_ARRAY){
- for(i = 0; i < RARRAY(val)->len; i++){
- client_ca = GetX509CertPtr(RARRAY(val)->ptr[i]);
+ for(i = 0; i < RARRAY_LEN(val); i++){
+ client_ca = GetX509CertPtr(RARRAY_PTR(val)[i]);
if (!SSL_CTX_add_client_CA(ctx, client_ca)){
/* Copies X509_NAME => FREE it. */
ossl_raise(eSSLError, "SSL_CTX_add_client_CA");
@@ -459,12 +459,12 @@ ossl_sslctx_set_ciphers(VALUE self, VALUE v)
return v;
else if (TYPE(v) == T_ARRAY) {
str = rb_str_new(0, 0);
- for (i = 0; i < RARRAY(v)->len; i++) {
+ for (i = 0; i < RARRAY_LEN(v); i++) {
elem = rb_ary_entry(v, i);
if (TYPE(elem) == T_ARRAY) elem = rb_ary_entry(elem, 0);
elem = rb_String(elem);
rb_str_append(str, elem);
- if (i < RARRAY(v)->len-1) rb_str_cat2(str, ":");
+ if (i < RARRAY_LEN(v)-1) rb_str_cat2(str, ":");
}
} else {
str = v;
diff --git a/ext/openssl/ossl_x509cert.c b/ext/openssl/ossl_x509cert.c
index f613c800e1b..0276764f83b 100644
--- a/ext/openssl/ossl_x509cert.c
+++ b/ext/openssl/ossl_x509cert.c
@@ -557,14 +557,14 @@ ossl_x509_set_extensions(VALUE self, VALUE ary)
Check_Type(ary, T_ARRAY);
/* All ary's members should be X509Extension */
- for (i=0; i<RARRAY(ary)->len; i++) {
- OSSL_Check_Kind(RARRAY(ary)->ptr[i], cX509Ext);
+ for (i=0; i<RARRAY_LEN(ary); i++) {
+ OSSL_Check_Kind(RARRAY_PTR(ary)[i], cX509Ext);
}
GetX509(self, x509);
sk_X509_EXTENSION_pop_free(x509->cert_info->extensions, X509_EXTENSION_free);
x509->cert_info->extensions = NULL;
- for (i=0; i<RARRAY(ary)->len; i++) {
- ext = DupX509ExtPtr(RARRAY(ary)->ptr[i]);
+ for (i=0; i<RARRAY_LEN(ary); i++) {
+ ext = DupX509ExtPtr(RARRAY_PTR(ary)[i]);
if (!X509_add_ext(x509, ext, -1)) { /* DUPs ext - FREE it */
X509_EXTENSION_free(ext);
diff --git a/ext/openssl/ossl_x509crl.c b/ext/openssl/ossl_x509crl.c
index 0dc22416e77..be9ddacf487 100644
--- a/ext/openssl/ossl_x509crl.c
+++ b/ext/openssl/ossl_x509crl.c
@@ -287,14 +287,14 @@ ossl_x509crl_set_revoked(VALUE self, VALUE ary)
Check_Type(ary, T_ARRAY);
/* All ary members should be X509 Revoked */
- for (i=0; i<RARRAY(ary)->len; i++) {
- OSSL_Check_Kind(RARRAY(ary)->ptr[i], cX509Rev);
+ for (i=0; i<RARRAY_LEN(ary); i++) {
+ OSSL_Check_Kind(RARRAY_PTR(ary)[i], cX509Rev);
}
GetX509CRL(self, crl);
sk_X509_REVOKED_pop_free(crl->crl->revoked, X509_REVOKED_free);
crl->crl->revoked = NULL;
- for (i=0; i<RARRAY(ary)->len; i++) {
- rev = DupX509RevokedPtr(RARRAY(ary)->ptr[i]);
+ for (i=0; i<RARRAY_LEN(ary); i++) {
+ rev = DupX509RevokedPtr(RARRAY_PTR(ary)[i]);
if (!X509_CRL_add0_revoked(crl, rev)) { /* NO DUP - don't free! */
ossl_raise(eX509CRLError, NULL);
}
@@ -461,14 +461,14 @@ ossl_x509crl_set_extensions(VALUE self, VALUE ary)
Check_Type(ary, T_ARRAY);
/* All ary members should be X509 Extensions */
- for (i=0; i<RARRAY(ary)->len; i++) {
- OSSL_Check_Kind(RARRAY(ary)->ptr[i], cX509Ext);
+ for (i=0; i<RARRAY_LEN(ary); i++) {
+ OSSL_Check_Kind(RARRAY_PTR(ary)[i], cX509Ext);
}
GetX509CRL(self, crl);
sk_X509_EXTENSION_pop_free(crl->crl->extensions, X509_EXTENSION_free);
crl->crl->extensions = NULL;
- for (i=0; i<RARRAY(ary)->len; i++) {
- ext = DupX509ExtPtr(RARRAY(ary)->ptr[i]);
+ for (i=0; i<RARRAY_LEN(ary); i++) {
+ ext = DupX509ExtPtr(RARRAY_PTR(ary)[i]);
if(!X509_CRL_add_ext(crl, ext, -1)) { /* DUPs ext - FREE it */
X509_EXTENSION_free(ext);
ossl_raise(eX509CRLError, NULL);
diff --git a/ext/openssl/ossl_x509req.c b/ext/openssl/ossl_x509req.c
index 10f0d20431a..13a42dddaf2 100644
--- a/ext/openssl/ossl_x509req.c
+++ b/ext/openssl/ossl_x509req.c
@@ -403,14 +403,14 @@ ossl_x509req_set_attributes(VALUE self, VALUE ary)
VALUE item;
Check_Type(ary, T_ARRAY);
- for (i=0;i<RARRAY(ary)->len; i++) {
- OSSL_Check_Kind(RARRAY(ary)->ptr[i], cX509Attr);
+ for (i=0;i<RARRAY_LEN(ary); i++) {
+ OSSL_Check_Kind(RARRAY_PTR(ary)[i], cX509Attr);
}
GetX509Req(self, req);
sk_X509_ATTRIBUTE_pop_free(req->req_info->attributes, X509_ATTRIBUTE_free);
req->req_info->attributes = NULL;
- for (i=0;i<RARRAY(ary)->len; i++) {
- item = RARRAY(ary)->ptr[i];
+ for (i=0;i<RARRAY_LEN(ary); i++) {
+ item = RARRAY_PTR(ary)[i];
attr = DupX509AttrPtr(item);
if (!X509_REQ_add1_attr(req, attr)) {
ossl_raise(eX509ReqError, NULL);
diff --git a/ext/openssl/ossl_x509revoked.c b/ext/openssl/ossl_x509revoked.c
index 3ccac8d26a4..d0f816bad47 100644
--- a/ext/openssl/ossl_x509revoked.c
+++ b/ext/openssl/ossl_x509revoked.c
@@ -175,14 +175,14 @@ ossl_x509revoked_set_extensions(VALUE self, VALUE ary)
VALUE item;
Check_Type(ary, T_ARRAY);
- for (i=0; i<RARRAY(ary)->len; i++) {
- OSSL_Check_Kind(RARRAY(ary)->ptr[i], cX509Ext);
+ for (i=0; i<RARRAY_LEN(ary); i++) {
+ OSSL_Check_Kind(RARRAY_PTR(ary)[i], cX509Ext);
}
GetX509Rev(self, rev);
sk_X509_EXTENSION_pop_free(rev->extensions, X509_EXTENSION_free);
rev->extensions = NULL;
- for (i=0; i<RARRAY(ary)->len; i++) {
- item = RARRAY(ary)->ptr[i];
+ for (i=0; i<RARRAY_LEN(ary); i++) {
+ item = RARRAY_PTR(ary)[i];
ext = DupX509ExtPtr(item);
if(!X509_REVOKED_add_ext(rev, ext, -1)) {
ossl_raise(eX509RevError, NULL);
diff --git a/ext/racc/cparse/cparse.c b/ext/racc/cparse/cparse.c
index 197a0eb40be..753cfddda22 100644
--- a/ext/racc/cparse/cparse.c
+++ b/ext/racc/cparse/cparse.c
@@ -88,7 +88,7 @@ num_to_long(VALUE n)
}
#define AREF(s, idx) \
- ((0 <= idx && idx < RARRAY(s)->len) ? RARRAY(s)->ptr[idx] : Qnil)
+ ((0 <= idx && idx < RARRAY_LEN(s)) ? RARRAY_PTR(s)[idx] : Qnil)
/* -----------------------------------------------------------------------
Parser Stack Interfaces
@@ -101,8 +101,8 @@ static VALUE
get_stack_tail(VALUE stack, long len)
{
if (len < 0) return Qnil; /* system error */
- if (len > RARRAY(stack)->len) len = RARRAY(stack)->len;
- return rb_ary_new4(len, RARRAY(stack)->ptr + RARRAY(stack)->len - len);
+ if (len > RARRAY_LEN(stack)) len = RARRAY_LEN(stack);
+ return rb_ary_new4(len, RARRAY_PTR(stack) + RARRAY_LEN(stack) - len);
}
static void
@@ -116,10 +116,10 @@ cut_stack_tail(VALUE stack, long len)
#define STACK_INIT_LEN 64
#define NEW_STACK() rb_ary_new2(STACK_INIT_LEN)
-#define PUSH(s, i) rb_ary_store(s, RARRAY(s)->len, i)
+#define PUSH(s, i) rb_ary_store(s, RARRAY_LEN(s), i)
#define POP(s) rb_ary_pop(s)
#define LAST_I(s) \
- ((RARRAY(s)->len > 0) ? RARRAY(s)->ptr[RARRAY(s)->len - 1] : Qnil)
+ ((RARRAY_LEN(s) > 0) ? RARRAY_PTR(s)[RARRAY_LEN(s) - 1] : Qnil)
#define GET_TAIL(s, len) get_stack_tail(s, len)
#define CUT_TAIL(s, len) cut_stack_tail(s, len)
@@ -329,23 +329,23 @@ initialize_params(VALUE vparams, VALUE parser, VALUE arg, VALUE lexer, VALUE lex
v->debug = RTEST(rb_ivar_get(parser, id_yydebug));
Check_Type(arg, T_ARRAY);
- if (!(13 <= RARRAY(arg)->len && RARRAY(arg)->len <= 14))
- rb_raise(RaccBug, "[Racc Bug] wrong arg.size %ld", RARRAY(arg)->len);
- v->action_table = assert_array (RARRAY(arg)->ptr[ 0]);
- v->action_check = assert_array (RARRAY(arg)->ptr[ 1]);
- v->action_default = assert_array (RARRAY(arg)->ptr[ 2]);
- v->action_pointer = assert_array (RARRAY(arg)->ptr[ 3]);
- v->goto_table = assert_array (RARRAY(arg)->ptr[ 4]);
- v->goto_check = assert_array (RARRAY(arg)->ptr[ 5]);
- v->goto_default = assert_array (RARRAY(arg)->ptr[ 6]);
- v->goto_pointer = assert_array (RARRAY(arg)->ptr[ 7]);
- v->nt_base = assert_integer(RARRAY(arg)->ptr[ 8]);
- v->reduce_table = assert_array (RARRAY(arg)->ptr[ 9]);
- v->token_table = assert_hash (RARRAY(arg)->ptr[10]);
- v->shift_n = assert_integer(RARRAY(arg)->ptr[11]);
- v->reduce_n = assert_integer(RARRAY(arg)->ptr[12]);
- if (RARRAY(arg)->len > 13) {
- v->use_result_var = RTEST(RARRAY(arg)->ptr[13]);
+ if (!(13 <= RARRAY_LEN(arg) && RARRAY_LEN(arg) <= 14))
+ rb_raise(RaccBug, "[Racc Bug] wrong arg.size %ld", RARRAY_LEN(arg));
+ v->action_table = assert_array (RARRAY_PTR(arg)[ 0]);
+ v->action_check = assert_array (RARRAY_PTR(arg)[ 1]);
+ v->action_default = assert_array (RARRAY_PTR(arg)[ 2]);
+ v->action_pointer = assert_array (RARRAY_PTR(arg)[ 3]);
+ v->goto_table = assert_array (RARRAY_PTR(arg)[ 4]);
+ v->goto_check = assert_array (RARRAY_PTR(arg)[ 5]);
+ v->goto_default = assert_array (RARRAY_PTR(arg)[ 6]);
+ v->goto_pointer = assert_array (RARRAY_PTR(arg)[ 7]);
+ v->nt_base = assert_integer(RARRAY_PTR(arg)[ 8]);
+ v->reduce_table = assert_array (RARRAY_PTR(arg)[ 9]);
+ v->token_table = assert_hash (RARRAY_PTR(arg)[10]);
+ v->shift_n = assert_integer(RARRAY_PTR(arg)[11]);
+ v->reduce_n = assert_integer(RARRAY_PTR(arg)[12]);
+ if (RARRAY_LEN(arg) > 13) {
+ v->use_result_var = RTEST(RARRAY_PTR(arg)[13]);
}
else {
v->use_result_var = Qtrue;
@@ -424,12 +424,12 @@ extract_user_token(struct cparse_params *v, VALUE block_args,
v->lex_is_iterator ? "yielded" : "returned",
rb_class2name(CLASS_OF(block_args)));
}
- if (RARRAY(block_args)->len != 2) {
+ if (RARRAY_LEN(block_args) != 2) {
rb_raise(rb_eArgError,
"%s() %s wrong size of array (%ld for 2)",
v->lex_is_iterator ? rb_id2name(v->lexmid) : "next_token",
v->lex_is_iterator ? "yielded" : "returned",
- RARRAY(block_args)->len);
+ RARRAY_LEN(block_args));
}
*tok = AREF(block_args, 0);
*val = AREF(block_args, 1);
@@ -565,7 +565,7 @@ parse_main(struct cparse_params *v, VALUE tok, VALUE val, int resume)
accept:
if (v->debug) rb_funcall(v->parser, id_d_accept, 0);
- v->retval = RARRAY(v->vstack)->ptr[0];
+ v->retval = RARRAY_PTR(v->vstack)[0];
v->fin = CP_FIN_ACCEPT;
return;
@@ -625,7 +625,7 @@ parse_main(struct cparse_params *v, VALUE tok, VALUE val, int resume)
error_pop:
D_puts("(err) act not found: can't handle error token; pop");
- if (RARRAY(v->state)->len <= 1) {
+ if (RARRAY_LEN(v->state) <= 1) {
v->retval = Qnil;
v->fin = CP_FIN_CANTPOP;
return;
@@ -694,9 +694,9 @@ reduce0(VALUE val, VALUE data, VALUE self)
VALUE goto_state;
Data_Get_Struct(data, struct cparse_params, v);
- reduce_len = RARRAY(v->reduce_table)->ptr[v->ruleno];
- reduce_to = RARRAY(v->reduce_table)->ptr[v->ruleno+1];
- method_id = RARRAY(v->reduce_table)->ptr[v->ruleno+2];
+ reduce_len = RARRAY_PTR(v->reduce_table)[v->ruleno];
+ reduce_to = RARRAY_PTR(v->reduce_table)[v->ruleno+1];
+ method_id = RARRAY_PTR(v->reduce_table)[v->ruleno+2];
len = NUM2LONG(reduce_len);
mid = value_to_id(method_id);
@@ -711,10 +711,10 @@ reduce0(VALUE val, VALUE data, VALUE self)
else {
if (mid != id_noreduce) {
tmp_v = GET_TAIL(v->vstack, len);
- tmp = RARRAY(tmp_v)->ptr[0];
+ tmp = RARRAY_PTR(tmp_v)[0];
}
else {
- tmp = RARRAY(v->vstack)->ptr[ RARRAY(v->vstack)->len - len ];
+ tmp = RARRAY_PTR(v->vstack)[ RARRAY_LEN(v->vstack) - len ];
}
CUT_TAIL(v->vstack, len);
if (v->debug) {
@@ -743,7 +743,7 @@ reduce0(VALUE val, VALUE data, VALUE self)
}
/* calculate transition state */
- if (RARRAY(v->state)->len == 0)
+ if (RARRAY_LEN(v->state) == 0)
rb_raise(RaccBug, "state stack unexpectedly empty");
k2 = num_to_long(LAST_I(v->state));
k1 = num_to_long(reduce_to) - v->nt_base;
diff --git a/ext/readline/readline.c b/ext/readline/readline.c
index 94aef8db611..1e646751769 100644
--- a/ext/readline/readline.c
+++ b/ext/readline/readline.c
@@ -170,12 +170,12 @@ readline_attempted_completion_function(const char *text, int start, int end)
ary = rb_funcall(proc, rb_intern("call"), 1, rb_tainted_str_new2(text));
if (TYPE(ary) != T_ARRAY)
ary = rb_Array(ary);
- matches = RARRAY(ary)->len;
+ matches = RARRAY_LEN(ary);
if (matches == 0)
return NULL;
result = ALLOC_N(char *, matches + 2);
for (i = 0; i < matches; i++) {
- temp = rb_obj_as_string(RARRAY(ary)->ptr[i]);
+ temp = rb_obj_as_string(RARRAY_PTR(ary)[i]);
result[i + 1] = ALLOC_N(char, RSTRING_LEN(temp) + 1);
strcpy(result[i + 1], RSTRING_PTR(temp));
}
@@ -661,7 +661,7 @@ filename_completion_proc_call(VALUE self, VALUE str)
free(matches[i]);
}
free(matches);
- if (RARRAY(result)->len >= 2)
+ if (RARRAY_LEN(result) >= 2)
rb_ary_shift(result);
}
else {
@@ -686,7 +686,7 @@ username_completion_proc_call(VALUE self, VALUE str)
free(matches[i]);
}
free(matches);
- if (RARRAY(result)->len >= 2)
+ if (RARRAY_LEN(result) >= 2)
rb_ary_shift(result);
}
else {
diff --git a/ext/sdbm/init.c b/ext/sdbm/init.c
index 758d7372770..08a3ab8bf54 100644
--- a/ext/sdbm/init.c
+++ b/ext/sdbm/init.c
@@ -323,8 +323,8 @@ fsdbm_delete_if(VALUE obj)
GetDBM2(obj, dbmp, dbm);
}
- for (i = 0; i < RARRAY(ary)->len; i++) {
- keystr = RARRAY(ary)->ptr[i];
+ for (i = 0; i < RARRAY_LEN(ary); i++) {
+ keystr = RARRAY_PTR(ary)[i];
StringValue(keystr);
key.dptr = RSTRING_PTR(keystr);
key.dsize = RSTRING_LEN(keystr);
@@ -333,7 +333,7 @@ fsdbm_delete_if(VALUE obj)
}
}
if (status) rb_jump_tag(status);
- if (n > 0) dbmp->di_size = n - RARRAY(ary)->len;
+ if (n > 0) dbmp->di_size = n - RARRAY_LEN(ary);
return obj;
}
@@ -416,10 +416,10 @@ static VALUE
update_i(VALUE pair, VALUE dbm)
{
Check_Type(pair, T_ARRAY);
- if (RARRAY(pair)->len < 2) {
+ if (RARRAY_LEN(pair) < 2) {
rb_raise(rb_eArgError, "pair must be [key, value]");
}
- fsdbm_store(dbm, RARRAY(pair)->ptr[0], RARRAY(pair)->ptr[1]);
+ fsdbm_store(dbm, RARRAY_PTR(pair)[0], RARRAY_PTR(pair)[1]);
return Qnil;
}
diff --git a/ext/socket/socket.c b/ext/socket/socket.c
index e2e691a1415..8cc850b8a1a 100644
--- a/ext/socket/socket.c
+++ b/ext/socket/socket.c
@@ -2991,7 +2991,7 @@ make_addrinfo(struct addrinfo *res0)
for (res = res0; res; res = res->ai_next) {
ary = ipaddr(res->ai_addr, do_not_reverse_lookup);
if (res->ai_canonname) {
- RARRAY(ary)->ptr[2] = rb_str_new2(res->ai_canonname);
+ RARRAY_PTR(ary)[2] = rb_str_new2(res->ai_canonname);
}
rb_ary_push(ary, INT2FIX(res->ai_family));
rb_ary_push(ary, INT2FIX(res->ai_socktype));
@@ -3232,17 +3232,17 @@ sock_s_getnameinfo(int argc, VALUE *argv)
if (!NIL_P(tmp)) {
sa = tmp;
MEMZERO(&hints, struct addrinfo, 1);
- if (RARRAY(sa)->len == 3) {
- af = RARRAY(sa)->ptr[0];
- port = RARRAY(sa)->ptr[1];
- host = RARRAY(sa)->ptr[2];
+ if (RARRAY_LEN(sa) == 3) {
+ af = RARRAY_PTR(sa)[0];
+ port = RARRAY_PTR(sa)[1];
+ host = RARRAY_PTR(sa)[2];
}
- else if (RARRAY(sa)->len >= 4) {
- af = RARRAY(sa)->ptr[0];
- port = RARRAY(sa)->ptr[1];
- host = RARRAY(sa)->ptr[3];
+ else if (RARRAY_LEN(sa) >= 4) {
+ af = RARRAY_PTR(sa)[0];
+ port = RARRAY_PTR(sa)[1];
+ host = RARRAY_PTR(sa)[3];
if (NIL_P(host)) {
- host = RARRAY(sa)->ptr[2];
+ host = RARRAY_PTR(sa)[2];
}
else {
/*
@@ -3256,7 +3256,7 @@ sock_s_getnameinfo(int argc, VALUE *argv)
}
else {
rb_raise(rb_eArgError, "array size should be 3 or 4, %ld given",
- RARRAY(sa)->len);
+ RARRAY_LEN(sa));
}
/* host */
if (NIL_P(host)) {
diff --git a/ext/syck/rubyext.c b/ext/syck/rubyext.c
index d036d24451d..371ef155990 100644
--- a/ext/syck/rubyext.c
+++ b/ext/syck/rubyext.c
@@ -1023,7 +1023,7 @@ syck_const_find(VALUE const_name)
VALUE tclass = rb_cObject;
VALUE tparts = rb_str_split( const_name, "::" );
int i = 0;
- for ( i = 0; i < RARRAY(tparts)->len; i++ ) {
+ for ( i = 0; i < RARRAY_LEN(tparts); i++ ) {
VALUE tpart = rb_to_id( rb_ary_entry( tparts, i ) );
if ( !rb_const_defined( tclass, tpart ) ) return Qnil;
tclass = rb_const_get( tclass, tpart );
@@ -1059,7 +1059,7 @@ syck_resolver_transfer(VALUE self, VALUE type, VALUE val)
VALUE subclass_parts = rb_ary_new();
VALUE parts = rb_str_split( type, ":" );
- while ( RARRAY(parts)->len > 1 )
+ while ( RARRAY_LEN(parts) > 1 )
{
VALUE partial;
rb_ary_unshift( subclass_parts, rb_ary_pop( parts ) );
@@ -1077,7 +1077,7 @@ syck_resolver_transfer(VALUE self, VALUE type, VALUE val)
if ( ! NIL_P( target_class ) )
{
subclass = target_class;
- if ( RARRAY(subclass_parts)->len > 0 && rb_respond_to( target_class, s_tag_subclasses ) &&
+ if ( RARRAY_LEN(subclass_parts) > 0 && rb_respond_to( target_class, s_tag_subclasses ) &&
RTEST( rb_funcall( target_class, s_tag_subclasses, 0 ) ) )
{
VALUE subclass_v;
@@ -1502,7 +1502,7 @@ syck_seq_value_set(VALUE self, VALUE val)
if ( !NIL_P( val ) ) {
int i;
syck_seq_empty( node );
- for ( i = 0; i < RARRAY( val )->len; i++ )
+ for ( i = 0; i < RARRAY_LEN( val ); i++ )
{
syck_seq_add( node, rb_ary_entry(val, i) );
}
@@ -1587,7 +1587,7 @@ syck_map_initialize(VALUE self, VALUE type_id, VALUE val, VALUE style)
}
keys = rb_funcall( hsh, s_keys, 0 );
- for ( i = 0; i < RARRAY(keys)->len; i++ )
+ for ( i = 0; i < RARRAY_LEN(keys); i++ )
{
VALUE key = rb_ary_entry(keys, i);
syck_map_add( node, key, rb_hash_aref(hsh, key) );
@@ -1622,7 +1622,7 @@ syck_map_value_set(VALUE self, VALUE val)
syck_map_empty( node );
keys = rb_funcall( hsh, s_keys, 0 );
- for ( i = 0; i < RARRAY(keys)->len; i++ )
+ for ( i = 0; i < RARRAY_LEN(keys); i++ )
{
VALUE key = rb_ary_entry(keys, i);
syck_map_add( node, key, rb_hash_aref(hsh, key) );
diff --git a/ext/tk/tcltklib.c b/ext/tk/tcltklib.c
index 6964c5f7900..9086f3e4ab6 100644
--- a/ext/tk/tcltklib.c
+++ b/ext/tk/tcltklib.c
@@ -1133,15 +1133,15 @@ set_max_block_time(self, time)
case T_BIGNUM:
/* time is micro-second value */
divmod = rb_funcall(time, rb_intern("divmod"), 1, LONG2NUM(1000000));
- tcl_time.sec = NUM2LONG(RARRAY(divmod)->ptr[0]);
- tcl_time.usec = NUM2LONG(RARRAY(divmod)->ptr[1]);
+ tcl_time.sec = NUM2LONG(RARRAY_PTR(divmod)[0]);
+ tcl_time.usec = NUM2LONG(RARRAY_PTR(divmod)[1]);
break;
case T_FLOAT:
/* time is second value */
divmod = rb_funcall(time, rb_intern("divmod"), 1, INT2FIX(1));
- tcl_time.sec = NUM2LONG(RARRAY(divmod)->ptr[0]);
- tcl_time.usec = (long)(NUM2DBL(RARRAY(divmod)->ptr[1]) * 1000000);
+ tcl_time.sec = NUM2LONG(RARRAY_PTR(divmod)[0]);
+ tcl_time.usec = (long)(NUM2DBL(RARRAY_PTR(divmod)[1]) * 1000000);
default:
{
@@ -2595,15 +2595,14 @@ ip_ruby_cmd(clientData, interp, argc, argv)
/* get args */
args = rb_ary_new2(argc - 2);
- RARRAY(args)->len = 0;
for(i = 3; i < argc; i++) {
#if TCL_MAJOR_VERSION >= 8
str = Tcl_GetStringFromObj(argv[i], &len);
DUMP2("arg:%s",str);
- RARRAY(args)->ptr[RARRAY(args)->len++] = rb_tainted_str_new(str, len);
+ rb_ary_push(args, rb_tainted_str_new(str, len));
#else /* TCL_MAJOR_VERSION < 8 */
DUMP2("arg:%s",argv[i]);
- RARRAY(args)->ptr[RARRAY(args)->len++] = rb_tainted_str_new2(argv[i]);
+ rb_ary_push(args, rb_tainted_str_new2(argv[i]));
#endif
}
@@ -5516,7 +5515,7 @@ call_queue_handler(evPtr, flags)
}
/* set result */
- RARRAY(q->result)->ptr[0] = ret;
+ RARRAY_PTR(q->result)[0] = ret;
/* complete */
*(q->done) = -1;
@@ -5586,8 +5585,8 @@ tk_funcall(func, argc, argv, obj)
/* allocate result obj */
result = rb_ary_new2(1);
- RARRAY(result)->ptr[0] = Qnil;
- RARRAY(result)->len = 1;
+ RARRAY_PTR(result)[0] = Qnil;
+ RARRAY_LEN(result) = 1;
/* construct event data */
callq->done = alloc_done;
@@ -5614,7 +5613,7 @@ tk_funcall(func, argc, argv, obj)
DUMP2("back from handler (current thread:%lx)", current);
/* get result & free allocated memory */
- ret = RARRAY(result)->ptr[0];
+ ret = RARRAY_PTR(result)[0];
free(alloc_done);
if (argv) free(argv);
@@ -5834,7 +5833,7 @@ eval_queue_handler(evPtr, flags)
}
/* set result */
- RARRAY(q->result)->ptr[0] = ret;
+ RARRAY_PTR(q->result)[0] = ret;
/* complete */
*(q->done) = -1;
@@ -5901,8 +5900,8 @@ ip_eval(self, str)
/* allocate result obj */
result = rb_ary_new2(1);
- RARRAY(result)->ptr[0] = Qnil;
- RARRAY(result)->len = 1;
+ RARRAY_PTR(result)[0] = Qnil;
+ RARRAY_LEN(result) = 1;
/* construct event data */
evq->done = alloc_done;
@@ -5930,7 +5929,7 @@ ip_eval(self, str)
DUMP2("back from handler (current thread:%lx)", current);
/* get result & free allocated memory */
- ret = RARRAY(result)->ptr[0];
+ ret = RARRAY_PTR(result)[0];
free(alloc_done);
free(eval_str);
@@ -6911,7 +6910,7 @@ invoke_queue_handler(evPtr, flags)
}
/* set result */
- RARRAY(q->result)->ptr[0] = ret;
+ RARRAY_PTR(q->result)[0] = ret;
/* complete */
*(q->done) = -1;
@@ -6981,8 +6980,8 @@ ip_invoke_with_position(argc, argv, obj, position)
/* allocate result obj */
result = rb_ary_new2(1);
- RARRAY(result)->ptr[0] = Qnil;
- RARRAY(result)->len = 1;
+ RARRAY_PTR(result)[0] = Qnil;
+ RARRAY_LEN(result) = 1;
/* construct event data */
ivq->done = alloc_done;
@@ -7008,7 +7007,7 @@ ip_invoke_with_position(argc, argv, obj, position)
DUMP2("back from handler (current thread:%lx)", current);
/* get result & free allocated memory */
- ret = RARRAY(result)->ptr[0];
+ ret = RARRAY_PTR(result)[0];
free(alloc_done);
Tcl_Release(ivq);
@@ -7535,11 +7534,9 @@ lib_split_tklist_core(ip_obj, list_str)
for(idx = 0; idx < objc; idx++) {
elem = get_str_from_obj(objv[idx]);
if (taint_flag) OBJ_TAINT(elem);
- RARRAY(ary)->ptr[idx] = elem;
+ rb_ary_push(ary, elem);
}
- RARRAY(ary)->len = objc;
-
if (old_gc == Qfalse) rb_gc_enable();
rb_thread_critical = thr_crit_bup;
@@ -7576,10 +7573,8 @@ lib_split_tklist_core(ip_obj, list_str)
elem = rb_str_new2(argv[idx]);
}
/* rb_ivar_set(elem, ID_at_enc, rb_str_new2("binary")); */
- RARRAY(ary)->ptr[idx] = elem;
+ rb_ary_push(ary, elem);
}
- RARRAY(ary)->len = argc;
-
if (old_gc == Qfalse) rb_gc_enable();
#endif
}
diff --git a/ext/win32ole/win32ole.c b/ext/win32ole/win32ole.c
index ef30d92345d..34eebeff451 100644
--- a/ext/win32ole/win32ole.c
+++ b/ext/win32ole/win32ole.c
@@ -863,7 +863,7 @@ ole_val2variant(VALUE val, VARIANT *var)
val1 = val;
i = 0;
while(TYPE(val1) == T_ARRAY) {
- psab[i].cElements = RARRAY(val1)->len;
+ psab[i].cElements = RARRAY_LEN(val1);
psab[i].lLbound = 0;
pub[i] = psab[i].cElements;
pid[i] = 0;
@@ -1113,7 +1113,7 @@ ole_val2olevariantdata(VALUE val, VARTYPE vtype, struct olevariantdata *pvar)
val1 = val;
i = 0;
while(TYPE(val1) == T_ARRAY) {
- psab[i].cElements = RARRAY(val1)->len;
+ psab[i].cElements = RARRAY_LEN(val1);
psab[i].lLbound = 0;
pub[i] = psab[i].cElements;
pid[i] = 0;
@@ -2544,7 +2544,7 @@ ole_invoke2(VALUE self, VALUE dispid, VALUE args, VALUE types, USHORT dispkind)
VariantInit(&result);
OLEData_Get_Struct(self, pole);
- dispParams.cArgs = RARRAY(args)->len;
+ dispParams.cArgs = RARRAY_LEN(args);
dispParams.rgvarg = ALLOCA_N(VARIANTARG, dispParams.cArgs);
realargs = ALLOCA_N(VARIANTARG, dispParams.cArgs);
for (i = 0, j = dispParams.cArgs - 1; i < (int)dispParams.cArgs; i++, j--)
@@ -2575,7 +2575,7 @@ ole_invoke2(VALUE self, VALUE dispid, VALUE args, VALUE types, USHORT dispkind)
SAFEARRAYBOUND rgsabound[1];
Check_Type(param, T_ARRAY);
rgsabound[0].lLbound = 0;
- rgsabound[0].cElements = RARRAY(param)->len;
+ rgsabound[0].cElements = RARRAY_LEN(param);
v = vt & ~(VT_ARRAY | VT_BYREF);
V_ARRAY(&realargs[i]) = SafeArrayCreate(v, 1, rgsabound);
V_VT(&realargs[i]) = VT_ARRAY | v;
@@ -4060,7 +4060,7 @@ foletypelib_initialize(VALUE self, VALUE args)
VALUE retval;
HRESULT hr = S_OK;
- len = RARRAY(args)->len;
+ len = RARRAY_LEN(args);
if (len < 1 || len > 3) {
rb_raise(rb_eArgError, "wrong number of arguments (%d for 1..3)", len);
}
@@ -6233,7 +6233,7 @@ ole_search_event_at(VALUE ary, VALUE ev)
long i, len;
long ret = -1;
def_event = Qnil;
- len = RARRAY(ary)->len;
+ len = RARRAY_LEN(ary);
for(i = 0; i < len; i++) {
event = rb_ary_entry(ary, i);
event_name = rb_ary_entry(event, 1);
@@ -6260,7 +6260,7 @@ ole_search_event(VALUE ary, VALUE ev, BOOL *is_default)
int i, len;
*is_default = FALSE;
def_event = Qnil;
- len = RARRAY(ary)->len;
+ len = RARRAY_LEN(ary);
for(i = 0; i < len; i++) {
event = rb_ary_entry(ary, i);
event_name = rb_ary_entry(event, 1);
@@ -6283,7 +6283,7 @@ ary2ptr_dispparams(VALUE ary, DISPPARAMS *pdispparams)
int i;
VALUE v;
VARIANT *pvar;
- for(i = 0; i < RARRAY(ary)->len && (unsigned int) i < pdispparams->cArgs; i++) {
+ for(i = 0; i < RARRAY_LEN(ary) && (unsigned int) i < pdispparams->cArgs; i++) {
v = rb_ary_entry(ary, i);
pvar = &pdispparams->rgvarg[pdispparams->cArgs-i-1];
ole_val2ptr_variant(v, pvar);
@@ -6825,7 +6825,7 @@ folevariant_initialize(VALUE self, VALUE args)
VARTYPE vt;
struct olevariantdata *pvar;
- len = RARRAY(args)->len;
+ len = RARRAY_LEN(args);
if (len < 1 || len > 3) {
rb_raise(rb_eArgError, "wrong number of arguments (%d for 1..3)", len);
}