1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

ext: use RARRAY_CONST_PTR

* ext/bigdecimal/bigdecimal.c: use RARRAY_CONST_PTR just fore
  reference instead of RARRAY_PTR, to keep the array WB-protected.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52448 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2015-11-04 07:27:10 +00:00
parent 52912db4a8
commit 3553a86eb5
20 changed files with 123 additions and 106 deletions

View file

@ -699,7 +699,7 @@ BigDecimal_to_i(VALUE self)
} }
else { else {
VALUE a = BigDecimal_split(self); VALUE a = BigDecimal_split(self);
VALUE digits = RARRAY_PTR(a)[1]; VALUE digits = RARRAY_CONST_PTR(a)[1];
VALUE numerator = rb_funcall(digits, rb_intern("to_i"), 0); VALUE numerator = rb_funcall(digits, rb_intern("to_i"), 0);
VALUE ret; VALUE ret;
ssize_t dpower = e - (ssize_t)RSTRING_LEN(digits); ssize_t dpower = e - (ssize_t)RSTRING_LEN(digits);
@ -788,7 +788,7 @@ BigDecimal_to_r(VALUE self)
sign = VpGetSign(p); sign = VpGetSign(p);
power = VpExponent10(p); power = VpExponent10(p);
a = BigDecimal_split(self); a = BigDecimal_split(self);
digits = RARRAY_PTR(a)[1]; digits = RARRAY_CONST_PTR(a)[1];
denomi_power = power - RSTRING_LEN(digits); denomi_power = power - RSTRING_LEN(digits);
numerator = rb_funcall(digits, rb_intern("to_i"), 0); numerator = rb_funcall(digits, rb_intern("to_i"), 0);

View file

@ -3826,14 +3826,14 @@ rt_complete_frags(VALUE klass, VALUE hash)
for (i = 0; i < RARRAY_LEN(tab); i++) { for (i = 0; i < RARRAY_LEN(tab); i++) {
VALUE x, a; VALUE x, a;
x = RARRAY_PTR(tab)[i]; x = RARRAY_CONST_PTR(tab)[i];
a = RARRAY_PTR(x)[1]; a = RARRAY_CONST_PTR(x)[1];
{ {
long j, n = 0; long j, n = 0;
for (j = 0; j < RARRAY_LEN(a); j++) for (j = 0; j < RARRAY_LEN(a); j++)
if (!NIL_P(ref_hash0(RARRAY_PTR(a)[j]))) if (!NIL_P(ref_hash0(RARRAY_CONST_PTR(a)[j])))
n++; n++;
if (n > eno) { if (n > eno) {
eno = n; eno = n;
@ -3845,8 +3845,8 @@ rt_complete_frags(VALUE klass, VALUE hash)
g = 0; g = 0;
else { else {
g = 1; g = 1;
k = RARRAY_PTR(RARRAY_PTR(tab)[idx])[0]; k = RARRAY_CONST_PTR(RARRAY_CONST_PTR(tab)[idx])[0];
a = RARRAY_PTR(RARRAY_PTR(tab)[idx])[1]; a = RARRAY_CONST_PTR(RARRAY_CONST_PTR(tab)[idx])[1];
e = eno; e = eno;
} }
} }
@ -3867,7 +3867,7 @@ rt_complete_frags(VALUE klass, VALUE hash)
long i; long i;
for (i = 0; i < RARRAY_LEN(a); i++) { for (i = 0; i < RARRAY_LEN(a); i++) {
VALUE e = RARRAY_PTR(a)[i]; VALUE e = RARRAY_CONST_PTR(a)[i];
if (!NIL_P(ref_hash0(e))) if (!NIL_P(ref_hash0(e)))
break; break;
@ -3884,7 +3884,7 @@ rt_complete_frags(VALUE klass, VALUE hash)
long i; long i;
for (i = 0; i < RARRAY_LEN(a); i++) { for (i = 0; i < RARRAY_LEN(a); i++) {
VALUE e = RARRAY_PTR(a)[i]; VALUE e = RARRAY_CONST_PTR(a)[i];
if (!NIL_P(ref_hash0(e))) if (!NIL_P(ref_hash0(e)))
break; break;
@ -3908,7 +3908,7 @@ rt_complete_frags(VALUE klass, VALUE hash)
long i; long i;
for (i = 0; i < RARRAY_LEN(a); i++) { for (i = 0; i < RARRAY_LEN(a); i++) {
VALUE e = RARRAY_PTR(a)[i]; VALUE e = RARRAY_CONST_PTR(a)[i];
if (!NIL_P(ref_hash0(e))) if (!NIL_P(ref_hash0(e)))
break; break;
@ -3925,7 +3925,7 @@ rt_complete_frags(VALUE klass, VALUE hash)
long i; long i;
for (i = 0; i < RARRAY_LEN(a); i++) { for (i = 0; i < RARRAY_LEN(a); i++) {
VALUE e = RARRAY_PTR(a)[i]; VALUE e = RARRAY_CONST_PTR(a)[i];
if (!NIL_P(ref_hash0(e))) if (!NIL_P(ref_hash0(e)))
break; break;
@ -7085,16 +7085,16 @@ d_lite_marshal_load(VALUE self, VALUE a)
if (RARRAY_LEN(a) == 2) { if (RARRAY_LEN(a) == 2) {
ajd = f_sub(RARRAY_PTR(a)[0], half_days_in_day); ajd = f_sub(RARRAY_CONST_PTR(a)[0], half_days_in_day);
of = INT2FIX(0); of = INT2FIX(0);
sg = RARRAY_PTR(a)[1]; sg = RARRAY_CONST_PTR(a)[1];
if (!k_numeric_p(sg)) if (!k_numeric_p(sg))
sg = DBL2NUM(RTEST(sg) ? GREGORIAN : JULIAN); sg = DBL2NUM(RTEST(sg) ? GREGORIAN : JULIAN);
} }
else { else {
ajd = RARRAY_PTR(a)[0]; ajd = RARRAY_CONST_PTR(a)[0];
of = RARRAY_PTR(a)[1]; of = RARRAY_CONST_PTR(a)[1];
sg = RARRAY_PTR(a)[2]; sg = RARRAY_CONST_PTR(a)[2];
} }
old_to_new(ajd, of, sg, old_to_new(ajd, of, sg,
@ -7119,12 +7119,12 @@ d_lite_marshal_load(VALUE self, VALUE a)
int jd, df, of; int jd, df, of;
double sg; double sg;
nth = RARRAY_PTR(a)[0]; nth = RARRAY_CONST_PTR(a)[0];
jd = NUM2INT(RARRAY_PTR(a)[1]); jd = NUM2INT(RARRAY_CONST_PTR(a)[1]);
df = NUM2INT(RARRAY_PTR(a)[2]); df = NUM2INT(RARRAY_CONST_PTR(a)[2]);
sf = RARRAY_PTR(a)[3]; sf = RARRAY_CONST_PTR(a)[3];
of = NUM2INT(RARRAY_PTR(a)[4]); of = NUM2INT(RARRAY_CONST_PTR(a)[4]);
sg = NUM2DBL(RARRAY_PTR(a)[5]); sg = NUM2DBL(RARRAY_CONST_PTR(a)[5]);
if (!df && f_zero_p(sf) && !of) { if (!df && f_zero_p(sf) && !of) {
set_to_simple(self, &dat->s, nth, jd, sg, 0, 0, 0, HAVE_JD); set_to_simple(self, &dat->s, nth, jd, sg, 0, 0, 0, HAVE_JD);
} else { } else {

View file

@ -528,7 +528,7 @@ fdbm_delete_if(VALUE obj)
} }
for (i = 0; i < RARRAY_LEN(ary); i++) { for (i = 0; i < RARRAY_LEN(ary); i++) {
keystr = RARRAY_PTR(ary)[i]; keystr = RARRAY_CONST_PTR(ary)[i];
key.dptr = RSTRING_PTR(keystr); key.dptr = RSTRING_PTR(keystr);
key.dsize = (DSIZE_TYPE)RSTRING_LEN(keystr); key.dsize = (DSIZE_TYPE)RSTRING_LEN(keystr);
if (dbm_delete(dbm, key)) { if (dbm_delete(dbm, key)) {
@ -599,11 +599,13 @@ static VALUE fdbm_store(VALUE,VALUE,VALUE);
static VALUE static VALUE
update_i(RB_BLOCK_CALL_FUNC_ARGLIST(pair, dbm)) update_i(RB_BLOCK_CALL_FUNC_ARGLIST(pair, dbm))
{ {
const VALUE *ptr;
Check_Type(pair, T_ARRAY); Check_Type(pair, T_ARRAY);
if (RARRAY_LEN(pair) < 2) { if (RARRAY_LEN(pair) < 2) {
rb_raise(rb_eArgError, "pair must be [key, value]"); rb_raise(rb_eArgError, "pair must be [key, value]");
} }
fdbm_store(dbm, RARRAY_PTR(pair)[0], RARRAY_PTR(pair)[1]); ptr = RARRAY_CONST_PTR(pair);
fdbm_store(dbm, ptr[0], ptr[1]);
return Qnil; return Qnil;
} }

View file

@ -70,7 +70,7 @@ callback(ffi_cif *cif, void *resp, void **args, void *ctx)
cPointer = rb_const_get(mFiddle, rb_intern("Pointer")); cPointer = rb_const_get(mFiddle, rb_intern("Pointer"));
for (i = 0; i < argc; i++) { for (i = 0; i < argc; i++) {
type = NUM2INT(RARRAY_PTR(rbargs)[i]); type = NUM2INT(RARRAY_CONST_PTR(rbargs)[i]);
switch (type) { switch (type) {
case TYPE_VOID: case TYPE_VOID:
argc = 0; argc = 0;
@ -123,7 +123,7 @@ callback(ffi_cif *cif, void *resp, void **args, void *ctx)
} }
} }
ret = rb_funcall2(self, rb_intern("call"), argc, RARRAY_PTR(params)); ret = rb_funcall2(self, rb_intern("call"), argc, RARRAY_CONST_PTR(params));
RB_GC_GUARD(params); RB_GC_GUARD(params);
type = NUM2INT(ctype); type = NUM2INT(ctype);
@ -210,7 +210,7 @@ initialize(int rbargc, VALUE argv[], VALUE self)
cl->argv = (ffi_type **)xcalloc(argc + 1, sizeof(ffi_type *)); cl->argv = (ffi_type **)xcalloc(argc + 1, sizeof(ffi_type *));
for (i = 0; i < argc; i++) { for (i = 0; i < argc; i++) {
int type = NUM2INT(RARRAY_PTR(args)[i]); int type = NUM2INT(RARRAY_CONST_PTR(args)[i]);
cl->argv[i] = INT2FFI_TYPE(type); cl->argv[i] = INT2FFI_TYPE(type);
} }
cl->argv[argc] = NULL; cl->argv[argc] = NULL;

View file

@ -110,7 +110,7 @@ initialize(int argc, VALUE argv[], VALUE self)
arg_types = xcalloc(RARRAY_LEN(args) + 1, sizeof(ffi_type *)); arg_types = xcalloc(RARRAY_LEN(args) + 1, sizeof(ffi_type *));
for (i = 0; i < RARRAY_LEN(args); i++) { for (i = 0; i < RARRAY_LEN(args); i++) {
int type = NUM2INT(RARRAY_PTR(args)[i]); int type = NUM2INT(RARRAY_CONST_PTR(args)[i]);
arg_types[i] = INT2FFI_TYPE(type); arg_types[i] = INT2FFI_TYPE(type);
} }
arg_types[RARRAY_LEN(args)] = NULL; arg_types[RARRAY_LEN(args)] = NULL;
@ -164,7 +164,7 @@ function_call(int argc, VALUE argv[], VALUE self)
values = (void **)((char *)generic_args + (size_t)argc * sizeof(fiddle_generic)); values = (void **)((char *)generic_args + (size_t)argc * sizeof(fiddle_generic));
for (i = 0; i < argc; i++) { for (i = 0; i < argc; i++) {
VALUE type = RARRAY_PTR(types)[i]; VALUE type = RARRAY_CONST_PTR(types)[i];
VALUE src = argv[i]; VALUE src = argv[i];
if(NUM2INT(type) == TYPE_VOIDP) { if(NUM2INT(type) == TYPE_VOIDP) {

View file

@ -634,7 +634,7 @@ fgdbm_delete_if(VALUE obj)
} }
for (i = 0; i < RARRAY_LEN(ary); i++) for (i = 0; i < RARRAY_LEN(ary); i++)
rb_gdbm_delete(obj, RARRAY_PTR(ary)[i]); rb_gdbm_delete(obj, RARRAY_CONST_PTR(ary)[i]);
if (status) rb_jump_tag(status); if (status) rb_jump_tag(status);
if (n > 0) dbmp->di_size = n - (int)RARRAY_LEN(ary); if (n > 0) dbmp->di_size = n - (int)RARRAY_LEN(ary);
rb_ary_clear(ary); rb_ary_clear(ary);
@ -747,11 +747,13 @@ fgdbm_store(VALUE obj, VALUE keystr, VALUE valstr)
static VALUE static VALUE
update_i(RB_BLOCK_CALL_FUNC_ARGLIST(pair, dbm)) update_i(RB_BLOCK_CALL_FUNC_ARGLIST(pair, dbm))
{ {
const VALUE *ptr;
Check_Type(pair, T_ARRAY); Check_Type(pair, T_ARRAY);
if (RARRAY_LEN(pair) < 2) { if (RARRAY_LEN(pair) < 2) {
rb_raise(rb_eArgError, "pair must be [key, value]"); rb_raise(rb_eArgError, "pair must be [key, value]");
} }
fgdbm_store(dbm, RARRAY_PTR(pair)[0], RARRAY_PTR(pair)[1]); ptr = RARRAY_CONST_PTR(pair);
fgdbm_store(dbm, ptr[0], ptr[1]);
return Qnil; return Qnil;
} }

View file

@ -521,12 +521,14 @@ console_set_winsize(VALUE io, VALUE size)
int newrow, newcol; int newrow, newcol;
#endif #endif
VALUE row, col, xpixel, ypixel; VALUE row, col, xpixel, ypixel;
const VALUE *sz;
int fd; int fd;
GetOpenFile(io, fptr); GetOpenFile(io, fptr);
size = rb_Array(size); size = rb_Array(size);
rb_scan_args((int)RARRAY_LEN(size), RARRAY_PTR(size), "22", rb_check_arity(RARRAY_LENINT(size), 2, 4);
&row, &col, &xpixel, &ypixel); sz = RARRAY_CONST_PTR(size);
row = sz[0], col = sz[1], xpixel = sz[2], ypixel = sz[3];
fd = GetWriteFD(fptr); fd = GetWriteFD(fptr);
#if defined TIOCSWINSZ #if defined TIOCSWINSZ
ws.ws_row = ws.ws_col = ws.ws_xpixel = ws.ws_ypixel = 0; ws.ws_row = ws.ws_col = ws.ws_xpixel = ws.ws_ypixel = 0;

View file

@ -682,7 +682,7 @@ ossl_ocspbres_add_status(VALUE self, VALUE cid, VALUE status,
/* All ary's members should be X509Extension */ /* All ary's members should be X509Extension */
Check_Type(ext, T_ARRAY); Check_Type(ext, T_ARRAY);
for (i = 0; i < RARRAY_LEN(ext); i++) for (i = 0; i < RARRAY_LEN(ext); i++)
OSSL_Check_Kind(RARRAY_PTR(ext)[i], cX509Ext); OSSL_Check_Kind(RARRAY_CONST_PTR(ext)[i], cX509Ext);
} }
error = 0; error = 0;
@ -711,7 +711,7 @@ ossl_ocspbres_add_status(VALUE self, VALUE cid, VALUE status,
sk_X509_EXTENSION_pop_free(single->singleExtensions, X509_EXTENSION_free); sk_X509_EXTENSION_pop_free(single->singleExtensions, X509_EXTENSION_free);
single->singleExtensions = NULL; single->singleExtensions = NULL;
for(i = 0; i < RARRAY_LEN(ext); i++){ for(i = 0; i < RARRAY_LEN(ext); i++){
x509ext = DupX509ExtPtr(RARRAY_PTR(ext)[i]); x509ext = DupX509ExtPtr(RARRAY_CONST_PTR(ext)[i]);
if(!OCSP_SINGLERESP_add_ext(single, x509ext, -1)){ if(!OCSP_SINGLERESP_add_ext(single, x509ext, -1)){
X509_EXTENSION_free(x509ext); X509_EXTENSION_free(x509ext);
error = 1; error = 1;

View file

@ -759,7 +759,7 @@ ossl_sslctx_setup(VALUE self)
if(!NIL_P(val)){ if(!NIL_P(val)){
if (RB_TYPE_P(val, T_ARRAY)) { if (RB_TYPE_P(val, T_ARRAY)) {
for(i = 0; i < RARRAY_LEN(val); i++){ for(i = 0; i < RARRAY_LEN(val); i++){
client_ca = GetX509CertPtr(RARRAY_PTR(val)[i]); client_ca = GetX509CertPtr(RARRAY_CONST_PTR(val)[i]);
if (!SSL_CTX_add_client_CA(ctx, client_ca)){ if (!SSL_CTX_add_client_CA(ctx, client_ca)){
/* Copies X509_NAME => FREE it. */ /* Copies X509_NAME => FREE it. */
ossl_raise(eSSLError, "SSL_CTX_add_client_CA"); ossl_raise(eSSLError, "SSL_CTX_add_client_CA");

View file

@ -668,13 +668,13 @@ ossl_x509_set_extensions(VALUE self, VALUE ary)
Check_Type(ary, T_ARRAY); Check_Type(ary, T_ARRAY);
/* All ary's members should be X509Extension */ /* All ary's members should be X509Extension */
for (i=0; i<RARRAY_LEN(ary); i++) { for (i=0; i<RARRAY_LEN(ary); i++) {
OSSL_Check_Kind(RARRAY_PTR(ary)[i], cX509Ext); OSSL_Check_Kind(RARRAY_CONST_PTR(ary)[i], cX509Ext);
} }
GetX509(self, x509); GetX509(self, x509);
sk_X509_EXTENSION_pop_free(x509->cert_info->extensions, X509_EXTENSION_free); sk_X509_EXTENSION_pop_free(x509->cert_info->extensions, X509_EXTENSION_free);
x509->cert_info->extensions = NULL; x509->cert_info->extensions = NULL;
for (i=0; i<RARRAY_LEN(ary); i++) { for (i=0; i<RARRAY_LEN(ary); i++) {
ext = DupX509ExtPtr(RARRAY_PTR(ary)[i]); ext = DupX509ExtPtr(RARRAY_CONST_PTR(ary)[i]);
if (!X509_add_ext(x509, ext, -1)) { /* DUPs ext - FREE it */ if (!X509_add_ext(x509, ext, -1)) { /* DUPs ext - FREE it */
X509_EXTENSION_free(ext); X509_EXTENSION_free(ext);

View file

@ -307,13 +307,13 @@ ossl_x509crl_set_revoked(VALUE self, VALUE ary)
Check_Type(ary, T_ARRAY); Check_Type(ary, T_ARRAY);
/* All ary members should be X509 Revoked */ /* All ary members should be X509 Revoked */
for (i=0; i<RARRAY_LEN(ary); i++) { for (i=0; i<RARRAY_LEN(ary); i++) {
OSSL_Check_Kind(RARRAY_PTR(ary)[i], cX509Rev); OSSL_Check_Kind(RARRAY_CONST_PTR(ary)[i], cX509Rev);
} }
GetX509CRL(self, crl); GetX509CRL(self, crl);
sk_X509_REVOKED_pop_free(crl->crl->revoked, X509_REVOKED_free); sk_X509_REVOKED_pop_free(crl->crl->revoked, X509_REVOKED_free);
crl->crl->revoked = NULL; crl->crl->revoked = NULL;
for (i=0; i<RARRAY_LEN(ary); i++) { for (i=0; i<RARRAY_LEN(ary); i++) {
rev = DupX509RevokedPtr(RARRAY_PTR(ary)[i]); rev = DupX509RevokedPtr(RARRAY_CONST_PTR(ary)[i]);
if (!X509_CRL_add0_revoked(crl, rev)) { /* NO DUP - don't free! */ if (!X509_CRL_add0_revoked(crl, rev)) { /* NO DUP - don't free! */
ossl_raise(eX509CRLError, NULL); ossl_raise(eX509CRLError, NULL);
} }
@ -481,13 +481,13 @@ ossl_x509crl_set_extensions(VALUE self, VALUE ary)
Check_Type(ary, T_ARRAY); Check_Type(ary, T_ARRAY);
/* All ary members should be X509 Extensions */ /* All ary members should be X509 Extensions */
for (i=0; i<RARRAY_LEN(ary); i++) { for (i=0; i<RARRAY_LEN(ary); i++) {
OSSL_Check_Kind(RARRAY_PTR(ary)[i], cX509Ext); OSSL_Check_Kind(RARRAY_CONST_PTR(ary)[i], cX509Ext);
} }
GetX509CRL(self, crl); GetX509CRL(self, crl);
sk_X509_EXTENSION_pop_free(crl->crl->extensions, X509_EXTENSION_free); sk_X509_EXTENSION_pop_free(crl->crl->extensions, X509_EXTENSION_free);
crl->crl->extensions = NULL; crl->crl->extensions = NULL;
for (i=0; i<RARRAY_LEN(ary); i++) { for (i=0; i<RARRAY_LEN(ary); i++) {
ext = DupX509ExtPtr(RARRAY_PTR(ary)[i]); ext = DupX509ExtPtr(RARRAY_CONST_PTR(ary)[i]);
if(!X509_CRL_add_ext(crl, ext, -1)) { /* DUPs ext - FREE it */ if(!X509_CRL_add_ext(crl, ext, -1)) { /* DUPs ext - FREE it */
X509_EXTENSION_free(ext); X509_EXTENSION_free(ext);
ossl_raise(eX509CRLError, NULL); ossl_raise(eX509CRLError, NULL);

View file

@ -423,13 +423,13 @@ ossl_x509req_set_attributes(VALUE self, VALUE ary)
Check_Type(ary, T_ARRAY); Check_Type(ary, T_ARRAY);
for (i=0;i<RARRAY_LEN(ary); i++) { for (i=0;i<RARRAY_LEN(ary); i++) {
OSSL_Check_Kind(RARRAY_PTR(ary)[i], cX509Attr); OSSL_Check_Kind(RARRAY_CONST_PTR(ary)[i], cX509Attr);
} }
GetX509Req(self, req); GetX509Req(self, req);
sk_X509_ATTRIBUTE_pop_free(req->req_info->attributes, X509_ATTRIBUTE_free); sk_X509_ATTRIBUTE_pop_free(req->req_info->attributes, X509_ATTRIBUTE_free);
req->req_info->attributes = NULL; req->req_info->attributes = NULL;
for (i=0;i<RARRAY_LEN(ary); i++) { for (i=0;i<RARRAY_LEN(ary); i++) {
item = RARRAY_PTR(ary)[i]; item = RARRAY_CONST_PTR(ary)[i];
attr = DupX509AttrPtr(item); attr = DupX509AttrPtr(item);
if (!X509_REQ_add1_attr(req, attr)) { if (!X509_REQ_add1_attr(req, attr)) {
ossl_raise(eX509ReqError, NULL); ossl_raise(eX509ReqError, NULL);

View file

@ -193,13 +193,13 @@ ossl_x509revoked_set_extensions(VALUE self, VALUE ary)
Check_Type(ary, T_ARRAY); Check_Type(ary, T_ARRAY);
for (i=0; i<RARRAY_LEN(ary); i++) { for (i=0; i<RARRAY_LEN(ary); i++) {
OSSL_Check_Kind(RARRAY_PTR(ary)[i], cX509Ext); OSSL_Check_Kind(RARRAY_CONST_PTR(ary)[i], cX509Ext);
} }
GetX509Rev(self, rev); GetX509Rev(self, rev);
sk_X509_EXTENSION_pop_free(rev->extensions, X509_EXTENSION_free); sk_X509_EXTENSION_pop_free(rev->extensions, X509_EXTENSION_free);
rev->extensions = NULL; rev->extensions = NULL;
for (i=0; i<RARRAY_LEN(ary); i++) { for (i=0; i<RARRAY_LEN(ary); i++) {
item = RARRAY_PTR(ary)[i]; item = RARRAY_CONST_PTR(ary)[i];
ext = DupX509ExtPtr(item); ext = DupX509ExtPtr(item);
if(!X509_REVOKED_add_ext(rev, ext, -1)) { if(!X509_REVOKED_add_ext(rev, ext, -1)) {
ossl_raise(eX509RevError, NULL); ossl_raise(eX509RevError, NULL);

View file

@ -170,7 +170,7 @@ static VALUE start_document(VALUE self, VALUE version, VALUE tags, VALUE imp)
tail = head; tail = head;
for(i = 0; i < RARRAY_LEN(tags); i++) { for(i = 0; i < RARRAY_LEN(tags); i++) {
VALUE tuple = RARRAY_PTR(tags)[i]; VALUE tuple = RARRAY_CONST_PTR(tags)[i];
VALUE name; VALUE name;
VALUE value; VALUE value;
@ -180,8 +180,8 @@ static VALUE start_document(VALUE self, VALUE version, VALUE tags, VALUE imp)
xfree(head); xfree(head);
rb_raise(rb_eRuntimeError, "tag tuple must be of length 2"); rb_raise(rb_eRuntimeError, "tag tuple must be of length 2");
} }
name = RARRAY_PTR(tuple)[0]; name = RARRAY_CONST_PTR(tuple)[0];
value = RARRAY_PTR(tuple)[1]; value = RARRAY_CONST_PTR(tuple)[1];
#ifdef HAVE_RUBY_ENCODING_H #ifdef HAVE_RUBY_ENCODING_H
name = rb_str_export_to_enc(name, encoding); name = rb_str_export_to_enc(name, encoding);
value = rb_str_export_to_enc(value, encoding); value = rb_str_export_to_enc(value, encoding);

View file

@ -963,7 +963,7 @@ readline_attempted_completion_function(const char *text, int start, int end)
enc = rb_locale_encoding(); enc = rb_locale_encoding();
encobj = rb_enc_from_encoding(enc); encobj = rb_enc_from_encoding(enc);
for (i = 0; i < matches; i++) { for (i = 0; i < matches; i++) {
temp = rb_obj_as_string(RARRAY_PTR(ary)[i]); temp = rb_obj_as_string(RARRAY_CONST_PTR(ary)[i]);
StringValueCStr(temp); /* must be NUL-terminated */ StringValueCStr(temp); /* must be NUL-terminated */
rb_enc_check(encobj, temp); rb_enc_check(encobj, temp);
result[i + 1] = (char*)malloc(RSTRING_LEN(temp) + 1); result[i + 1] = (char*)malloc(RSTRING_LEN(temp) + 1);

View file

@ -530,7 +530,7 @@ fsdbm_delete_if(VALUE obj)
} }
for (i = 0; i < RARRAY_LEN(ary); i++) { for (i = 0; i < RARRAY_LEN(ary); i++) {
keystr = RARRAY_PTR(ary)[i]; keystr = RARRAY_CONST_PTR(ary)[i];
ExportStringValue(keystr); ExportStringValue(keystr);
key.dptr = RSTRING_PTR(keystr); key.dptr = RSTRING_PTR(keystr);
key.dsize = RSTRING_LENINT(keystr); key.dsize = RSTRING_LENINT(keystr);
@ -655,11 +655,13 @@ fsdbm_store(VALUE obj, VALUE keystr, VALUE valstr)
static VALUE static VALUE
update_i(RB_BLOCK_CALL_FUNC_ARGLIST(pair, dbm)) update_i(RB_BLOCK_CALL_FUNC_ARGLIST(pair, dbm))
{ {
const VALUE *ptr;
Check_Type(pair, T_ARRAY); Check_Type(pair, T_ARRAY);
if (RARRAY_LEN(pair) < 2) { if (RARRAY_LEN(pair) < 2) {
rb_raise(rb_eArgError, "pair must be [key, value]"); rb_raise(rb_eArgError, "pair must be [key, value]");
} }
fsdbm_store(dbm, RARRAY_PTR(pair)[0], RARRAY_PTR(pair)[1]); ptr = RARRAY_CONST_PTR(pair);
fsdbm_store(dbm, ptr[0], ptr[1]);
return Qnil; return Qnil;
} }

View file

@ -207,7 +207,7 @@ ancillary_s_unix_rights(int argc, VALUE *argv, VALUE klass)
str = rb_str_buf_new(sizeof(int) * argc); str = rb_str_buf_new(sizeof(int) * argc);
for (i = 0 ; i < argc; i++) { for (i = 0 ; i < argc; i++) {
VALUE obj = RARRAY_PTR(ary)[i]; VALUE obj = RARRAY_CONST_PTR(ary)[i];
rb_io_t *fptr; rb_io_t *fptr;
int fd; int fd;
GetOpenFile(obj, fptr); GetOpenFile(obj, fptr);

View file

@ -1406,16 +1406,16 @@ sock_s_getnameinfo(int argc, VALUE *argv)
sa = tmp; sa = tmp;
MEMZERO(&hints, struct addrinfo, 1); MEMZERO(&hints, struct addrinfo, 1);
if (RARRAY_LEN(sa) == 3) { if (RARRAY_LEN(sa) == 3) {
af = RARRAY_PTR(sa)[0]; af = RARRAY_CONST_PTR(sa)[0];
port = RARRAY_PTR(sa)[1]; port = RARRAY_CONST_PTR(sa)[1];
host = RARRAY_PTR(sa)[2]; host = RARRAY_CONST_PTR(sa)[2];
} }
else if (RARRAY_LEN(sa) >= 4) { else if (RARRAY_LEN(sa) >= 4) {
af = RARRAY_PTR(sa)[0]; af = RARRAY_CONST_PTR(sa)[0];
port = RARRAY_PTR(sa)[1]; port = RARRAY_CONST_PTR(sa)[1];
host = RARRAY_PTR(sa)[3]; host = RARRAY_CONST_PTR(sa)[3];
if (NIL_P(host)) { if (NIL_P(host)) {
host = RARRAY_PTR(sa)[2]; host = RARRAY_CONST_PTR(sa)[2];
} }
else { else {
/* /*

View file

@ -42,6 +42,9 @@ int rb_thread_check_trap_pending(void);
#define RARRAY_PTR(s) (RARRAY(s)->ptr) #define RARRAY_PTR(s) (RARRAY(s)->ptr)
#define RARRAY_LEN(s) (RARRAY(s)->len) #define RARRAY_LEN(s) (RARRAY(s)->len)
#endif #endif
#if !defined(RARRAY_CONST_PTR)
#define RARRAY_CONST_PTR(s) (const VALUE *)RARRAY_PTR(s)
#endif
#ifdef OBJ_UNTRUST #ifdef OBJ_UNTRUST
#define RbTk_OBJ_UNTRUST(x) do {OBJ_TAINT(x); OBJ_UNTRUST(x);} while (0) #define RbTk_OBJ_UNTRUST(x) do {OBJ_TAINT(x); OBJ_UNTRUST(x);} while (0)
@ -1889,15 +1892,15 @@ set_max_block_time(self, time)
case T_BIGNUM: case T_BIGNUM:
/* time is micro-second value */ /* time is micro-second value */
divmod = rb_funcall(time, rb_intern("divmod"), 1, LONG2NUM(1000000)); divmod = rb_funcall(time, rb_intern("divmod"), 1, LONG2NUM(1000000));
tcl_time.sec = NUM2LONG(RARRAY_PTR(divmod)[0]); tcl_time.sec = NUM2LONG(RARRAY_CONST_PTR(divmod)[0]);
tcl_time.usec = NUM2LONG(RARRAY_PTR(divmod)[1]); tcl_time.usec = NUM2LONG(RARRAY_CONST_PTR(divmod)[1]);
break; break;
case T_FLOAT: case T_FLOAT:
/* time is second value */ /* time is second value */
divmod = rb_funcall(time, rb_intern("divmod"), 1, INT2FIX(1)); divmod = rb_funcall(time, rb_intern("divmod"), 1, INT2FIX(1));
tcl_time.sec = NUM2LONG(RARRAY_PTR(divmod)[0]); tcl_time.sec = NUM2LONG(RARRAY_CONST_PTR(divmod)[0]);
tcl_time.usec = (long)(NUM2DBL(RARRAY_PTR(divmod)[1]) * 1000000); tcl_time.usec = (long)(NUM2DBL(RARRAY_CONST_PTR(divmod)[1]) * 1000000);
default: default:
{ {
@ -7210,7 +7213,7 @@ tk_funcall(func, argc, argv, obj)
DUMP2("back from handler (current thread:%"PRIxVALUE")", current); DUMP2("back from handler (current thread:%"PRIxVALUE")", current);
/* get result & free allocated memory */ /* get result & free allocated memory */
ret = RARRAY_PTR(result)[0]; ret = RARRAY_CONST_PTR(result)[0];
#if 0 /* use Tcl_EventuallyFree */ #if 0 /* use Tcl_EventuallyFree */
Tcl_EventuallyFree((ClientData)alloc_done, TCL_DYNAMIC); /* XXXXXXXX */ Tcl_EventuallyFree((ClientData)alloc_done, TCL_DYNAMIC); /* XXXXXXXX */
#else #else
@ -7694,7 +7697,7 @@ ip_eval(self, str)
DUMP2("back from handler (current thread:%"PRIxVALUE")", current); DUMP2("back from handler (current thread:%"PRIxVALUE")", current);
/* get result & free allocated memory */ /* get result & free allocated memory */
ret = RARRAY_PTR(result)[0]; ret = RARRAY_CONST_PTR(result)[0];
#if 0 /* use Tcl_EventuallyFree */ #if 0 /* use Tcl_EventuallyFree */
Tcl_EventuallyFree((ClientData)alloc_done, TCL_DYNAMIC); /* XXXXXXXX */ Tcl_EventuallyFree((ClientData)alloc_done, TCL_DYNAMIC); /* XXXXXXXX */
@ -9193,7 +9196,7 @@ ip_invoke_with_position(argc, argv, obj, position)
DUMP2("back from handler (current thread:%"PRIxVALUE")", current); DUMP2("back from handler (current thread:%"PRIxVALUE")", current);
/* get result & free allocated memory */ /* get result & free allocated memory */
ret = RARRAY_PTR(result)[0]; ret = RARRAY_CONST_PTR(result)[0];
#if 0 /* use Tcl_EventuallyFree */ #if 0 /* use Tcl_EventuallyFree */
Tcl_EventuallyFree((ClientData)alloc_done, TCL_DYNAMIC); /* XXXXXXXX */ Tcl_EventuallyFree((ClientData)alloc_done, TCL_DYNAMIC); /* XXXXXXXX */
#else #else

View file

@ -37,6 +37,9 @@ static int rb_thread_critical; /* dummy */
#define RARRAY_PTR(s) (RARRAY(s)->ptr) #define RARRAY_PTR(s) (RARRAY(s)->ptr)
#define RARRAY_LEN(s) (RARRAY(s)->len) #define RARRAY_LEN(s) (RARRAY(s)->len)
#endif #endif
#if !defined(RARRAY_CONST_PTR)
#define RARRAY_CONST_PTR(s) (const VALUE *)RARRAY_PTR(s)
#endif
#if defined(HAVE_STRNDUP) && !defined(_GNU_SOURCE) #if defined(HAVE_STRNDUP) && !defined(_GNU_SOURCE)
extern char *strndup(const char* _ptr, size_t _len); extern char *strndup(const char* _ptr, size_t _len);
@ -334,8 +337,8 @@ ary2list(ary, enc_flag, self)
/* size = RARRAY_LEN(ary); */ /* size = RARRAY_LEN(ary); */
size = 0; size = 0;
for(idx = 0; idx < RARRAY_LEN(ary); idx++) { for(idx = 0; idx < RARRAY_LEN(ary); idx++) {
if (RB_TYPE_P(RARRAY_PTR(ary)[idx], T_HASH)) { if (RB_TYPE_P(RARRAY_CONST_PTR(ary)[idx], T_HASH)) {
size += 2 * RHASH_SIZE(RARRAY_PTR(ary)[idx]); size += 2 * RHASH_SIZE(RARRAY_CONST_PTR(ary)[idx]);
} else { } else {
size++; size++;
} }
@ -343,7 +346,7 @@ ary2list(ary, enc_flag, self)
dst = rb_ary_new2(size); dst = rb_ary_new2(size);
for(idx = 0; idx < RARRAY_LEN(ary); idx++) { for(idx = 0; idx < RARRAY_LEN(ary); idx++) {
val = RARRAY_PTR(ary)[idx]; val = RARRAY_CONST_PTR(ary)[idx];
str_val = Qnil; str_val = Qnil;
switch(TYPE(val)) { switch(TYPE(val)) {
case T_ARRAY: case T_ARRAY:
@ -374,7 +377,7 @@ ary2list(ary, enc_flag, self)
} }
size2 = RARRAY_LEN(val); size2 = RARRAY_LEN(val);
for(idx2 = 0; idx2 < size2; idx2++) { for(idx2 = 0; idx2 < size2; idx2++) {
val2 = RARRAY_PTR(val)[idx2]; val2 = RARRAY_CONST_PTR(val)[idx2];
switch(TYPE(val2)) { switch(TYPE(val2)) {
case T_ARRAY: case T_ARRAY:
str_val = ary2list(val2, enc_flag, self); str_val = ary2list(val2, enc_flag, self);
@ -435,7 +438,7 @@ ary2list(ary, enc_flag, self)
if (RTEST(dst_enc) && !NIL_P(sys_enc)) { if (RTEST(dst_enc) && !NIL_P(sys_enc)) {
for(idx = 0; idx < RARRAY_LEN(dst); idx++) { for(idx = 0; idx < RARRAY_LEN(dst); idx++) {
str_val = RARRAY_PTR(dst)[idx]; str_val = RARRAY_CONST_PTR(dst)[idx];
if (rb_obj_respond_to(self, ID_toUTF8, Qtrue)) { if (rb_obj_respond_to(self, ID_toUTF8, Qtrue)) {
str_val = rb_funcall(self, ID_toUTF8, 1, str_val); str_val = rb_funcall(self, ID_toUTF8, 1, str_val);
} else { } else {
@ -488,7 +491,7 @@ ary2list2(ary, enc_flag, self)
size = RARRAY_LEN(ary); size = RARRAY_LEN(ary);
dst = rb_ary_new2(size); dst = rb_ary_new2(size);
for(idx = 0; idx < RARRAY_LEN(ary); idx++) { for(idx = 0; idx < RARRAY_LEN(ary); idx++) {
val = RARRAY_PTR(ary)[idx]; val = RARRAY_CONST_PTR(ary)[idx];
str_val = Qnil; str_val = Qnil;
switch(TYPE(val)) { switch(TYPE(val)) {
case T_ARRAY: case T_ARRAY:
@ -529,7 +532,7 @@ ary2list2(ary, enc_flag, self)
if (RTEST(dst_enc) && !NIL_P(sys_enc)) { if (RTEST(dst_enc) && !NIL_P(sys_enc)) {
for(idx = 0; idx < RARRAY_LEN(dst); idx++) { for(idx = 0; idx < RARRAY_LEN(dst); idx++) {
str_val = RARRAY_PTR(dst)[idx]; str_val = RARRAY_CONST_PTR(dst)[idx];
if (rb_obj_respond_to(self, ID_toUTF8, Qtrue)) { if (rb_obj_respond_to(self, ID_toUTF8, Qtrue)) {
str_val = rb_funcall(self, ID_toUTF8, 1, str_val); str_val = rb_funcall(self, ID_toUTF8, 1, str_val);
} else { } else {
@ -571,27 +574,27 @@ assoc2kv(assoc, ary, self)
len = RARRAY_LEN(assoc); len = RARRAY_LEN(assoc);
for(i = 0; i < len; i++) { for(i = 0; i < len; i++) {
pair = RARRAY_PTR(assoc)[i]; pair = RARRAY_CONST_PTR(assoc)[i];
if (!RB_TYPE_P(pair, T_ARRAY)) { if (!RB_TYPE_P(pair, T_ARRAY)) {
rb_ary_push(dst, key2keyname(pair)); rb_ary_push(dst, key2keyname(pair));
continue; continue;
} }
switch(RARRAY_LEN(assoc)) { switch(RARRAY_LEN(assoc)) {
case 2: case 2:
rb_ary_push(dst, RARRAY_PTR(pair)[2]); rb_ary_push(dst, RARRAY_CONST_PTR(pair)[2]);
case 1: case 1:
rb_ary_push(dst, key2keyname(RARRAY_PTR(pair)[0])); rb_ary_push(dst, key2keyname(RARRAY_CONST_PTR(pair)[0]));
case 0: case 0:
continue; continue;
default: default:
rb_ary_push(dst, key2keyname(RARRAY_PTR(pair)[0])); rb_ary_push(dst, key2keyname(RARRAY_CONST_PTR(pair)[0]));
val = rb_ary_new2(RARRAY_LEN(pair) - 1); val = rb_ary_new2(RARRAY_LEN(pair) - 1);
for(j = 1; j < RARRAY_LEN(pair); j++) { for(j = 1; j < RARRAY_LEN(pair); j++) {
rb_ary_push(val, RARRAY_PTR(pair)[j]); rb_ary_push(val, RARRAY_CONST_PTR(pair)[j]);
} }
rb_ary_push(dst, val); rb_ary_push(dst, val);
@ -619,27 +622,27 @@ assoc2kv_enc(assoc, ary, self)
len = RARRAY_LEN(assoc); len = RARRAY_LEN(assoc);
for(i = 0; i < len; i++) { for(i = 0; i < len; i++) {
pair = RARRAY_PTR(assoc)[i]; pair = RARRAY_CONST_PTR(assoc)[i];
if (!RB_TYPE_P(pair, T_ARRAY)) { if (!RB_TYPE_P(pair, T_ARRAY)) {
rb_ary_push(dst, key2keyname(pair)); rb_ary_push(dst, key2keyname(pair));
continue; continue;
} }
switch(RARRAY_LEN(assoc)) { switch(RARRAY_LEN(assoc)) {
case 2: case 2:
rb_ary_push(dst, get_eval_string_core(RARRAY_PTR(pair)[2], Qtrue, self)); rb_ary_push(dst, get_eval_string_core(RARRAY_CONST_PTR(pair)[2], Qtrue, self));
case 1: case 1:
rb_ary_push(dst, key2keyname(RARRAY_PTR(pair)[0])); rb_ary_push(dst, key2keyname(RARRAY_CONST_PTR(pair)[0]));
case 0: case 0:
continue; continue;
default: default:
rb_ary_push(dst, key2keyname(RARRAY_PTR(pair)[0])); rb_ary_push(dst, key2keyname(RARRAY_CONST_PTR(pair)[0]));
val = rb_ary_new2(RARRAY_LEN(pair) - 1); val = rb_ary_new2(RARRAY_LEN(pair) - 1);
for(j = 1; j < RARRAY_LEN(pair); j++) { for(j = 1; j < RARRAY_LEN(pair); j++) {
rb_ary_push(val, RARRAY_PTR(pair)[j]); rb_ary_push(val, RARRAY_CONST_PTR(pair)[j]);
} }
rb_ary_push(dst, get_eval_string_core(val, Qtrue, self)); rb_ary_push(dst, get_eval_string_core(val, Qtrue, self));
@ -661,7 +664,7 @@ push_kv(key, val, args)
{ {
volatile VALUE ary; volatile VALUE ary;
ary = RARRAY_PTR(args)[0]; ary = RARRAY_CONST_PTR(args)[0];
#if 0 #if 0
rb_ary_push(ary, key2keyname(key)); rb_ary_push(ary, key2keyname(key));
@ -671,7 +674,7 @@ push_kv(key, val, args)
if (val == TK_None) return ST_CHECK; if (val == TK_None) return ST_CHECK;
rb_ary_push(ary, get_eval_string_core(val, Qnil, RARRAY_PTR(args)[1])); rb_ary_push(ary, get_eval_string_core(val, Qnil, RARRAY_CONST_PTR(args)[1]));
return ST_CHECK; return ST_CHECK;
} }
@ -702,20 +705,20 @@ push_kv_enc(key, val, args)
{ {
volatile VALUE ary; volatile VALUE ary;
ary = RARRAY_PTR(args)[0]; ary = RARRAY_CONST_PTR(args)[0];
#if 0 #if 0
rb_ary_push(ary, key2keyname(key)); rb_ary_push(ary, key2keyname(key));
if (val != TK_None) { if (val != TK_None) {
rb_ary_push(ary, get_eval_string_core(val, Qtrue, rb_ary_push(ary, get_eval_string_core(val, Qtrue,
RARRAY_PTR(args)[1])); RARRAY_CONST_PTR(args)[1]));
} }
#endif #endif
rb_ary_push(ary, key2keyname(key)); rb_ary_push(ary, key2keyname(key));
if (val == TK_None) return ST_CHECK; if (val == TK_None) return ST_CHECK;
rb_ary_push(ary, get_eval_string_core(val, Qtrue, RARRAY_PTR(args)[1])); rb_ary_push(ary, get_eval_string_core(val, Qtrue, RARRAY_CONST_PTR(args)[1]));
return ST_CHECK; return ST_CHECK;
} }
@ -1529,6 +1532,7 @@ cbsubst_table_setup(argc, argv, self)
volatile VALUE longkey_inf; volatile VALUE longkey_inf;
volatile VALUE proc_inf; volatile VALUE proc_inf;
VALUE inf; VALUE inf;
const VALUE *infp;
ID id; ID id;
struct cbsubst_info *subst_inf; struct cbsubst_info *subst_inf;
long idx, len; long idx, len;
@ -1559,15 +1563,16 @@ cbsubst_table_setup(argc, argv, self)
*/ */
len = RARRAY_LEN(key_inf); len = RARRAY_LEN(key_inf);
for(idx = 0; idx < len; idx++) { for(idx = 0; idx < len; idx++) {
inf = RARRAY_PTR(key_inf)[idx]; inf = RARRAY_CONST_PTR(key_inf)[idx];
if (!RB_TYPE_P(inf, T_ARRAY)) continue; if (!RB_TYPE_P(inf, T_ARRAY)) continue;
infp = RARRAY_CONST_PTR(inf);
chr = NUM2CHR(RARRAY_PTR(inf)[0]); chr = NUM2CHR(infp[0]);
subst_inf->type[chr] = NUM2CHR(RARRAY_PTR(inf)[1]); subst_inf->type[chr] = NUM2CHR(infp[1]);
subst_inf->full_subst_length += 3; subst_inf->full_subst_length += 3;
id = SYM2ID(RARRAY_PTR(inf)[2]); id = SYM2ID(infp[2]);
subst_inf->ivar[chr] = rb_intern_str(rb_sprintf("@%"PRIsVALUE, rb_id2str(id))); subst_inf->ivar[chr] = rb_intern_str(rb_sprintf("@%"PRIsVALUE, rb_id2str(id)));
rb_attr(self, id, 1, 0, Qtrue); rb_attr(self, id, 1, 0, Qtrue);
@ -1582,27 +1587,28 @@ cbsubst_table_setup(argc, argv, self)
*/ */
len = RARRAY_LEN(longkey_inf); len = RARRAY_LEN(longkey_inf);
for(idx = 0; idx < len; idx++) { for(idx = 0; idx < len; idx++) {
inf = RARRAY_PTR(longkey_inf)[idx]; inf = RARRAY_CONST_PTR(longkey_inf)[idx];
if (!RB_TYPE_P(inf, T_ARRAY)) continue; if (!RB_TYPE_P(inf, T_ARRAY)) continue;
infp = RARRAY_CONST_PTR(inf);
chr = (unsigned char)(0x80 + idx); chr = (unsigned char)(0x80 + idx);
subst_inf->keylen[chr] = RSTRING_LEN(RARRAY_PTR(inf)[0]); subst_inf->keylen[chr] = RSTRING_LEN(infp[0]);
#if HAVE_STRNDUP #if HAVE_STRNDUP
subst_inf->key[chr] = strndup(RSTRING_PTR(RARRAY_PTR(inf)[0]), subst_inf->key[chr] = strndup(RSTRING_PTR(infp[0]),
RSTRING_LEN(RARRAY_PTR(inf)[0])); RSTRING_LEN(infp[0]));
#else #else
subst_inf->key[chr] = malloc(RSTRING_LEN(RARRAY_PTR(inf)[0]) + 1); subst_inf->key[chr] = malloc(RSTRING_LEN(infp[0]) + 1);
if (subst_inf->key[chr]) { if (subst_inf->key[chr]) {
strncpy(subst_inf->key[chr], RSTRING_PTR(RARRAY_PTR(inf)[0]), strncpy(subst_inf->key[chr], RSTRING_PTR(infp[0]),
RSTRING_LEN(RARRAY_PTR(inf)[0]) + 1); RSTRING_LEN(infp[0]) + 1);
subst_inf->key[chr][RSTRING_LEN(RARRAY_PTR(inf)[0])] = '\0'; subst_inf->key[chr][RSTRING_LEN(infp[0])] = '\0';
} }
#endif #endif
subst_inf->type[chr] = NUM2CHR(RARRAY_PTR(inf)[1]); subst_inf->type[chr] = NUM2CHR(infp[1]);
subst_inf->full_subst_length += (subst_inf->keylen[chr] + 2); subst_inf->full_subst_length += (subst_inf->keylen[chr] + 2);
id = SYM2ID(RARRAY_PTR(inf)[2]); id = SYM2ID(infp[2]);
subst_inf->ivar[chr] = rb_intern_str(rb_sprintf("@%"PRIsVALUE, rb_id2str(id))); subst_inf->ivar[chr] = rb_intern_str(rb_sprintf("@%"PRIsVALUE, rb_id2str(id)));
rb_attr(self, id, 1, 0, Qtrue); rb_attr(self, id, 1, 0, Qtrue);
@ -1616,7 +1622,7 @@ cbsubst_table_setup(argc, argv, self)
len = RARRAY_LEN(proc_inf); len = RARRAY_LEN(proc_inf);
for(idx = 0; idx < len; idx++) { for(idx = 0; idx < len; idx++) {
VALUE type, proc; VALUE type, proc;
inf = RARRAY_PTR(proc_inf)[idx]; inf = RARRAY_CONST_PTR(proc_inf)[idx];
if (!RB_TYPE_P(inf, T_ARRAY)) continue; if (!RB_TYPE_P(inf, T_ARRAY)) continue;
if (RARRAY_LEN(inf) < 2) continue; if (RARRAY_LEN(inf) < 2) continue;
type = rb_ary_entry(inf, 0); type = rb_ary_entry(inf, 0);
@ -1676,10 +1682,10 @@ cbsubst_scan_args(self, arg_key, val_ary)
} }
if (NIL_P(proc)) { if (NIL_P(proc)) {
rb_ary_push(dst, RARRAY_PTR(val_ary)[idx]); rb_ary_push(dst, RARRAY_CONST_PTR(val_ary)[idx]);
} else { } else {
rb_ary_push(dst, rb_funcall(proc, ID_call, 1, rb_ary_push(dst, rb_funcall(proc, ID_call, 1,
RARRAY_PTR(val_ary)[idx])); RARRAY_CONST_PTR(val_ary)[idx]));
} }
} }