Use rb_len_t in the C API for lengths and indices

Once rb_len_t widens this changes the `long *` output parameters of rb_range_beg_len(), rb_str_subpos(), rb_arithmetic_sequence_beg_len_step(), ruby_enc_find_basename() and ruby_enc_find_extname(), so extensions passing `long *` to them will need to be updated. The extension guides list these signatures verbatim and follow along.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Hiroshi SHIBATAandClaude Opus 5 committed 2026-10-09 14:00:15 +09:00
1 parent 123fce4e6a
commit cc3ba11012
49 files changed
+284 -279
Notes: git 2026-10-09 05:02:12 +00:00

No files matched your search

+20 -20
View File
@@ -316,7 +316,7 @@ rb_ary_ptr_use_end(VALUE ary)
}
void
rb_mem_clear(VALUE *mem, long size)
rb_mem_clear(VALUE *mem, rb_len_t size)
{
while (size--) {
*mem++ = Qnil;
@@ -759,7 +759,7 @@ ary_new(VALUE klass, long capa)
}
VALUE
rb_ary_new_capa(long capa)
rb_ary_new_capa(rb_len_t capa)
{
return ary_new(rb_cArray, capa);
}
@@ -771,7 +771,7 @@ rb_ary_new(void)
}
VALUE
(rb_ary_new_from_args)(long n, ...)
(rb_ary_new_from_args)(rb_len_t n, ...)
{
va_list ar;
VALUE ary;
@@ -804,7 +804,7 @@ rb_ary_tmp_new_from_values(VALUE klass, long n, const VALUE *elts)
}
VALUE
rb_ary_new_from_values(long n, const VALUE *elts)
rb_ary_new_from_values(rb_len_t n, const VALUE *elts)
{
return rb_ary_tmp_new_from_values(rb_cArray, n, elts);
}
@@ -875,7 +875,7 @@ rb_ec_ary_new_from_values(rb_execution_context_t *ec, long n, const VALUE *elts)
}
VALUE
rb_ary_hidden_new(long capa)
rb_ary_hidden_new(rb_len_t capa)
{
VALUE ary = ary_new(0, capa);
return ary;
@@ -1225,7 +1225,7 @@ rb_ary_s_create(int argc, VALUE *argv, VALUE klass)
}
void
rb_ary_store(VALUE ary, long idx, VALUE val)
rb_ary_store(VALUE ary, rb_len_t idx, VALUE val)
{
long len = RARRAY_LEN(ary);
@@ -1421,7 +1421,7 @@ rb_ary_push(VALUE ary, VALUE item)
}
VALUE
rb_ary_cat(VALUE ary, const VALUE *argv, long len)
rb_ary_cat(VALUE ary, const VALUE *argv, rb_len_t len)
{
long oldlen = RARRAY_LEN(ary);
VALUE target_ary = ary_ensure_room_for_push(ary, len);
@@ -1763,7 +1763,7 @@ rb_ary_elt(VALUE ary, long offset)
}
VALUE
rb_ary_entry(VALUE ary, long offset)
rb_ary_entry(VALUE ary, rb_len_t offset)
{
return rb_ary_entry_internal(ary, offset);
}
@@ -1784,7 +1784,7 @@ ary_subseq_len(VALUE ary, long beg, long len)
}
VALUE
rb_ary_subseq(VALUE ary, long beg, long len)
rb_ary_subseq(VALUE ary, rb_len_t beg, rb_len_t len)
{
const VALUE klass = rb_cArray;
len = ary_subseq_len(ary, beg, len);
@@ -1937,7 +1937,7 @@ rb_ary_aref2(VALUE ary, VALUE b, VALUE e)
VALUE
rb_ary_aref1(VALUE ary, VALUE arg)
{
long beg, len, step;
rb_len_t beg, len, step;
const VALUE klass = rb_cArray;
/* special case - speeding up */
@@ -2429,7 +2429,7 @@ rb_ary_modify_expand(VALUE ary, long expand)
}
VALUE
rb_ary_resize(VALUE ary, long len)
rb_ary_resize(VALUE ary, rb_len_t len)
{
long olen;
@@ -2633,7 +2633,7 @@ ary_aset_by_rb_ary_splice(VALUE ary, long beg, long len, VALUE val)
static VALUE
rb_ary_aset(int argc, VALUE *argv, VALUE ary)
{
long offset, beg, len;
rb_len_t offset, beg, len;
rb_check_arity(argc, 2, 3);
rb_ary_modify_check(ary);
@@ -3458,7 +3458,7 @@ ary_rotate_ptr(VALUE *ptr, long len, long cnt)
}
VALUE
rb_ary_rotate(VALUE ary, long cnt)
rb_ary_rotate(VALUE ary, rb_len_t cnt)
{
rb_ary_modify(ary);
@@ -3945,10 +3945,10 @@ rb_ary_collect_bang(VALUE ary)
}
VALUE
rb_get_values_at(VALUE obj, long olen, int argc, const VALUE *argv, VALUE (*func) (VALUE, long))
rb_get_values_at(VALUE obj, rb_len_t olen, int argc, const VALUE *argv, VALUE (*func) (VALUE, rb_len_t))
{
VALUE result = rb_ary_new2(argc);
long beg, len, i, j;
rb_len_t beg, len, i, j;
for (i=0; i<argc; i++) {
if (FIXNUM_P(argv[i])) {
@@ -3971,9 +3971,9 @@ rb_get_values_at(VALUE obj, long olen, int argc, const VALUE *argv, VALUE (*func
}
static VALUE
append_values_at_single(VALUE result, VALUE ary, long olen, VALUE idx)
append_values_at_single(VALUE result, VALUE ary, rb_len_t olen, VALUE idx)
{
long beg, len;
rb_len_t beg, len;
if (FIXNUM_P(idx)) {
beg = FIX2LONG(idx);
}
@@ -4365,7 +4365,7 @@ rb_ary_delete_same(VALUE ary, VALUE item)
}
VALUE
rb_ary_delete_at(VALUE ary, long pos)
rb_ary_delete_at(VALUE ary, rb_len_t pos)
{
long len = RARRAY_LEN(ary);
VALUE del;
@@ -4546,7 +4546,7 @@ static VALUE
rb_ary_slice_bang(int argc, VALUE *argv, VALUE ary)
{
VALUE arg1;
long pos, len;
rb_len_t pos, len;
rb_ary_modify_check(ary);
rb_check_arity(argc, 1, 2);
@@ -5196,7 +5196,7 @@ static VALUE
rb_ary_fill(int argc, VALUE *argv, VALUE ary)
{
VALUE item = Qundef, arg1, arg2;
long beg = 0, end = 0, len = 0;
rb_len_t beg = 0, end = 0, len = 0;
if (rb_block_given_p()) {
rb_scan_args(argc, argv, "02", &arg1, &arg2);
+19 -19
View File
@@ -200,7 +200,7 @@ Rubyが用意している関数を用いてください.
==== 文字列に対する関数
<tt>rb_str_new(const char *ptr, long len)</tt> ::
<tt>rb_str_new(const char *ptr, rb_len_t len)</tt> ::
新しいRubyの文字列を生成する.
@@ -228,7 +228,7 @@ Rubyが用意している関数を用いてください.
ときは Object#inspect)を使ったVALUEの出力に利用できる.これ
は<tt>"%i"</tt>と衝突するため,整数には<tt>"%d"</tt>を使用すること.
<tt>rb_str_cat(VALUE str, const char *ptr, long len)</tt> ::
<tt>rb_str_cat(VALUE str, const char *ptr, rb_len_t len)</tt> ::
Rubyの文字列 _str_ に _len_ バイトの文字列 _ptr_ を追加する.
@@ -246,7 +246,7 @@ Rubyが用意している関数を用いてください.
<tt>rb_str_append(str, rb_sprintf(format, ...))</tt> や
<tt>rb_str_append(str, rb_vsprintf(format, ap))</tt> と同等である.
<tt>rb_enc_str_new(const char *ptr, long len, rb_encoding *enc)</tt> ::
<tt>rb_enc_str_new(const char *ptr, rb_len_t len, rb_encoding *enc)</tt> ::
<tt>rb_enc_str_new_cstr(const char *ptr, rb_encoding *enc)</tt> ::
指定されたエンコーディングでRubyの文字列を生成する.
@@ -255,7 +255,7 @@ Rubyが用意している関数を用いてください.
Cのリテラル文字列から指定されたエンコーディングでRubyの文字列を生成する.
<tt>rb_usascii_str_new(const char *ptr, long len)</tt> ::
<tt>rb_usascii_str_new(const char *ptr, rb_len_t len)</tt> ::
<tt>rb_usascii_str_new_cstr(const char *ptr)</tt> ::
エンコーディングがUS-ASCIIのRubyの文字列を生成する.
@@ -264,7 +264,7 @@ Rubyが用意している関数を用いてください.
Cのリテラル文字列からエンコーディングがUS-ASCIIのRubyの文字列を生成する.
<tt>rb_utf8_str_new(const char *ptr, long len)</tt> ::
<tt>rb_utf8_str_new(const char *ptr, rb_len_t len)</tt> ::
<tt>rb_utf8_str_new_cstr(const char *ptr)</tt> ::
エンコーディングがUTF-8のRubyの文字列を生成する.
@@ -273,7 +273,7 @@ Rubyが用意している関数を用いてください.
Cのリテラル文字列からエンコーディングがUTF-8のRubyの文字列を生成する.
<tt>rb_str_resize(VALUE str, long len)</tt> ::
<tt>rb_str_resize(VALUE str, rb_len_t len)</tt> ::
Rubyの文字列のサイズを _len_ バイトに変更する._str_ の長さは前
以てセットされていなければならない._len_ が元の長さよりも短
@@ -282,7 +282,7 @@ Rubyが用意している関数を用いてください.
れないでゴミになるだろう.この関数の呼び出しによって
<tt>RSTRING_PTR(str)</tt>が変更されるかもしれないことに注意.
<tt>rb_str_set_len(VALUE str, long len)</tt> ::
<tt>rb_str_set_len(VALUE str, rb_len_t len)</tt> ::
Rubyの文字列のサイズを _len_ バイトにセットする._str_ が変更可
能でなければ例外が発生する.<tt>RSTRING_LEN(str)</tt>とは無関係に,
@@ -303,19 +303,19 @@ Rubyが用意している関数を用いてください.
要素が0の配列を生成する.
<tt>rb_ary_new2(long len)</tt> ::
<tt>rb_ary_new_capa(long len)</tt> ::
<tt>rb_ary_new2(rb_len_t len)</tt> ::
<tt>rb_ary_new_capa(rb_len_t len)</tt> ::
要素が0の配列を生成する._len_ 要素分の領域をあらかじめ割り
当てておく.
<tt>rb_ary_new3(long n, ...)</tt> ::
<tt>rb_ary_new_from_args(long n, ...)</tt> ::
<tt>rb_ary_new3(rb_len_t n, ...)</tt> ::
<tt>rb_ary_new_from_args(rb_len_t n, ...)</tt> ::
引数で指定した _n_ 要素を含む配列を生成する.
<tt>rb_ary_new4(long n, VALUE *elts)</tt> ::
<tt>rb_ary_new_from_values(long n, VALUE *elts)</tt> ::
<tt>rb_ary_new4(rb_len_t n, VALUE *elts)</tt> ::
<tt>rb_ary_new_from_values(rb_len_t n, VALUE *elts)</tt> ::
配列で与えた _n_ 要素の配列を生成する.
@@ -332,15 +332,15 @@ Rubyが用意している関数を用いてください.
Array#[]と同等.
<tt>rb_ary_entry(VALUE ary, long offset)</tt> ::
<tt>rb_ary_entry(VALUE ary, rb_len_t offset)</tt> ::
<tt>ary[offset]</tt>
<tt>rb_ary_store(VALUE ary, long offset, VALUE obj)</tt> ::
<tt>rb_ary_store(VALUE ary, rb_len_t offset, VALUE obj)</tt> ::
<tt>ary[offset] = obj</tt>
<tt>rb_ary_subseq(VALUE ary, long beg, long len)</tt> ::
<tt>rb_ary_subseq(VALUE ary, rb_len_t beg, rb_len_t len)</tt> ::
<tt>ary[beg, len]</tt>
@@ -351,7 +351,7 @@ Rubyが用意している関数を用いてください.
<tt>ary.push(val)</tt>, <tt>ary.pop</tt>, <tt>ary.shift</tt>, <tt>ary.unshift(val)</tt>
<tt>rb_ary_cat(VALUE ary, const VALUE *ptr, long len)</tt> ::
<tt>rb_ary_cat(VALUE ary, const VALUE *ptr, rb_len_t len)</tt> ::
配列 _ary_ に _ptr_ から _len_ 個のオブジェクトを追加する.
@@ -549,7 +549,7 @@ IDとは変数名,メソッド名を表す整数です.Rubyの中では
rb_to_id(VALUE symbol)
rb_check_id(volatile VALUE *name)
rb_check_id_cstr(const char *name, long len, rb_encoding *enc)
rb_check_id_cstr(const char *name, rb_len_t len, rb_encoding *enc)
もし引数がシンボルでも文字列でもなければ,+to_str+ メソッドで文
字列に変換しようとします.第二の関数はその変換結果を<tt>*name</tt>に保
@@ -563,7 +563,7 @@ Rubyから引数として与えられたシンボル(または文字列)をシ
rb_to_symbol(VALUE name)
rb_check_symbol(volatile VALUE *namep)
rb_check_symbol_cstr(const char *ptr, long len, rb_encoding *enc)
rb_check_symbol_cstr(const char *ptr, rb_len_t len, rb_encoding *enc)
これらの関数は,IDの代わりにシンボルを返すことを除けば上記の
関数と同じです.
+19 -19
View File
@@ -182,7 +182,7 @@ listed below:
==== String functions
<tt>rb_str_new(const char *ptr, long len)</tt> ::
<tt>rb_str_new(const char *ptr, rb_len_t len)</tt> ::
Creates a new Ruby string.
@@ -210,7 +210,7 @@ listed below:
Appends Ruby string str2 to Ruby string str1.
<tt>rb_str_cat(VALUE str, const char *ptr, long len)</tt> ::
<tt>rb_str_cat(VALUE str, const char *ptr, rb_len_t len)</tt> ::
Appends len bytes of data from ptr to the Ruby string.
@@ -228,7 +228,7 @@ listed below:
equivalent to <tt>rb_str_append(str, rb_sprintf(format, ...))</tt> and
<tt>rb_str_append(str, rb_vsprintf(format, ap))</tt>, respectively.
<tt>rb_enc_str_new(const char *ptr, long len, rb_encoding *enc)</tt> ::
<tt>rb_enc_str_new(const char *ptr, rb_len_t len, rb_encoding *enc)</tt> ::
<tt>rb_enc_str_new_cstr(const char *ptr, rb_encoding *enc)</tt> ::
Creates a new Ruby string with the specified encoding.
@@ -238,7 +238,7 @@ listed below:
Creates a new Ruby string from a C string literal with the specified
encoding.
<tt>rb_usascii_str_new(const char *ptr, long len)</tt> ::
<tt>rb_usascii_str_new(const char *ptr, rb_len_t len)</tt> ::
<tt>rb_usascii_str_new_cstr(const char *ptr)</tt> ::
Creates a new Ruby string with encoding US-ASCII.
@@ -248,7 +248,7 @@ listed below:
Creates a new Ruby string from a C string literal with encoding
US-ASCII.
<tt>rb_utf8_str_new(const char *ptr, long len)</tt> ::
<tt>rb_utf8_str_new(const char *ptr, rb_len_t len)</tt> ::
<tt>rb_utf8_str_new_cstr(const char *ptr)</tt> ::
Creates a new Ruby string with encoding UTF-8.
@@ -258,7 +258,7 @@ listed below:
Creates a new Ruby string from a C string literal with encoding
UTF-8.
<tt>rb_str_resize(VALUE str, long len)</tt> ::
<tt>rb_str_resize(VALUE str, rb_len_t len)</tt> ::
Resizes a Ruby string to len bytes. If str is not modifiable, this
function raises an exception. The length of str must be set in
@@ -268,7 +268,7 @@ listed below:
will be garbage. Note that <tt>RSTRING_PTR(str)</tt> may change by calling
this function.
<tt>rb_str_set_len(VALUE str, long len)</tt> ::
<tt>rb_str_set_len(VALUE str, rb_len_t len)</tt> ::
Sets the length of a Ruby string. If str is not modifiable, this
function raises an exception. This function preserves the content
@@ -289,19 +289,19 @@ listed below:
Creates an array with no elements.
<tt>rb_ary_new2(long len)</tt> ::
<tt>rb_ary_new_capa(long len)</tt> ::
<tt>rb_ary_new2(rb_len_t len)</tt> ::
<tt>rb_ary_new_capa(rb_len_t len)</tt> ::
Creates an array with no elements, allocating internal buffer
for len elements.
<tt>rb_ary_new3(long n, ...)</tt> ::
<tt>rb_ary_new_from_args(long n, ...)</tt> ::
<tt>rb_ary_new3(rb_len_t n, ...)</tt> ::
<tt>rb_ary_new_from_args(rb_len_t n, ...)</tt> ::
Creates an n-element array from the arguments.
<tt>rb_ary_new4(long n, VALUE *elts)</tt> ::
<tt>rb_ary_new_from_values(long n, VALUE *elts)</tt> ::
<tt>rb_ary_new4(rb_len_t n, VALUE *elts)</tt> ::
<tt>rb_ary_new_from_values(rb_len_t n, VALUE *elts)</tt> ::
Creates an n-element array from a C array.
@@ -317,15 +317,15 @@ types are given.
Equivalent to Array#[].
<tt>rb_ary_entry(VALUE ary, long offset)</tt> ::
<tt>rb_ary_entry(VALUE ary, rb_len_t offset)</tt> ::
<tt>ary[offset]</tt>
<tt>rb_ary_store(VALUE ary, long offset, VALUE obj)</tt> ::
<tt>rb_ary_store(VALUE ary, rb_len_t offset, VALUE obj)</tt> ::
<tt>ary[offset] = obj</tt>
<tt>rb_ary_subseq(VALUE ary, long beg, long len)</tt> ::
<tt>rb_ary_subseq(VALUE ary, rb_len_t beg, rb_len_t len)</tt> ::
<tt>ary[beg, len]</tt>
@@ -336,7 +336,7 @@ types are given.
<tt>ary.push(val)</tt>, <tt>ary.pop</tt>, <tt>ary.shift</tt>, <tt>ary.unshift(val)</tt>
<tt>rb_ary_cat(VALUE ary, const VALUE *ptr, long len)</tt> ::
<tt>rb_ary_cat(VALUE ary, const VALUE *ptr, rb_len_t len)</tt> ::
Appends _len_ elements of objects from _ptr_ to the array.
@@ -527,7 +527,7 @@ argument by using
rb_to_id(VALUE symbol)
rb_check_id(volatile VALUE *name)
rb_check_id_cstr(const char *name, long len, rb_encoding *enc)
rb_check_id_cstr(const char *name, rb_len_t len, rb_encoding *enc)
These functions try to convert the argument to a String if it was not a
Symbol nor a String. The second function stores the converted result into
@@ -542,7 +542,7 @@ an argument by using
rb_to_symbol(VALUE name)
rb_check_symbol(volatile VALUE *namep)
rb_check_symbol_cstr(const char *ptr, long len, rb_encoding *enc)
rb_check_symbol_cstr(const char *ptr, rb_len_t len, rb_encoding *enc)
These functions are similar to above functions except that these
return a Symbol instead of an ID.
+1 -1
View File
@@ -4006,7 +4006,7 @@ rb_arithmetic_sequence_extract(VALUE obj, rb_arithmetic_sequence_components_t *c
}
VALUE
rb_arithmetic_sequence_beg_len_step(VALUE obj, long *begp, long *lenp, long *stepp, long len, int err)
rb_arithmetic_sequence_beg_len_step(VALUE obj, rb_len_t *begp, rb_len_t *lenp, rb_len_t *stepp, rb_len_t len, int err)
{
RBIMPL_NONNULL_ARG(begp);
RBIMPL_NONNULL_ARG(lenp);
+1 -1
View File
@@ -1492,7 +1492,7 @@ static ID id_private_call_p, id_top, id_bottom;
#undef rb_exc_new_cstr
VALUE
rb_exc_new(VALUE etype, const char *ptr, long len)
rb_exc_new(VALUE etype, const char *ptr, rb_len_t len)
{
VALUE mesg = rb_str_new(ptr, len);
return rb_class_new_instance(1, &mesg, etype);
@@ -4,7 +4,7 @@ static VALUE
arith_seq_s_beg_len_step(VALUE mod, VALUE obj, VALUE len, VALUE err)
{
VALUE r;
long beg, len2, step;
rb_len_t beg, len2, step;
r = rb_arithmetic_sequence_beg_len_step(obj, &beg, &len2, &step, NUM2LONG(len), NUM2INT(err));
+1 -1
View File
@@ -324,7 +324,7 @@ static VALUE
memory_view_get_data_body(VALUE _args)
{
memory_view_get_data_args *args = (memory_view_get_data_args *)_args;
long beg, len;
rb_len_t beg, len;
if (RTEST(rb_range_beg_len(args->location,
&beg,
+6 -6
View File
@@ -5833,7 +5833,7 @@ rmext(const char *p, long l0, long l1, const char *e, long l2, rb_encoding *enc)
}
static inline const char *
enc_find_basename(const char *name, long *baselen, long *alllen, bool mb_enc, rb_encoding *enc)
enc_find_basename(const char *name, rb_len_t *baselen, rb_len_t *alllen, bool mb_enc, rb_encoding *enc)
{
const char *p, *q, *e, *end;
long f = 0, n = -1;
@@ -5911,7 +5911,7 @@ enc_find_basename(const char *name, long *baselen, long *alllen, bool mb_enc, rb
}
const char *
ruby_enc_find_basename(const char *name, long *baselen, long *alllen, rb_encoding *enc)
ruby_enc_find_basename(const char *name, rb_len_t *baselen, rb_len_t *alllen, rb_encoding *enc)
{
return enc_find_basename(name, baselen, alllen, enc_mbclen_needed(enc), enc);
}
@@ -5958,7 +5958,7 @@ rb_file_s_basename(int argc, VALUE *argv, VALUE _)
{
VALUE fname, fext = Qnil;
const char *name, *p, *fp = 0;
long f = 0, n;
rb_len_t f = 0, n;
rb_encoding *enc;
argc = rb_check_arity(argc, 1, 2);
@@ -6091,7 +6091,7 @@ rb_file_dirname_n(VALUE fname, int n)
}
static inline const char *
enc_find_extname(const char *name, long *len, bool mb_enc, rb_encoding *enc)
enc_find_extname(const char *name, rb_len_t *len, bool mb_enc, rb_encoding *enc)
{
const char *p, *e, *end = name + (len ? *len : (long)strlen(name));
@@ -6156,7 +6156,7 @@ enc_find_extname(const char *name, long *len, bool mb_enc, rb_encoding *enc)
*
*/
const char *
ruby_enc_find_extname(const char *name, long *len, rb_encoding *enc)
ruby_enc_find_extname(const char *name, rb_len_t *len, rb_encoding *enc)
{
return enc_find_extname(name, len, enc_mbclen_needed(enc), enc);
}
@@ -6206,7 +6206,7 @@ rb_file_s_extname(VALUE klass, VALUE fname)
{
const char *name;
CheckPath(fname, name);
long len = RSTRING_LEN(fname);
rb_len_t len = RSTRING_LEN(fname);
if (len < 1) {
return rb_enc_str_new(0, 0, rb_str_enc_get(fname));
+1 -1
View File
@@ -13292,7 +13292,7 @@ rb_gc_impl_after_fork(void *objspace_ptr, rb_pid_t pid)
}
}
VALUE rb_ident_hash_new_capa(long size);
VALUE rb_ident_hash_new_capa(rb_len_t size);
#if GC_DEBUG_STRESS_TO_CLASS
/*
+3 -3
View File
@@ -1620,7 +1620,7 @@ hash_new_capa(VALUE klass, size_t capa)
}
VALUE
rb_hash_new_capa(long capa)
rb_hash_new_capa(rb_len_t capa)
{
if (capa < 0) {
rb_raise(rb_eArgError, "negative hash size (or size too big)");
@@ -5012,7 +5012,7 @@ rb_ident_hash_new(void)
}
VALUE
rb_ident_hash_new_capa(long size)
rb_ident_hash_new_capa(rb_len_t size)
{
VALUE hash = rb_hash_new_capa(0);
FL_SET_RAW(hash, RHASH_COMPARE_BY_IDENTITY);
@@ -5390,7 +5390,7 @@ ar_bulk_insert(VALUE hash, long argc, const VALUE *argv)
}
void
rb_hash_bulk_insert(long argc, const VALUE *argv, VALUE hash)
rb_hash_bulk_insert(rb_len_t argc, const VALUE *argv, VALUE hash)
{
HASH_ASSERT(argc % 2 == 0);
if (argc > 0) {
+2 -2
View File
@@ -86,7 +86,7 @@ rb_imemo_tmpbuf_new(void)
}
void *
rb_alloc_tmp_buffer(volatile VALUE *store, long len, bool marked)
rb_alloc_tmp_buffer(volatile VALUE *store, rb_len_t len, bool marked)
{
if (len < 0) {
rb_raise(rb_eArgError, "negative buffer size (or size too big)");
@@ -111,7 +111,7 @@ rb_free_tmp_buffer(volatile VALUE *store)
rb_imemo_tmpbuf_t *s = (rb_imemo_tmpbuf_t*)ATOMIC_VALUE_EXCHANGE(*store, 0);
if (s) {
void *ptr = ATOMIC_PTR_EXCHANGE(s->ptr, 0);
long size = s->size;
size_t size = s->size;
s->size = 0;
ruby_xfree_sized(ptr, size);
}
+5 -5
View File
@@ -245,7 +245,7 @@ VALUE rb_debug_inspector_backtrace_locations(const rb_debug_inspector_t *dc);
* @exception rb_eArgError `index` out of range.
* @return The current receiver at `index`-th frame.
*/
VALUE rb_debug_inspector_frame_self_get(const rb_debug_inspector_t *dc, long index);
VALUE rb_debug_inspector_frame_self_get(const rb_debug_inspector_t *dc, rb_len_t index);
/**
* Queries the current class of the passed context's upper frame.
@@ -255,7 +255,7 @@ VALUE rb_debug_inspector_frame_self_get(const rb_debug_inspector_t *dc, long ind
* @exception rb_eArgError `index` out of range.
* @return The current class at `index`-th frame.
*/
VALUE rb_debug_inspector_frame_class_get(const rb_debug_inspector_t *dc, long index);
VALUE rb_debug_inspector_frame_class_get(const rb_debug_inspector_t *dc, rb_len_t index);
/**
* Queries the binding of the passed context's upper frame.
@@ -265,7 +265,7 @@ VALUE rb_debug_inspector_frame_class_get(const rb_debug_inspector_t *dc, long in
* @exception rb_eArgError `index` out of range.
* @return The binding at `index`-th frame.
*/
VALUE rb_debug_inspector_frame_binding_get(const rb_debug_inspector_t *dc, long index);
VALUE rb_debug_inspector_frame_binding_get(const rb_debug_inspector_t *dc, rb_len_t index);
/**
* Queries the instruction sequence of the passed context's upper frame.
@@ -278,7 +278,7 @@ VALUE rb_debug_inspector_frame_binding_get(const rb_debug_inspector_t *dc, long
* represents the instruction sequence at `index`-th
* frame.
*/
VALUE rb_debug_inspector_frame_iseq_get(const rb_debug_inspector_t *dc, long index);
VALUE rb_debug_inspector_frame_iseq_get(const rb_debug_inspector_t *dc, rb_len_t index);
/**
* Queries the depth of the passed context's upper frame.
@@ -291,7 +291,7 @@ VALUE rb_debug_inspector_frame_iseq_get(const rb_debug_inspector_t *dc, long ind
* @exception rb_eArgError `index` out of range.
* @retval The depth at `index`-th frame in Integer.
*/
VALUE rb_debug_inspector_frame_depth(const rb_debug_inspector_t *dc, long index);
VALUE rb_debug_inspector_frame_depth(const rb_debug_inspector_t *dc, rb_len_t index);
// A macro to recognize `rb_debug_inspector_frame_depth()` is available or not
#define RB_DEBUG_INSPECTOR_FRAME_DEPTH(dc, index) rb_debug_inspector_frame_depth(dc, index)
+2 -2
View File
@@ -135,7 +135,7 @@ RBIMPL_ATTR_NONNULL((1, 4))
* @post `alllen`, if passed, is updated to be the number of bytes of
* strings not considered as the basename.
*/
const char *ruby_enc_find_basename(const char *name, long *baselen, long *alllen, rb_encoding *enc);
const char *ruby_enc_find_basename(const char *name, rb_len_t *baselen, rb_len_t *alllen, rb_encoding *enc);
RBIMPL_ATTR_NONNULL((1, 3))
/**
@@ -177,7 +177,7 @@ RBIMPL_ATTR_NONNULL((1, 3))
* @return See above.
* @post `len`, if passed, is updated (see above).
*/
const char *ruby_enc_find_extname(const char *name, long *len, rb_encoding *enc);
const char *ruby_enc_find_extname(const char *name, rb_len_t *len, rb_encoding *enc);
RBIMPL_SYMBOL_EXPORT_END()
+1 -1
View File
@@ -39,7 +39,7 @@ RBIMPL_SYMBOL_EXPORT_BEGIN()
* @return An allocated new instance of ::rb_cRegexp, of `enc` encoding,
* whose expression is compiled according to `ptr`.
*/
VALUE rb_enc_reg_new(const char *ptr, long len, rb_encoding *enc, int opts);
VALUE rb_enc_reg_new(const char *ptr, rb_len_t len, rb_encoding *enc, int opts);
RBIMPL_SYMBOL_EXPORT_END()
+10 -10
View File
@@ -45,7 +45,7 @@ RBIMPL_SYMBOL_EXPORT_BEGIN()
* @note `enc` can be a null pointer. It can also be seen as a routine
* identical to rb_usascii_str_new() then.
*/
VALUE rb_enc_str_new(const char *ptr, long len, rb_encoding *enc);
VALUE rb_enc_str_new(const char *ptr, rb_len_t len, rb_encoding *enc);
RBIMPL_ATTR_NONNULL((1))
/**
@@ -84,7 +84,7 @@ VALUE rb_enc_str_new_cstr(const char *ptr, rb_encoding *enc);
* @note `enc` can be a null pointer. It can also be seen as a routine
* identical to rb_usascii_str_new_static() then.
*/
VALUE rb_enc_str_new_static(const char *ptr, long len, rb_encoding *enc);
VALUE rb_enc_str_new_static(const char *ptr, rb_len_t len, rb_encoding *enc);
/**
* Identical to rb_enc_str_new(), except it returns a "f"string. It can also
@@ -103,7 +103,7 @@ VALUE rb_enc_str_new_static(const char *ptr, long len, rb_encoding *enc);
* accessible via `ptr`.
* @note `enc` can be a null pointer.
*/
VALUE rb_enc_interned_str(const char *ptr, long len, rb_encoding *enc);
VALUE rb_enc_interned_str(const char *ptr, rb_len_t len, rb_encoding *enc);
RBIMPL_ATTR_NONNULL((1))
/**
@@ -133,7 +133,7 @@ VALUE rb_enc_interned_str_cstr(const char *ptr, rb_encoding *enc);
* @return Number of characters exist in `head` .. `tail`. The definition
* of "character" depends on the passed `enc`.
*/
long rb_enc_strlen(const char *head, const char *tail, rb_encoding *enc);
rb_len_t rb_enc_strlen(const char *head, const char *tail, rb_encoding *enc);
/**
* Queries the n-th character. Like rb_enc_strlen() this function can be fast
@@ -149,7 +149,7 @@ long rb_enc_strlen(const char *head, const char *tail, rb_encoding *enc);
* character (OOB etc). The definition of "character" depends on
* the passed `enc`.
*/
char *rb_enc_nth(const char *head, const char *tail, long nth, rb_encoding *enc);
char *rb_enc_nth(const char *head, const char *tail, rb_len_t nth, rb_encoding *enc);
/**
* Identical to rb_enc_get_index(), except the return type.
@@ -173,7 +173,7 @@ VALUE rb_obj_encoding(VALUE obj);
* @post The contents of `ptr` is copied, transcoded into `dst`'s
* encoding, then pasted into `dst`'s end.
*/
VALUE rb_enc_str_buf_cat(VALUE str, const char *ptr, long len, rb_encoding *enc);
VALUE rb_enc_str_buf_cat(VALUE str, const char *ptr, rb_len_t len, rb_encoding *enc);
/**
* Encodes the passed code point into a series of bytes.
@@ -221,7 +221,7 @@ VALUE rb_enc_uint_chr(unsigned int code, rb_encoding *enc);
* that others obey. It seems to him that this should have been called
* `rb_enc_external_str_new`.
*/
VALUE rb_external_str_new_with_enc(const char *ptr, long len, rb_encoding *enc);
VALUE rb_external_str_new_with_enc(const char *ptr, rb_len_t len, rb_encoding *enc);
/**
* Identical to rb_str_export(), except it additionally takes an encoding.
@@ -318,7 +318,7 @@ rb_enc_str_coderange_inline(VALUE str)
* @return Distance between `str` and first such byte where broken.
* @post `cr` has the code range type.
*/
long rb_str_coderange_scan_restartable(const char *str, const char *end, rb_encoding *enc, int *cr);
rb_len_t rb_str_coderange_scan_restartable(const char *str, const char *end, rb_encoding *enc, int *cr);
/**
* Queries if the passed string is "ASCII only". An ASCII only string is a
@@ -345,14 +345,14 @@ RBIMPL_ATTR_NONNULL(())
* @retval otherwise Found index in `y`.
* @note This API can match at a non-character-boundary.
*/
long rb_memsearch(const void *x, long m, const void *y, long n, rb_encoding *enc);
rb_len_t rb_memsearch(const void *x, rb_len_t m, const void *y, rb_len_t n, rb_encoding *enc);
/** @cond INTERNAL_MACRO */
RBIMPL_ATTR_NONNULL(())
static inline VALUE
rbimpl_enc_str_new_cstr(const char *str, rb_encoding *enc)
{
long len = rbimpl_strlen(str);
rb_len_t len = rbimpl_strlen(str);
return rb_enc_str_new_static(str, len, enc);
}
+4 -4
View File
@@ -42,7 +42,7 @@ RBIMPL_SYMBOL_EXPORT_BEGIN()
* is up to you to avoid memory leaks. Think twice before using
* it.
*/
ID rb_intern3(const char *name, long len, rb_encoding *enc);
ID rb_intern3(const char *name, rb_len_t len, rb_encoding *enc);
RBIMPL_ATTR_NONNULL(())
/**
@@ -66,7 +66,7 @@ int rb_enc_symname_p(const char *str, rb_encoding *enc);
* @retval 1 It is a valid symbol name.
* @retval 0 It is invalid as a symbol name.
*/
int rb_enc_symname2_p(const char *name, long len, rb_encoding *enc);
int rb_enc_symname2_p(const char *name, rb_len_t len, rb_encoding *enc);
/**
* Identical to rb_check_id(), except it takes a pointer to a memory region
@@ -79,7 +79,7 @@ int rb_enc_symname2_p(const char *name, long len, rb_encoding *enc);
* @retval 0 No such id ever existed in the history.
* @retval otherwise The id that represents the given name.
*/
ID rb_check_id_cstr(const char *ptr, long len, rb_encoding *enc);
ID rb_check_id_cstr(const char *ptr, rb_len_t len, rb_encoding *enc);
/**
* Identical to rb_check_id_cstr(), except for the return type. It can also be
@@ -93,7 +93,7 @@ ID rb_check_id_cstr(const char *ptr, long len, rb_encoding *enc);
* @retval RUBY_Qnil No such id ever existed in the history.
* @retval otherwise The id that represents the given name.
*/
VALUE rb_check_symbol_cstr(const char *ptr, long len, rb_encoding *enc);
VALUE rb_check_symbol_cstr(const char *ptr, rb_len_t len, rb_encoding *enc);
RBIMPL_SYMBOL_EXPORT_END()
+3 -3
View File
@@ -380,7 +380,7 @@ VALUE rb_econv_str_convert(rb_econv_t *ec, VALUE src, int flags);
* @exception rb_eUndefinedConversionError Conversion undefined.
* @return The conversion result.
*/
VALUE rb_econv_substr_convert(rb_econv_t *ec, VALUE src, long byteoff, long bytesize, int flags);
VALUE rb_econv_substr_convert(rb_econv_t *ec, VALUE src, rb_len_t byteoff, rb_len_t bytesize, int flags);
/**
* Identical to rb_econv_str_convert(), except it appends the conversion result
@@ -416,7 +416,7 @@ VALUE rb_econv_str_append(rb_econv_t *ec, VALUE src, VALUE dst, int flags);
* @exception rb_eUndefinedConversionError Conversion undefined.
* @return The conversion result.
*/
VALUE rb_econv_substr_append(rb_econv_t *ec, VALUE src, long byteoff, long bytesize, VALUE dst, int flags);
VALUE rb_econv_substr_append(rb_econv_t *ec, VALUE src, rb_len_t byteoff, rb_len_t bytesize, VALUE dst, int flags);
/**
* Converts the passed C's pointer according to the passed converter, then
@@ -433,7 +433,7 @@ VALUE rb_econv_substr_append(rb_econv_t *ec, VALUE src, long byteoff, long bytes
* @exception rb_eUndefinedConversionError Conversion undefined.
* @return The conversion result.
*/
VALUE rb_econv_append(rb_econv_t *ec, const char *bytesrc, long bytesize, VALUE dst, int flags);
VALUE rb_econv_append(rb_econv_t *ec, const char *bytesrc, rb_len_t bytesize, VALUE dst, int flags);
/**
* This badly named function does not set the destination encoding to binary,
+13 -13
View File
@@ -40,7 +40,7 @@ RBIMPL_ATTR_NOALIAS()
* @param[in] len Number of objects of `buf`.
* @post `buf` is filled with ::RUBY_Qnil.
*/
void rb_mem_clear(VALUE *buf, long len)
void rb_mem_clear(VALUE *buf, rb_len_t len)
RBIMPL_ATTR_NOEXCEPT(true)
;
@@ -86,7 +86,7 @@ VALUE rb_ary_new(void);
* @param[in] capa Designed capacity of the generating array.
* @return An empty array, whose capacity is `capa`.
*/
VALUE rb_ary_new_capa(long capa);
VALUE rb_ary_new_capa(rb_len_t capa);
/**
* Constructs an array from the passed objects.
@@ -95,7 +95,7 @@ VALUE rb_ary_new_capa(long capa);
* @param[in] ... Arbitrary ruby objects, filled into the returning array.
* @return An array of size `n`, whose contents are the passed objects.
*/
VALUE rb_ary_new_from_args(long n, ...);
VALUE rb_ary_new_from_args(rb_len_t n, ...);
/**
* Identical to rb_ary_new_from_args(), except how objects are passed.
@@ -104,7 +104,7 @@ VALUE rb_ary_new_from_args(long n, ...);
* @param[in] elts Arbitrary ruby objects, filled into the returning array.
* @return An array of size `n`, whose contents are the passed objects.
*/
VALUE rb_ary_new_from_values(long n, const VALUE *elts);
VALUE rb_ary_new_from_values(rb_len_t n, const VALUE *elts);
/**
* Allocates a hidden (no class) empty array.
@@ -113,7 +113,7 @@ VALUE rb_ary_new_from_values(long n, const VALUE *elts);
* @return A hidden, empty array.
* @see rb_obj_hide()
*/
VALUE rb_ary_hidden_new(long capa);
VALUE rb_ary_hidden_new(rb_len_t capa);
#define rb_ary_tmp_new rb_ary_hidden_new
/**
@@ -211,7 +211,7 @@ VALUE rb_ary_aref(int argc, const VALUE *argv, VALUE ary);
* @note Return array can be shorter than `len` when for instance
* `[0, 1, 2, 3]`'s 4th to 1,000,000,000th is requested.
*/
VALUE rb_ary_subseq(VALUE ary, long beg, long len);
VALUE rb_ary_subseq(VALUE ary, rb_len_t beg, rb_len_t len);
/**
* Destructively stores the passed value to the passed array's passed index.
@@ -228,7 +228,7 @@ VALUE rb_ary_subseq(VALUE ary, long beg, long len);
* can also create a series of "hole" positions inside of the
* backend storage. They are filled with ::RUBY_Qnil.
*/
void rb_ary_store(VALUE ary, long key, VALUE val);
void rb_ary_store(VALUE ary, rb_len_t key, VALUE val);
/**
* Duplicates an array.
@@ -288,7 +288,7 @@ VALUE rb_ary_to_s(VALUE ary);
* @return The passed `ary`.
* @post `ary` has contents from `train` appended at its end.
*/
VALUE rb_ary_cat(VALUE ary, const VALUE *train, long len);
VALUE rb_ary_cat(VALUE ary, const VALUE *train, rb_len_t len);
/**
* Special case of rb_ary_cat() that it adds only one element.
@@ -356,7 +356,7 @@ RBIMPL_ATTR_PURE()
* what is stored at `off`-th position of `ary`.
* @note `ary`'s `off`-th element can happen to be ::RUBY_Qnil.
*/
VALUE rb_ary_entry(VALUE ary, long off);
VALUE rb_ary_entry(VALUE ary, rb_len_t off);
/**
* Iteratively yields each element of the passed array to the implicitly passed
@@ -407,7 +407,7 @@ VALUE rb_ary_reverse(VALUE ary);
* @retval ary Rotated.
* @post `ary` is rotated.
*/
VALUE rb_ary_rotate(VALUE ary, long rot);
VALUE rb_ary_rotate(VALUE ary, rb_len_t rot);
/**
* Creates a copy of the passed array, whose elements are sorted according to
@@ -472,7 +472,7 @@ VALUE rb_ary_delete(VALUE ary, VALUE elem);
* @note There is no way to distinguish whether `pos` is out of bound,
* or `pos` did exist but stored ::RUBY_Qnil as an ordinal value.
*/
VALUE rb_ary_delete_at(VALUE ary, long pos);
VALUE rb_ary_delete_at(VALUE ary, rb_len_t pos);
/**
* Destructively removes everything form an array.
@@ -633,7 +633,7 @@ VALUE rb_ary_replace(VALUE copy, VALUE orig);
* `Array#values_at` no longer uses this function. There is no reason apart
* from historical ones to list this function here.
*/
VALUE rb_get_values_at(VALUE obj, long olen, int argc, const VALUE *argv, VALUE (*func)(VALUE obj, long oidx));
VALUE rb_get_values_at(VALUE obj, rb_len_t olen, int argc, const VALUE *argv, VALUE (*func)(VALUE obj, rb_len_t oidx));
/**
* Expands or shrinks the passed array to the passed length.
@@ -652,7 +652,7 @@ VALUE rb_get_values_at(VALUE obj, long olen, int argc, const VALUE *argv, VALUE
*
* `len` is signed. Intentional or...?
*/
VALUE rb_ary_resize(VALUE ary, long len);
VALUE rb_ary_resize(VALUE ary, rb_len_t len);
#define rb_ary_new2 rb_ary_new_capa /**< @old{rb_ary_new_capa} */
#define rb_ary_new3 rb_ary_new_from_args /**< @old{rb_ary_new_from_args} */
+2 -2
View File
@@ -136,7 +136,7 @@ RBIMPL_ATTR_NONNULL(())
* - `0`: returns ::RUBY_Qnil.
* - `1`: raises ::rb_eRangeError.
* - `2`: `beg` and `len` expanded accordingly.
* @exception rb_eRangeError `as` cannot fit into `long`.
* @exception rb_eRangeError `as` cannot fit into ::rb_len_t.
* @retval RUBY_Qfalse `as` is not `Enumerator::ArithmericSequence`.
* @retval RUBY_Qnil `len` is out of `as` but `err` is zero.
* @retval RUBY_Qtrue Otherwise.
@@ -148,7 +148,7 @@ RBIMPL_ATTR_NONNULL(())
* Currently no 3rd party applications of this function is found. But that can
* be because this function is relatively new.
*/
VALUE rb_arithmetic_sequence_beg_len_step(VALUE as, long *begp, long *lenp, long *stepp, long len, int err);
VALUE rb_arithmetic_sequence_beg_len_step(VALUE as, rb_len_t *begp, rb_len_t *lenp, rb_len_t *stepp, rb_len_t len, int err);
RBIMPL_SYMBOL_EXPORT_END()
+1 -1
View File
@@ -63,7 +63,7 @@ RBIMPL_SYMBOL_EXPORT_BEGIN()
* This function works for non-exception classes as well, as long as they take
* one string argument.
*/
VALUE rb_exc_new(VALUE etype, const char *ptr, long len);
VALUE rb_exc_new(VALUE etype, const char *ptr, rb_len_t len);
RBIMPL_ATTR_NONNULL(())
/**
+2 -2
View File
@@ -115,7 +115,7 @@ VALUE rb_hash_new(void);
* @param[in] capa Designed capacity of the hash.
* @return An empty Hash, whose capacity is `capa`.
*/
VALUE rb_hash_new_capa(long capa);
VALUE rb_hash_new_capa(rb_len_t capa);
/**
* Duplicates a hash.
@@ -256,7 +256,7 @@ VALUE rb_hash_delete(VALUE hash, VALUE key);
* accept the newest (rightmost) one. This behaviour also mimics repeated call
* of rb_hash_aset().
*/
void rb_hash_bulk_insert(long argc, const VALUE *argv, VALUE hash);
void rb_hash_bulk_insert(rb_len_t argc, const VALUE *argv, VALUE hash);
/**
* Type of callback functions to pass to rb_hash_update_by().
+1 -1
View File
@@ -504,7 +504,7 @@ void rb_write_error(const char *str);
* @param[in] len Length of `str`, in bytes.
* @post `str` is written to somewhere.
*/
void rb_write_error2(const char *str, long len);
void rb_write_error2(const char *str, rb_len_t len);
/**
* Closes everything. In case of POSIX environments, a child process inherits
+1 -1
View File
@@ -70,7 +70,7 @@ void rb_reset_random_seed(void);
* The arguments are just silently ignored and the default RNG is used instead,
* if they are non-RNG.
*/
VALUE rb_random_bytes(VALUE rnd, long n);
VALUE rb_random_bytes(VALUE rnd, rb_len_t n);
/**
* Identical to rb_genrand_int32(), except it generates using the passed RNG.
+4 -4
View File
@@ -42,8 +42,8 @@ VALUE rb_range_new(VALUE beg, VALUE end, int excl);
RBIMPL_ATTR_NONNULL(())
/**
* Deconstructs a numerical range. As the arguments are `long` based, it
* expects everything are in the `long` domain.
* Deconstructs a numerical range. As the arguments are ::rb_len_t based, it
* expects everything are in the ::rb_len_t domain.
*
* @param[in] range A range of numerical endpoints.
* @param[out] begp Return value buffer.
@@ -54,7 +54,7 @@ RBIMPL_ATTR_NONNULL(())
* - `1`: raises ::rb_eRangeError.
* - `2`: `beg` and `len` expanded accordingly.
* @exception rb_eTypeError `range` is not a numerical range.
* @exception rb_eRangeError `range` cannot fit into `long`.
* @exception rb_eRangeError `range` cannot fit into ::rb_len_t.
* @retval RUBY_Qfalse `range` is not an ::rb_cRange.
* @retval RUBY_Qnil `len` is out of `range` but `err` is zero.
* @retval RUBY_Qtrue Otherwise.
@@ -66,7 +66,7 @@ RBIMPL_ATTR_NONNULL(())
* The complex error handling switch reflects the fact that `Array#[]=` and
* `String#[]=` behave differently when they take ranges.
*/
VALUE rb_range_beg_len(VALUE range, long *begp, long *lenp, long len, int err);
VALUE rb_range_beg_len(VALUE range, rb_len_t *begp, rb_len_t *lenp, rb_len_t len, int err);
RBIMPL_ATTR_NONNULL(())
/**
+2 -2
View File
@@ -57,7 +57,7 @@ RBIMPL_SYMBOL_EXPORT_BEGIN()
*
* Can accept NULLs as long as n is also 0, and returns 0.
*/
int rb_memcicmp(const void *s1,const void *s2, long n);
int rb_memcicmp(const void *s1,const void *s2, rb_len_t n);
/**
* Asserts that the given MatchData is "occupied". MatchData shares its
@@ -176,7 +176,7 @@ RBIMPL_ATTR_NONNULL(())
* @param[in] opts Options e.g. ONIG_OPTION_MULTILINE.
* @return Allocated new instance of ::rb_cRegexp.
*/
VALUE rb_reg_new(const char *src, long len, int opts);
VALUE rb_reg_new(const char *src, rb_len_t len, int opts);
/**
* Allocates an instance of ::rb_cRegexp.
+39 -39
View File
@@ -60,7 +60,7 @@ RBIMPL_SYMBOL_EXPORT_BEGIN()
* @pre At least `len` bytes of continuous memory region shall be
* accessible via `ptr`.
*/
VALUE rb_str_new(const char *ptr, long len);
VALUE rb_str_new(const char *ptr, rb_len_t len);
/**
* Identical to rb_str_new(), except it assumes the passed pointer is a pointer
@@ -120,7 +120,7 @@ VALUE rb_str_new_frozen(VALUE str);
*
* Why it doesn't take an instance of ::rb_cClass?
*/
VALUE rb_str_new_with_class(VALUE obj, const char *ptr, long len);
VALUE rb_str_new_with_class(VALUE obj, const char *ptr, rb_len_t len);
/**
* Identical to rb_str_new(), except it generates a string of "default
@@ -140,7 +140,7 @@ VALUE rb_str_new_with_class(VALUE obj, const char *ptr, long len);
* a corrupted output. You can know the failure by querying
* `valid_encoding?` of the result object.
*/
VALUE rb_external_str_new(const char *ptr, long len);
VALUE rb_external_str_new(const char *ptr, rb_len_t len);
RBIMPL_ATTR_NONNULL(())
/**
@@ -183,7 +183,7 @@ VALUE rb_external_str_new_cstr(const char *ptr);
* a corrupted output. You can know the failure by querying
* `valid_encoding?` of the result object.
*/
VALUE rb_locale_str_new(const char *ptr, long len);
VALUE rb_locale_str_new(const char *ptr, rb_len_t len);
RBIMPL_ATTR_NONNULL(())
/**
@@ -226,7 +226,7 @@ VALUE rb_locale_str_new_cstr(const char *ptr);
* a corrupted output. You can know the failure by querying
* `valid_encoding?` of the result object.
*/
VALUE rb_filesystem_str_new(const char *ptr, long len);
VALUE rb_filesystem_str_new(const char *ptr, rb_len_t len);
RBIMPL_ATTR_NONNULL(())
/**
@@ -258,7 +258,7 @@ VALUE rb_filesystem_str_new_cstr(const char *ptr);
* @param[in] capa Designed capacity of the generating string.
* @return An empty string, of "binary" encoding, whose capacity is `capa`.
*/
VALUE rb_str_buf_new(long capa);
VALUE rb_str_buf_new(rb_len_t capa);
RBIMPL_ATTR_NONNULL(())
/**
@@ -285,7 +285,7 @@ VALUE rb_str_buf_new_cstr(const char *ptr);
* @return A hidden, empty string.
* @see rb_obj_hide()
*/
VALUE rb_str_tmp_new(long len);
VALUE rb_str_tmp_new(rb_len_t len);
/**
* Creates a frozen copy of `orig` that guarantees the RSTRING_PTR is safe to
@@ -324,7 +324,7 @@ void rb_str_no_gvl_safe_release(VALUE orig, VALUE tmp);
* @return An instance of ::rb_cString, of `len` bytes length, of
* "US ASCII" encoding, whose contents are verbatim copy of `ptr`.
*/
VALUE rb_usascii_str_new(const char *ptr, long len);
VALUE rb_usascii_str_new(const char *ptr, rb_len_t len);
/**
* Identical to rb_str_new_cstr(), except it generates a string of "US ASCII"
@@ -352,7 +352,7 @@ VALUE rb_usascii_str_new_cstr(const char *ptr);
* @return An instance of ::rb_cString, of `len` bytes length, of
* "UTF-8" encoding, whose contents are verbatim copy of `ptr`.
*/
VALUE rb_utf8_str_new(const char *ptr, long len);
VALUE rb_utf8_str_new(const char *ptr, rb_len_t len);
/**
* Identical to rb_str_new_cstr(), except it generates a string of "UTF-8"
@@ -396,7 +396,7 @@ VALUE rb_utf8_str_new_cstr(const char *ptr);
*
* Surprisingly it can take NULL, and generates an empty string.
*/
VALUE rb_str_new_static(const char *ptr, long len);
VALUE rb_str_new_static(const char *ptr, rb_len_t len);
/**
* Identical to rb_str_new_static(), except it generates a string of "US ASCII"
@@ -413,7 +413,7 @@ VALUE rb_str_new_static(const char *ptr, long len);
* immediate SEGV shall occur). Consider return values of this
* function be read-only.
*/
VALUE rb_usascii_str_new_static(const char *ptr, long len);
VALUE rb_usascii_str_new_static(const char *ptr, rb_len_t len);
/**
* Identical to rb_str_new_static(), except it generates a string of "UTF-8"
@@ -430,7 +430,7 @@ VALUE rb_usascii_str_new_static(const char *ptr, long len);
* immediate SEGV shall occur). Consider return values of this
* function be read-only.
*/
VALUE rb_utf8_str_new_static(const char *ptr, long len);
VALUE rb_utf8_str_new_static(const char *ptr, rb_len_t len);
/** @} */
@@ -474,7 +474,7 @@ VALUE rb_str_to_interned_str(VALUE str);
* @pre At least `len` bytes of continuous memory region shall be
* accessible via `ptr`.
*/
VALUE rb_interned_str(const char *ptr, long len);
VALUE rb_interned_str(const char *ptr, rb_len_t len);
RBIMPL_ATTR_NONNULL(())
/**
@@ -546,7 +546,7 @@ void rb_str_shared_replace(VALUE dst, VALUE src);
VALUE rb_str_buf_append(VALUE dst, VALUE src);
/** @alias{rb_str_cat} */
VALUE rb_str_buf_cat(VALUE, const char*, long);
VALUE rb_str_buf_cat(VALUE, const char*, rb_len_t);
/** @alias{rb_str_cat_cstr} */
VALUE rb_str_buf_cat2(VALUE, const char*);
@@ -694,7 +694,7 @@ VALUE rb_str_times(VALUE str, VALUE num);
* @param[in] pos Offset, in bytes.
* @return Offset, in characters.
*/
long rb_str_sublen(VALUE str, long pos);
rb_len_t rb_str_sublen(VALUE str, rb_len_t pos);
/**
* This is the implementation of two-argumented `String#slice`.
@@ -746,7 +746,7 @@ long rb_str_sublen(VALUE str, long pos);
* substring of `str`.
* @pre `str` must not be any arbitrary objects except ::RString.
*/
VALUE rb_str_substr(VALUE str, long beg, long len);
VALUE rb_str_substr(VALUE str, rb_len_t beg, rb_len_t len);
/**
* Identical to rb_str_substr(), except the numbers are interpreted as byte
@@ -759,7 +759,7 @@ VALUE rb_str_substr(VALUE str, long beg, long len);
* @pre `str` must not be any arbitrary objects except ::RString.
* @pre `beg` and `len` must not point to OOB contents.
*/
VALUE rb_str_subseq(VALUE str, long beg, long len);
VALUE rb_str_subseq(VALUE str, rb_len_t beg, rb_len_t len);
/**
* Identical to rb_str_substr(), except it returns a C's string instead of
@@ -774,7 +774,7 @@ VALUE rb_str_subseq(VALUE str, long beg, long len);
* @pre `str` must not be any arbitrary objects except ::RString.
* @post `len` is updated to have the length of the return value.
*/
char *rb_str_subpos(VALUE str, long beg, long *len);
char *rb_str_subpos(VALUE str, rb_len_t beg, rb_len_t *len);
/**
* Declares that the string is about to be modified. This for instance let the
@@ -802,7 +802,7 @@ void rb_str_modify(VALUE str);
* @post Upon successful return the passed string is modified so that
* its capacity is increased for `capa` bytes.
*/
void rb_str_modify_expand(VALUE str, long capa);
void rb_str_modify_expand(VALUE str, rb_len_t capa);
/**
* This is the implementation of `String#freeze`.
@@ -836,7 +836,7 @@ VALUE rb_str_freeze(VALUE str);
* @pre `str` must not be any arbitrary objects except ::RString.
* @post Upon successful return `str`'s length is set to `len`.
*/
void rb_str_set_len(VALUE str, long len);
void rb_str_set_len(VALUE str, rb_len_t len);
/**
* Overwrites the length of the string. In contrast to rb_str_set_len(), this
@@ -852,7 +852,7 @@ void rb_str_set_len(VALUE str, long len);
* @post Upon successful return `str` is either expanded or shrunken to
* have its length be `len`.
*/
VALUE rb_str_resize(VALUE str, long len);
VALUE rb_str_resize(VALUE str, rb_len_t len);
/**
* Destructively appends the passed contents to the string.
@@ -865,7 +865,7 @@ VALUE rb_str_resize(VALUE str, long len);
* @pre `dst` must not be any arbitrary objects except ::RString.
* @post `dst` has the contents of `ptr` appended.
*/
VALUE rb_str_cat(VALUE dst, const char *src, long srclen);
VALUE rb_str_cat(VALUE dst, const char *src, rb_len_t srclen);
/**
* Identical to rb_str_cat(), except it assumes the passed pointer is a pointer
@@ -930,7 +930,7 @@ VALUE rb_str_concat(VALUE dst, VALUE src);
* Cryptology in India (INDOCRYPT 2012), LNCS 7668, pp. 489-508,
* 2012. http://doi.org/10.1007/978-3-642-34931-7_28
*/
st_index_t rb_memhash(const void *ptr, long len);
st_index_t rb_memhash(const void *ptr, rb_len_t len);
/**
* Starts a series of hashing. Suppose you have a struct:
@@ -1070,7 +1070,7 @@ VALUE rb_str_equal(VALUE str1, VALUE str2);
*
* What if `len` is negative?
*/
VALUE rb_str_drop_bytes(VALUE str, long len);
VALUE rb_str_drop_bytes(VALUE str, rb_len_t len);
/**
* Replaces some (or all) of the contents of the given string. This is the
@@ -1090,7 +1090,7 @@ VALUE rb_str_drop_bytes(VALUE str, long len);
* same length as the portion it is replacing, `dst` will be
* resized accordingly.
*/
void rb_str_update(VALUE dst, long beg, long len, VALUE src);
void rb_str_update(VALUE dst, rb_len_t beg, rb_len_t len, VALUE src);
/**
* Replaces the contents of the former object with the stringised contents of
@@ -1211,7 +1211,7 @@ VALUE rb_sym_to_s(VALUE sym);
* @param[in] str Target string to query.
* @return Its number of characters.
*/
long rb_str_strlen(VALUE str);
rb_len_t rb_str_strlen(VALUE str);
/**
* Identical to rb_str_strlen(), except it returns the value in ::rb_cInteger.
@@ -1230,7 +1230,7 @@ VALUE rb_str_length(VALUE);
* @param[in] pos Offset, in characters.
* @return Offset, in bytes.
*/
long rb_str_offset(VALUE str, long pos);
rb_len_t rb_str_offset(VALUE str, rb_len_t pos);
RBIMPL_ATTR_PURE()
/**
@@ -1256,7 +1256,7 @@ size_t rb_str_capacity(VALUE str);
* @retval otherwise A new, shortened string.
* @note The length is counted in characters.
*/
VALUE rb_str_ellipsize(VALUE str, long len);
VALUE rb_str_ellipsize(VALUE str, rb_len_t len);
/**
* "Cleanses" the string. A string has its encoding and its contents. They,
@@ -1368,12 +1368,12 @@ RBIMPL_ATTR_NONNULL(())
* This is an implementation detail. Don't bother.
*
* @param[in] str A C string.
* @return `strlen`, casted to `long`.
* @return `strlen`, casted to ::rb_len_t.
*/
static inline long
static inline rb_len_t
rbimpl_strlen(const char *str)
{
return RBIMPL_CAST((long)strlen(str));
return RBIMPL_CAST((rb_len_t)strlen(str));
}
RBIMPL_ATTR_NONNULL(())
@@ -1388,7 +1388,7 @@ RBIMPL_ATTR_NONNULL(())
static inline VALUE
rbimpl_str_new_cstr(const char *str)
{
long len = rbimpl_strlen(str);
rb_len_t len = rbimpl_strlen(str);
return rb_str_new_static(str, len);
}
@@ -1404,7 +1404,7 @@ RBIMPL_ATTR_NONNULL(())
static inline VALUE
rbimpl_usascii_str_new_cstr(const char *str)
{
long len = rbimpl_strlen(str);
rb_len_t len = rbimpl_strlen(str);
return rb_usascii_str_new_static(str, len);
}
@@ -1420,7 +1420,7 @@ RBIMPL_ATTR_NONNULL(())
static inline VALUE
rbimpl_utf8_str_new_cstr(const char *str)
{
long len = rbimpl_strlen(str);
rb_len_t len = rbimpl_strlen(str);
return rb_utf8_str_new_static(str, len);
}
@@ -1436,7 +1436,7 @@ RBIMPL_ATTR_NONNULL(())
static inline VALUE
rbimpl_external_str_new_cstr(const char *str)
{
long len = rbimpl_strlen(str);
rb_len_t len = rbimpl_strlen(str);
return rb_external_str_new(str, len);
}
@@ -1452,7 +1452,7 @@ RBIMPL_ATTR_NONNULL(())
static inline VALUE
rbimpl_locale_str_new_cstr(const char *str)
{
long len = rbimpl_strlen(str);
rb_len_t len = rbimpl_strlen(str);
return rb_locale_str_new(str, len);
}
@@ -1468,7 +1468,7 @@ RBIMPL_ATTR_NONNULL(())
static inline VALUE
rbimpl_str_buf_new_cstr(const char *str)
{
long len = rbimpl_strlen(str);
rb_len_t len = rbimpl_strlen(str);
VALUE buf = rb_str_buf_new(len);
return rb_str_buf_cat(buf, str, len);
}
@@ -1486,7 +1486,7 @@ RBIMPL_ATTR_NONNULL(())
static inline VALUE
rbimpl_str_cat_cstr(VALUE buf, const char *str)
{
long len = rbimpl_strlen(str);
rb_len_t len = rbimpl_strlen(str);
return rb_str_cat(buf, str, len);
}
@@ -1503,7 +1503,7 @@ RBIMPL_ATTR_NONNULL(())
static inline VALUE
rbimpl_exc_new_cstr(VALUE exc, const char *str)
{
long len = rbimpl_strlen(str);
rb_len_t len = rbimpl_strlen(str);
return rb_exc_new(exc, str, len);
}
+3 -3
View File
@@ -438,7 +438,7 @@ RBIMPL_ATTR_NONNULL(())
* @return Allocated `len` bytes array.
* @post `store` holds the corresponding tmp buffer object.
*/
void *rb_alloc_tmp_buffer(volatile VALUE *store, long len, bool mark);
void *rb_alloc_tmp_buffer(volatile VALUE *store, rb_len_t len, bool mark);
/**
* @private
@@ -715,10 +715,10 @@ rbimpl_size_add_or_raise(size_t x, size_t y)
* We might want to deprecate this function and make a `rbimpl_` counterpart.
*/
static inline void *
rb_alloc_tmp_buffer2(volatile VALUE *store, long count, size_t elsize)
rb_alloc_tmp_buffer2(volatile VALUE *store, rb_len_t count, size_t elsize)
{
const size_t total_size = rbimpl_size_mul_or_raise(RBIMPL_CAST((size_t)count), elsize);
return rb_alloc_tmp_buffer(store, (long)total_size, elsize >= sizeof(VALUE));
return rb_alloc_tmp_buffer(store, (rb_len_t)total_size, elsize >= sizeof(VALUE));
}
RBIMPL_SYMBOL_EXPORT_BEGIN()
+2 -2
View File
@@ -98,7 +98,7 @@ ID rb_intern(const char *name);
* is up to you to avoid memory leaks. Think twice before using
* it.
*/
ID rb_intern2(const char *name, long len);
ID rb_intern2(const char *name, rb_len_t len);
/**
* Identical to rb_intern(), except it takes a `T_STRING` object.
@@ -285,7 +285,7 @@ static inline ID
rb_intern_const(const char *str)
{
size_t len = strlen(str);
return rb_intern2(str, RBIMPL_CAST((long)len));
return rb_intern2(str, RBIMPL_CAST((rb_len_t)len));
}
RBIMPL_ATTR_NOALIAS()
+2 -2
View File
@@ -59,7 +59,7 @@ VALUE rb_reg_regcomp(VALUE str);
* Distinction between raising ::rb_eArgError and ::rb_eRegexpError is not
* obvious, at least to @shyouhei.
*/
long rb_reg_search(VALUE re, VALUE str, long pos, int dir);
rb_len_t rb_reg_search(VALUE re, VALUE str, rb_len_t pos, int dir);
/**
* Substitution. This is basically the implementation of `String#sub`. Also
@@ -94,7 +94,7 @@ VALUE rb_reg_regsub(VALUE repl, VALUE src, struct re_registers *regs, VALUE rexp
* character boundary.
*
*/
long rb_reg_adjust_startpos(VALUE re, VALUE str, long pos, int dir);
rb_len_t rb_reg_adjust_startpos(VALUE re, VALUE str, rb_len_t pos, int dir);
/**
* Escapes any characters that would have special meaning in a regular
+1 -1
View File
@@ -89,7 +89,7 @@ int rb_hash_stlike_delete(VALUE hash, st_data_t *pkey, st_data_t *pval);
int rb_hash_stlike_update(VALUE hash, st_data_t key, st_update_callback_func *func, st_data_t arg);
bool rb_hash_default_unredefined(VALUE hash);
VALUE rb_hash_alloc_fixed_size(VALUE klass, st_index_t size);
VALUE rb_ident_hash_new_capa(long size);
VALUE rb_ident_hash_new_capa(rb_len_t size);
void rb_hash_free(VALUE hash);
VALUE rb_hash_alloc_copy(VALUE klass, VALUE src);
RUBY_EXTERN VALUE rb_cHash_empty_frozen;
+1 -1
View File
@@ -41,6 +41,6 @@ RANGE_EXCL(VALUE r)
VALUE
rb_range_component_beg_len(VALUE b, VALUE e, int excl,
long *begp, long *lenp, long len, int err);
rb_len_t *begp, rb_len_t *lenp, rb_len_t len, int err);
#endif /* INTERNAL_RANGE_H */
+1 -1
View File
@@ -27,6 +27,6 @@ typedef int st_foreach_with_hash_callback_func(st_data_t, st_data_t, st_data_t,
int rb_st_foreach_with_hash(st_table *, st_foreach_with_hash_callback_func *, st_data_t);
#define st_foreach_with_hash rb_st_foreach_with_hash
void rb_hash_bulk_insert_into_st_table(long, const VALUE *, VALUE);
void rb_hash_bulk_insert_into_st_table(rb_len_t, const VALUE *, VALUE);
#endif
+1 -1
View File
@@ -9402,7 +9402,7 @@ rb_stderr_to_original_p(VALUE err)
}
void
rb_write_error2(const char *mesg, long len)
rb_write_error2(const char *mesg, rb_len_t len)
{
VALUE out = rb_ractor_stderr();
if (rb_stderr_to_original_p(out)) {
+1 -1
View File
@@ -1932,7 +1932,7 @@ r_object0(struct load_arg *arg, bool partial, int *ivp, VALUE extmod)
static VALUE
r_object_for(struct load_arg *arg, bool partial, int *ivp, VALUE klass, VALUE extmod, int type)
{
VALUE (*hash_new_capa)(long) = rb_hash_new_capa;
VALUE (*hash_new_capa)(rb_len_t) = rb_hash_new_capa;
VALUE v = Qnil;
long id;
st_data_t link;
+3 -3
View File
@@ -296,7 +296,7 @@ static VALUE
path_sub_ext(VALUE self, VALUE repl)
{
VALUE path = get_strpath(self);
long len = RSTRING_LEN(path);
rb_len_t len = RSTRING_LEN(path);
const char *ptr = RSTRING_PTR(path);
const char *ext = ruby_enc_find_extname(ptr, &len, rb_enc_get(path));
if (len > 0) {
@@ -316,7 +316,7 @@ path_sub_ext(VALUE self, VALUE repl)
static VALUE
chop_basename(VALUE self, VALUE path)
{
long baselen, alllen = RSTRING_LEN(check_strpath(path));
rb_len_t baselen, alllen = RSTRING_LEN(check_strpath(path));
if (alllen <= 0) return Qnil;
rb_encoding *enc = rb_enc_get(path);
const char *name = RSTRING_PTR(path);
@@ -356,7 +356,7 @@ split_names(VALUE self, VALUE path)
static VALUE
has_trailing_separator(VALUE self, VALUE path)
{
long baselen, alllen = RSTRING_LEN(check_strpath(path));
rb_len_t baselen, alllen = RSTRING_LEN(check_strpath(path));
if (alllen <= 0) return Qfalse;
rb_encoding *enc = rb_enc_get(path);
const char *name = RSTRING_PTR(path);
+2 -2
View File
@@ -1262,7 +1262,7 @@ rb_rand_bytes_int32(rb_random_get_int32_func *get_int32,
}
VALUE
rb_random_bytes(VALUE obj, long n)
rb_random_bytes(VALUE obj, rb_len_t n)
{
const rb_random_interface_t *rng;
rb_random_t *rnd = try_get_rnd(obj, &rng);
@@ -1717,7 +1717,7 @@ rb_hash_start(st_index_t h)
}
st_index_t
rb_memhash(const void *ptr, long len)
rb_memhash(const void *ptr, rb_len_t len)
{
sip_uint64_t h = sip_hash13(hash_salt.key.sip, ptr, len);
#if SIZEOF_ST_INDEX_T >= 8
+2 -2
View File
@@ -1907,7 +1907,7 @@ rb_range_values(VALUE range, VALUE *begp, VALUE *endp, int *exclp)
*/
VALUE
rb_range_component_beg_len(VALUE b, VALUE e, int excl,
long *begp, long *lenp, long len, int err)
rb_len_t *begp, rb_len_t *lenp, rb_len_t len, int err)
{
long beg, end;
@@ -1942,7 +1942,7 @@ rb_range_component_beg_len(VALUE b, VALUE e, int excl,
}
VALUE
rb_range_beg_len(VALUE range, long *begp, long *lenp, long len, int err)
rb_range_beg_len(VALUE range, rb_len_t *begp, rb_len_t *lenp, rb_len_t len, int err)
{
VALUE b, e;
int excl;
+11 -11
View File
@@ -125,7 +125,7 @@ static const char casetable[] = {
rb_hrtime_t rb_reg_match_time_limit = 0;
int
rb_memcicmp(const void *x, const void *y, long len)
rb_memcicmp(const void *x, const void *y, rb_len_t len)
{
const unsigned char *p1 = x, *p2 = y;
int tmp;
@@ -281,8 +281,8 @@ rb_memsearch_qchar(const unsigned char *xs, long m, const unsigned char *ys, lon
return rb_memsearch_with_char_size(xs, m, ys, n, 4);
}
long
rb_memsearch(const void *x0, long m, const void *y0, long n, rb_encoding *enc)
rb_len_t
rb_memsearch(const void *x0, rb_len_t m, const void *y0, rb_len_t n, rb_encoding *enc)
{
const unsigned char *x = x0, *y = y0;
@@ -1873,8 +1873,8 @@ rb_reg_onig_match(VALUE re, VALUE str,
return result;
}
long
rb_reg_adjust_startpos(VALUE re, VALUE str, long pos, int reverse)
rb_len_t
rb_reg_adjust_startpos(VALUE re, VALUE str, rb_len_t pos, int reverse)
{
long range;
rb_encoding *enc;
@@ -1996,8 +1996,8 @@ rb_reg_search0(VALUE re, VALUE str, long pos, int reverse, int set_backref_str,
return rb_reg_search_set_match(re, str, pos, reverse, set_backref_str, match);
}
long
rb_reg_search(VALUE re, VALUE str, long pos, int reverse)
rb_len_t
rb_reg_search(VALUE re, VALUE str, rb_len_t pos, int reverse)
{
return rb_reg_search_set_match(re, str, pos, reverse, 1, NULL);
}
@@ -2362,7 +2362,7 @@ match_ary_subseq(VALUE match, long beg, long len, VALUE result)
static VALUE
match_ary_aref(VALUE match, VALUE idx, VALUE result)
{
long beg, len;
rb_len_t beg, len;
int num_regs = RMATCH_NREGS(match);
/* check if idx is Range */
@@ -3636,7 +3636,7 @@ rb_reg_new_from_values(long cnt, const VALUE *elements, int opt)
}
VALUE
rb_enc_reg_new(const char *s, long len, rb_encoding *enc, int options)
rb_enc_reg_new(const char *s, rb_len_t len, rb_encoding *enc, int options)
{
VALUE re = rb_reg_alloc();
onig_errmsg_buffer err = "";
@@ -3650,7 +3650,7 @@ rb_enc_reg_new(const char *s, long len, rb_encoding *enc, int options)
}
VALUE
rb_reg_new(const char *s, long len, int options)
rb_reg_new(const char *s, rb_len_t len, int options)
{
return rb_enc_reg_new(s, len, rb_ascii8bit_encoding(), options);
}
@@ -4140,7 +4140,7 @@ rb_reg_match_p(VALUE re, VALUE str, long pos)
if (pos < 0) return Qfalse;
}
if (pos > 0) {
long len = 1;
rb_len_t len = 1;
const char *beg = rb_str_subpos(str, pos, &len);
if (!beg) return Qfalse;
pos = beg - RSTRING_PTR(str);
+4 -4
View File
@@ -79,7 +79,7 @@ is_notop_id2(ID id)
}
static VALUE
enc_str_new(const char *ptr, long len, parser_encoding *enc)
enc_str_new(const char *ptr, rb_len_t len, parser_encoding *enc)
{
return rb_enc_str_new(ptr, len, enc);
}
@@ -169,13 +169,13 @@ enc_isspace(OnigCodePoint c, parser_encoding *enc)
}
static ID
intern3(const char *name, long len, parser_encoding *enc)
intern3(const char *name, rb_len_t len, parser_encoding *enc)
{
return rb_intern3(name, len, enc);
}
static int
enc_symname_type(const char *name, long len, parser_encoding *enc, unsigned int allowed_attrset)
enc_symname_type(const char *name, rb_len_t len, parser_encoding *enc, unsigned int allowed_attrset)
{
return rb_enc_symname_type(name, len, enc, allowed_attrset);
}
@@ -285,7 +285,7 @@ static_id2sym(ID id)
return (((VALUE)(id)<<RUBY_SPECIAL_SHIFT)|SYMBOL_FLAG);
}
static long
static rb_len_t
str_coderange_scan_restartable(const char *s, const char *e, parser_encoding *enc, int *cr)
{
return rb_str_coderange_scan_restartable(s, e, enc, cr);
+10 -10
View File
@@ -1235,7 +1235,7 @@ typedef struct rb_parser_config_struct {
VALUE (*attr_get)(VALUE obj, ID id);
/* Array */
VALUE (*ary_new_from_args)(long n, ...);
VALUE (*ary_new_from_args)(rb_len_t n, ...);
VALUE (*ary_unshift)(VALUE ary, VALUE item);
/* Symbol */
@@ -1246,11 +1246,11 @@ typedef struct rb_parser_config_struct {
int (*id_type)(ID id);
ID (*id_attrset)(ID);
ID (*intern)(const char *name);
ID (*intern2)(const char *name, long len);
ID (*intern3)(const char *name, long len, rb_encoding *enc);
ID (*intern2)(const char *name, rb_len_t len);
ID (*intern3)(const char *name, rb_len_t len, rb_encoding *enc);
ID (*intern_str)(VALUE str);
int (*is_notop_id)(ID);
int (*enc_symname_type)(const char *name, long len, rb_encoding *enc, unsigned int allowed_attrset);
int (*enc_symname_type)(const char *name, rb_len_t len, rb_encoding *enc, unsigned int allowed_attrset);
const char *(*id2name)(ID id);
VALUE (*id2str)(ID id);
VALUE (*id2sym)(ID x);
@@ -1259,17 +1259,17 @@ typedef struct rb_parser_config_struct {
RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 2, 3)
VALUE (*str_catf)(VALUE str, const char *format, ...);
VALUE (*str_cat_cstr)(VALUE str, const char *ptr);
VALUE (*str_resize)(VALUE str, long len);
VALUE (*str_new)(const char *ptr, long len);
VALUE (*str_resize)(VALUE str, rb_len_t len);
VALUE (*str_new)(const char *ptr, rb_len_t len);
VALUE (*str_new_cstr)(const char *ptr);
VALUE (*str_to_interned_str)(VALUE);
VALUE (*enc_str_new)(const char *ptr, long len, rb_encoding *enc);
VALUE (*enc_str_new)(const char *ptr, rb_len_t len, rb_encoding *enc);
RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 2, 0)
VALUE (*str_vcatf)(VALUE str, const char *fmt, va_list ap);
RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 1, 2)
VALUE (*rb_sprintf)(const char *format, ...);
char *(*rstring_ptr)(VALUE str);
long (*rstring_len)(VALUE str);
rb_len_t (*rstring_len)(VALUE str);
/* Numeric */
VALUE (*int2num)(int v);
@@ -1333,7 +1333,7 @@ typedef struct rb_parser_config_struct {
/* Re */
VALUE (*reg_compile)(VALUE str, int options, const char *sourcefile, int sourceline);
VALUE (*reg_check_preprocess)(VALUE str);
int (*memcicmp)(const void *x, const void *y, long len);
int (*memcicmp)(const void *x, const void *y, rb_len_t len);
/* Error */
void (*compile_warn)(const char *file, int line, const char *fmt, ...) RUBYPARSER_ATTRIBUTE_FORMAT(3, 4);
@@ -1364,7 +1364,7 @@ typedef struct rb_parser_config_struct {
int enc_coderange_7bit;
int enc_coderange_unknown;
VALUE (*static_id2sym)(ID id);
long (*str_coderange_scan_restartable)(const char *s, const char *e, rb_encoding *enc, int *cr);
rb_len_t (*str_coderange_scan_restartable)(const char *s, const char *e, rb_encoding *enc, int *cr);
/* Source hash */
void (*source_hash_init)(rb_source_hash_state_t *state);
+5 -5
View File
@@ -26,8 +26,8 @@ VALUE range_spec_rb_range_values(VALUE self, VALUE range) {
}
VALUE range_spec_rb_range_beg_len(VALUE self, VALUE range, VALUE lenv, VALUE errv) {
long begp = 0;
long lenp = 0;
rb_len_t begp = 0;
rb_len_t lenp = 0;
long len = FIX2LONG(lenv);
int err = FIX2INT(errv);
VALUE ary = rb_ary_new();
@@ -58,9 +58,9 @@ VALUE range_spec_rb_arithmetic_sequence_extract(VALUE self, VALUE object) {
}
VALUE range_spec_rb_arithmetic_sequence_beg_len_step(VALUE self, VALUE aseq, VALUE lenv, VALUE errv) {
long begp = 0;
long lenp = 0;
long stepp = 0;
rb_len_t begp = 0;
rb_len_t lenp = 0;
rb_len_t stepp = 0;
long len = FIX2LONG(lenv);
int err = FIX2INT(errv);
+5
View File
@@ -7,6 +7,11 @@
#include <ruby.h>
#include <ruby/version.h>
/* Before rb_len_t, lengths and indices were `long` */
#ifndef RB_LEN2NUM
typedef long rb_len_t;
#endif
/* copied from ext/-test-/cxxanyargs/cxxanyargs.cpp */
#if 0 /* Ignore deprecation warnings */
+1 -1
View File
@@ -306,7 +306,7 @@ VALUE string_spec_rb_str_substr(VALUE self, VALUE str, VALUE beg, VALUE len) {
VALUE string_spec_rb_str_subpos(VALUE self, VALUE str, VALUE beg) {
char* original = RSTRING_PTR(str);
char* end = RSTRING_END(str);
long len = rb_str_strlen(str);
rb_len_t len = rb_str_strlen(str);
char *p = rb_str_subpos(str, FIX2LONG(beg), &len);
if (p == NULL) {
return Qnil;
+1 -1
View File
@@ -2451,7 +2451,7 @@ st_insert_generic(st_table *tab, long argc, const VALUE *argv, VALUE hash)
/* Mimics ruby's { foo => bar } syntax. This function is subpart
of rb_hash_bulk_insert. */
void
rb_hash_bulk_insert_into_st_table(long argc, const VALUE *argv, VALUE hash)
rb_hash_bulk_insert_into_st_table(rb_len_t argc, const VALUE *argv, VALUE hash)
{
st_index_t n, size = argc / 2;
st_table *tab = RHASH_ST_TABLE(hash);
+49 -49
View File
@@ -840,7 +840,7 @@ coderange_scan(const char *p, long len, rb_encoding *enc)
return ENC_CODERANGE_VALID;
}
long
rb_len_t
rb_str_coderange_scan_restartable(const char *s, const char *e, rb_encoding *enc, int *cr)
{
const char *p = s;
@@ -1124,25 +1124,25 @@ str_new(VALUE klass, const char *ptr, long len)
}
VALUE
rb_str_new(const char *ptr, long len)
rb_str_new(const char *ptr, rb_len_t len)
{
return str_new(rb_cString, ptr, len);
}
VALUE
rb_usascii_str_new(const char *ptr, long len)
rb_usascii_str_new(const char *ptr, rb_len_t len)
{
return str_enc_new(rb_cString, ptr, len, rb_usascii_encoding());
}
VALUE
rb_utf8_str_new(const char *ptr, long len)
rb_utf8_str_new(const char *ptr, rb_len_t len)
{
return str_enc_new(rb_cString, ptr, len, rb_utf8_encoding());
}
VALUE
rb_enc_str_new(const char *ptr, long len, rb_encoding *enc)
rb_enc_str_new(const char *ptr, rb_len_t len, rb_encoding *enc)
{
return str_enc_new(rb_cString, ptr, len, enc);
}
@@ -1206,7 +1206,7 @@ str_new_static(VALUE klass, const char *ptr, long len, int encindex)
}
VALUE
rb_str_new_static(const char *ptr, long len)
rb_str_new_static(const char *ptr, rb_len_t len)
{
return str_new_static(rb_cString, ptr, len, 0);
}
@@ -1229,19 +1229,19 @@ rb_str_new_owned(char *ptr, long len, long capa, int encindex)
}
VALUE
rb_usascii_str_new_static(const char *ptr, long len)
rb_usascii_str_new_static(const char *ptr, rb_len_t len)
{
return str_new_static(rb_cString, ptr, len, ENCINDEX_US_ASCII);
}
VALUE
rb_utf8_str_new_static(const char *ptr, long len)
rb_utf8_str_new_static(const char *ptr, rb_len_t len)
{
return str_new_static(rb_cString, ptr, len, ENCINDEX_UTF_8);
}
VALUE
rb_enc_str_new_static(const char *ptr, long len, rb_encoding *enc)
rb_enc_str_new_static(const char *ptr, rb_len_t len, rb_encoding *enc)
{
return str_new_static(rb_cString, ptr, len, rb_enc_to_index(enc));
}
@@ -1382,7 +1382,7 @@ rb_str_conv_enc(VALUE str, rb_encoding *from, rb_encoding *to)
}
VALUE
rb_external_str_new_with_enc(const char *ptr, long len, rb_encoding *eenc)
rb_external_str_new_with_enc(const char *ptr, rb_len_t len, rb_encoding *eenc)
{
rb_encoding *ienc;
VALUE str;
@@ -1433,7 +1433,7 @@ rb_external_str_with_enc(VALUE str, rb_encoding *eenc)
}
VALUE
rb_external_str_new(const char *ptr, long len)
rb_external_str_new(const char *ptr, rb_len_t len)
{
return rb_external_str_new_with_enc(ptr, len, rb_default_external_encoding());
}
@@ -1445,7 +1445,7 @@ rb_external_str_new_cstr(const char *ptr)
}
VALUE
rb_locale_str_new(const char *ptr, long len)
rb_locale_str_new(const char *ptr, rb_len_t len)
{
return rb_external_str_new_with_enc(ptr, len, rb_locale_encoding());
}
@@ -1457,7 +1457,7 @@ rb_locale_str_new_cstr(const char *ptr)
}
VALUE
rb_filesystem_str_new(const char *ptr, long len)
rb_filesystem_str_new(const char *ptr, rb_len_t len)
{
return rb_external_str_new_with_enc(ptr, len, rb_filesystem_encoding());
}
@@ -1750,7 +1750,7 @@ str_new_frozen_buffer(VALUE klass, VALUE orig, int copy_encoding)
}
VALUE
rb_str_new_with_class(VALUE obj, const char *ptr, long len)
rb_str_new_with_class(VALUE obj, const char *ptr, rb_len_t len)
{
return str_enc_new(rb_obj_class(obj), ptr, len, STR_ENC_GET(obj));
}
@@ -1766,7 +1766,7 @@ str_new_empty_String(VALUE str)
#define STR_BUF_MIN_SIZE 63
VALUE
rb_str_buf_new(long capa)
rb_str_buf_new(rb_len_t capa)
{
if (STR_EMBEDDABLE_P(capa, 1)) {
return str_alloc_embed(rb_cString, capa + 1);
@@ -1794,7 +1794,7 @@ rb_str_buf_new_cstr(const char *ptr)
}
VALUE
rb_str_tmp_new(long len)
rb_str_tmp_new(rb_len_t len)
{
return str_new(0, 0, len);
}
@@ -2401,7 +2401,7 @@ enc_strlen(const char *p, const char *e, rb_encoding *enc, int cr)
return c;
}
long
rb_len_t
rb_enc_strlen(const char *p, const char *e, rb_encoding *enc)
{
return enc_strlen(p, e, enc, ENC_CODERANGE_UNKNOWN);
@@ -2488,7 +2488,7 @@ str_strlen(VALUE str, rb_encoding *enc)
}
}
long
rb_len_t
rb_str_strlen(VALUE str)
{
return str_strlen(str, NULL);
@@ -2813,7 +2813,7 @@ rb_str_modify(VALUE str)
}
void
rb_str_modify_expand(VALUE str, long expand)
rb_str_modify_expand(VALUE str, rb_len_t expand)
{
RUBY_ASSERT(ruby_thread_has_gvl_p());
@@ -3072,7 +3072,7 @@ rb_str_s_try_convert(VALUE dummy, VALUE str)
}
static char*
str_nth_len(const char *p, const char *e, long *nthp, rb_encoding *enc)
str_nth_len(const char *p, const char *e, rb_len_t *nthp, rb_encoding *enc)
{
long nth = *nthp;
if (rb_enc_mbmaxlen(enc) == 1) {
@@ -3120,13 +3120,13 @@ str_nth_len(const char *p, const char *e, long *nthp, rb_encoding *enc)
}
char*
rb_enc_nth(const char *p, const char *e, long nth, rb_encoding *enc)
rb_enc_nth(const char *p, const char *e, rb_len_t nth, rb_encoding *enc)
{
return str_nth_len(p, e, &nth, enc);
}
static char*
str_nth(const char *p, const char *e, long nth, rb_encoding *enc, int singlebyte)
str_nth(const char *p, const char *e, rb_len_t nth, rb_encoding *enc, int singlebyte)
{
if (singlebyte)
p += nth;
@@ -3147,8 +3147,8 @@ str_offset(const char *p, const char *e, long nth, rb_encoding *enc, int singleb
return pp - p;
}
long
rb_str_offset(VALUE str, long pos)
rb_len_t
rb_str_offset(VALUE str, rb_len_t pos)
{
return str_offset(RSTRING_PTR(str), RSTRING_END(str), pos,
STR_ENC_GET(str), single_byte_optimizable(str));
@@ -3156,7 +3156,7 @@ rb_str_offset(VALUE str, long pos)
#ifdef NONASCII_MASK
static char *
str_utf8_nth(const char *p, const char *e, long *nthp)
str_utf8_nth(const char *p, const char *e, rb_len_t *nthp)
{
long nth = *nthp;
if ((int)SIZEOF_VOIDP * 2 < e - p && (int)SIZEOF_VOIDP * 2 < nth) {
@@ -3186,7 +3186,7 @@ str_utf8_nth(const char *p, const char *e, long *nthp)
}
static long
str_utf8_offset(const char *p, const char *e, long nth)
str_utf8_offset(const char *p, const char *e, rb_len_t nth)
{
const char *pp = str_utf8_nth(p, e, &nth);
return pp - p;
@@ -3194,8 +3194,8 @@ str_utf8_offset(const char *p, const char *e, long nth)
#endif
/* byte offset to char offset */
long
rb_str_sublen(VALUE str, long pos)
rb_len_t
rb_str_sublen(VALUE str, rb_len_t pos)
{
if (single_byte_optimizable(str) || pos < 0)
return pos;
@@ -3263,7 +3263,7 @@ str_subseq(VALUE str, long beg, long len)
}
VALUE
rb_str_subseq(VALUE str, long beg, long len)
rb_str_subseq(VALUE str, rb_len_t beg, rb_len_t len)
{
VALUE str2 = str_subseq(str, beg, len);
rb_enc_cr_str_copy_for_substr(str2, str);
@@ -3271,7 +3271,7 @@ rb_str_subseq(VALUE str, long beg, long len)
}
char *
rb_str_subpos(VALUE str, long beg, long *lenp)
rb_str_subpos(VALUE str, rb_len_t beg, rb_len_t *lenp)
{
long len = *lenp;
long slen = -1L;
@@ -3357,10 +3357,10 @@ rb_str_subpos(VALUE str, long beg, long *lenp)
return (char *)p;
}
static VALUE str_substr(VALUE str, long beg, long len, int empty);
static VALUE str_substr(VALUE str, rb_len_t beg, rb_len_t len, int empty);
VALUE
rb_str_substr(VALUE str, long beg, long len)
rb_str_substr(VALUE str, rb_len_t beg, rb_len_t len)
{
return str_substr(str, beg, len, TRUE);
}
@@ -3372,7 +3372,7 @@ rb_str_substr_two_fixnums(VALUE str, VALUE beg, VALUE len, int empty)
}
static VALUE
str_substr(VALUE str, long beg, long len, int empty)
str_substr(VALUE str, rb_len_t beg, rb_len_t len, int empty)
{
const char *p = rb_str_subpos(str, beg, &len);
@@ -3497,7 +3497,7 @@ rb_str_locktmp_ensure(VALUE str, VALUE (*func)(VALUE), VALUE arg)
}
void
rb_str_set_len(VALUE str, long len)
rb_str_set_len(VALUE str, rb_len_t len)
{
RUBY_ASSERT(ruby_thread_has_gvl_p());
@@ -3547,7 +3547,7 @@ rb_str_set_len(VALUE str, long len)
}
VALUE
rb_str_resize(VALUE str, long len)
rb_str_resize(VALUE str, rb_len_t len)
{
if (len < 0) {
rb_raise(rb_eArgError, "negative string size (or size too big)");
@@ -3678,7 +3678,7 @@ str_buf_cat4(VALUE str, const char *ptr, long len, bool keep_cr)
#define str_buf_cat2(str, ptr) str_buf_cat4((str), (ptr), rb_strlen_lit(ptr), false)
VALUE
rb_str_cat(VALUE str, const char *ptr, long len)
rb_str_cat(VALUE str, const char *ptr, rb_len_t len)
{
if (len == 0) return str;
if (len < 0) {
@@ -3750,7 +3750,7 @@ rb_str_buf_cat_byte(VALUE str, unsigned char byte)
}
}
RUBY_ALIAS_FUNCTION(rb_str_buf_cat(VALUE str, const char *ptr, long len), rb_str_cat, (str, ptr, len))
RUBY_ALIAS_FUNCTION(rb_str_buf_cat(VALUE str, const char *ptr, rb_len_t len), rb_str_cat, (str, ptr, len))
RUBY_ALIAS_FUNCTION(rb_str_buf_cat2(VALUE str, const char *ptr), rb_str_cat_cstr, (str, ptr))
RUBY_ALIAS_FUNCTION(rb_str_cat2(VALUE str, const char *ptr), rb_str_cat_cstr, (str, ptr))
@@ -3845,7 +3845,7 @@ rb_enc_cr_str_buf_cat(VALUE str, const char *ptr, long len,
}
VALUE
rb_enc_str_buf_cat(VALUE str, const char *ptr, long len, rb_encoding *ptr_enc)
rb_enc_str_buf_cat(VALUE str, const char *ptr, rb_len_t len, rb_encoding *ptr_enc)
{
return rb_enc_cr_str_buf_cat(str, ptr, len,
rb_enc_to_index(ptr_enc), ENC_CODERANGE_UNKNOWN, NULL);
@@ -5811,7 +5811,7 @@ rb_str_aref(VALUE str, VALUE indx)
}
else {
/* check if indx is Range */
long beg, len = str_strlen(str, NULL);
rb_len_t beg, len = str_strlen(str, NULL);
switch (rb_range_beg_len(indx, &beg, &len, len, 0)) {
case Qfalse:
break;
@@ -5855,7 +5855,7 @@ rb_str_aref_m(int argc, VALUE *argv, VALUE str)
}
VALUE
rb_str_drop_bytes(VALUE str, long len)
rb_str_drop_bytes(VALUE str, rb_len_t len)
{
char *ptr = RSTRING_PTR(str);
long olen = RSTRING_LEN(str), nlen;
@@ -5940,7 +5940,7 @@ rb_str_update_0(VALUE str, long beg, long len, VALUE val)
}
void
rb_str_update(VALUE str, long beg, long len, VALUE val)
rb_str_update(VALUE str, rb_len_t beg, rb_len_t len, VALUE val)
{
long slen;
char *p, *e;
@@ -6040,7 +6040,7 @@ rb_str_aset(VALUE str, VALUE indx, VALUE val)
default:
/* check if indx is Range */
{
long beg, len;
rb_len_t beg, len;
if (rb_range_beg_len(indx, &beg, &len, str_strlen(str, NULL), 2)) {
rb_str_update(str, beg, len, val);
return val;
@@ -6136,7 +6136,7 @@ rb_str_slice_bang(int argc, VALUE *argv, VALUE str)
{
VALUE result = Qnil;
VALUE indx;
long beg, len = 1;
rb_len_t beg, len = 1;
char *p;
rb_check_arity(argc, 1, 2);
@@ -7649,7 +7649,7 @@ str_byte_aref(VALUE str, VALUE indx)
}
else {
/* check if indx is Range */
long beg, len = RSTRING_LEN(str);
rb_len_t beg, len = RSTRING_LEN(str);
switch (rb_range_beg_len(indx, &beg, &len, len, 0)) {
case Qfalse:
@@ -7686,7 +7686,7 @@ rb_str_byteslice(int argc, VALUE *argv, VALUE str)
}
static void
str_check_beg_len(VALUE str, long *beg, long *len)
str_check_beg_len(VALUE str, rb_len_t *beg, rb_len_t *len)
{
long end, slen = RSTRING_LEN(str);
@@ -7721,7 +7721,7 @@ str_check_beg_len(VALUE str, long *beg, long *len)
static VALUE
rb_str_bytesplice(int argc, VALUE *argv, VALUE str)
{
long beg, len, vbeg, vlen;
rb_len_t beg, len, vbeg, vlen;
VALUE val;
int cr;
@@ -13144,7 +13144,7 @@ rb_str_is_ascii_only_p(VALUE str)
}
VALUE
rb_str_ellipsize(VALUE str, long len)
rb_str_ellipsize(VALUE str, rb_len_t len)
{
static const char ellipsis[] = "...";
const long ellipsislen = sizeof(ellipsis) - 1;
@@ -14176,7 +14176,7 @@ rb_str_to_interned_str(VALUE str)
}
VALUE
rb_interned_str(const char *ptr, long len)
rb_interned_str(const char *ptr, rb_len_t len)
{
struct RString fake_str = {RBASIC_INIT};
int encidx = ENCINDEX_US_ASCII;
@@ -14197,7 +14197,7 @@ rb_interned_str_cstr(const char *ptr)
}
VALUE
rb_enc_interned_str(const char *ptr, long len, rb_encoding *enc)
rb_enc_interned_str(const char *ptr, rb_len_t len, rb_encoding *enc)
{
if (enc != NULL && UNLIKELY(rb_enc_autoload_p(enc))) {
rb_enc_autoload(enc);
+1 -1
View File
@@ -1350,7 +1350,7 @@ rb_struct_lookup_default(VALUE s, VALUE idx, VALUE notfound, bool name_only)
}
static VALUE
struct_entry(VALUE s, long n)
struct_entry(VALUE s, rb_len_t n)
{
return rb_struct_aref(s, LONG2NUM(n));
}
+5 -5
View File
@@ -855,7 +855,7 @@ rb_enc_symname_type(const char *name, long len, rb_encoding *enc, unsigned int a
}
int
rb_enc_symname2_p(const char *name, long len, rb_encoding *enc)
rb_enc_symname2_p(const char *name, rb_len_t len, rb_encoding *enc)
{
return rb_enc_symname_type(name, len, enc, IDSET_ATTRSET_FOR_SYNTAX) != -1;
}
@@ -991,7 +991,7 @@ lookup_str_id(VALUE str)
}
ID
rb_intern3(const char *name, long len, rb_encoding *enc)
rb_intern3(const char *name, rb_len_t len, rb_encoding *enc)
{
struct RString fake_str = {RBASIC_INIT};
VALUE str = rb_setup_fake_str(&fake_str, name, len, enc);
@@ -1002,7 +1002,7 @@ rb_intern3(const char *name, long len, rb_encoding *enc)
}
ID
rb_intern2(const char *name, long len)
rb_intern2(const char *name, rb_len_t len)
{
return rb_intern3(name, len, rb_usascii_encoding());
}
@@ -1378,7 +1378,7 @@ rb_check_symbol(volatile VALUE *namep)
}
ID
rb_check_id_cstr(const char *ptr, long len, rb_encoding *enc)
rb_check_id_cstr(const char *ptr, rb_len_t len, rb_encoding *enc)
{
struct RString fake_str = {RBASIC_INIT};
const VALUE name = rb_setup_fake_str(&fake_str, ptr, len, enc);
@@ -1389,7 +1389,7 @@ rb_check_id_cstr(const char *ptr, long len, rb_encoding *enc)
}
VALUE
rb_check_symbol_cstr(const char *ptr, long len, rb_encoding *enc)
rb_check_symbol_cstr(const char *ptr, rb_len_t len, rb_encoding *enc)
{
VALUE sym;
struct RString fake_str = {RBASIC_INIT};
+3 -3
View File
@@ -1875,7 +1875,7 @@ rb_econv_asciicompat_encoding(const char *ascii_incompat_name)
* `dst`, `dst` may not be valid encoding.
*/
VALUE
rb_econv_append(rb_econv_t *ec, const char *ss, long len, VALUE dst, int flags)
rb_econv_append(rb_econv_t *ec, const char *ss, rb_len_t len, VALUE dst, int flags)
{
unsigned const char *sp, *se;
unsigned char *ds, *dp, *de;
@@ -1938,7 +1938,7 @@ rb_econv_append(rb_econv_t *ec, const char *ss, long len, VALUE dst, int flags)
}
VALUE
rb_econv_substr_append(rb_econv_t *ec, VALUE src, long off, long len, VALUE dst, int flags)
rb_econv_substr_append(rb_econv_t *ec, VALUE src, rb_len_t off, rb_len_t len, VALUE dst, int flags)
{
src = rb_str_new_frozen(src);
dst = rb_econv_append(ec, RSTRING_PTR(src) + off, len, dst, flags);
@@ -1953,7 +1953,7 @@ rb_econv_str_append(rb_econv_t *ec, VALUE src, VALUE dst, int flags)
}
VALUE
rb_econv_substr_convert(rb_econv_t *ec, VALUE src, long byteoff, long bytesize, int flags)
rb_econv_substr_convert(rb_econv_t *ec, VALUE src, rb_len_t byteoff, rb_len_t bytesize, int flags)
{
return rb_econv_substr_append(ec, src, byteoff, bytesize, Qnil, flags);
}
+6 -6
View File
@@ -1576,7 +1576,7 @@ ec_backtrace_range(const rb_execution_context_t *ec, int argc, const VALUE *argv
break;
case 1:
{
long beg, len, bt_size = backtrace_size(ec);
rb_len_t beg, len, bt_size = backtrace_size(ec);
switch (rb_range_beg_len(level, &beg, &len, bt_size - lev_plus, 0)) {
case Qfalse:
lev = NUM2LONG(level);
@@ -2057,28 +2057,28 @@ frame_get(const rb_debug_inspector_t *dc, long index)
}
VALUE
rb_debug_inspector_frame_self_get(const rb_debug_inspector_t *dc, long index)
rb_debug_inspector_frame_self_get(const rb_debug_inspector_t *dc, rb_len_t index)
{
VALUE frame = frame_get(dc, index);
return rb_ary_entry(frame, CALLER_BINDING_SELF);
}
VALUE
rb_debug_inspector_frame_class_get(const rb_debug_inspector_t *dc, long index)
rb_debug_inspector_frame_class_get(const rb_debug_inspector_t *dc, rb_len_t index)
{
VALUE frame = frame_get(dc, index);
return rb_ary_entry(frame, CALLER_BINDING_CLASS);
}
VALUE
rb_debug_inspector_frame_binding_get(const rb_debug_inspector_t *dc, long index)
rb_debug_inspector_frame_binding_get(const rb_debug_inspector_t *dc, rb_len_t index)
{
VALUE frame = frame_get(dc, index);
return rb_ary_entry(frame, CALLER_BINDING_BINDING);
}
VALUE
rb_debug_inspector_frame_iseq_get(const rb_debug_inspector_t *dc, long index)
rb_debug_inspector_frame_iseq_get(const rb_debug_inspector_t *dc, rb_len_t index)
{
VALUE frame = frame_get(dc, index);
VALUE iseq = rb_ary_entry(frame, CALLER_BINDING_ISEQ);
@@ -2087,7 +2087,7 @@ rb_debug_inspector_frame_iseq_get(const rb_debug_inspector_t *dc, long index)
}
VALUE
rb_debug_inspector_frame_depth(const rb_debug_inspector_t *dc, long index)
rb_debug_inspector_frame_depth(const rb_debug_inspector_t *dc, rb_len_t index)
{
VALUE frame = frame_get(dc, index);
return rb_ary_entry(frame, CALLER_BINDING_DEPTH);