mirror of
https://github.com/ruby/ruby.git
synced 2026-10-28 16:36:20 +08:00
Use rb_len_t for the lengths and indices left in long
These still held String and Array lengths and indices in long, or cast them to long. rb_len_t is still long everywhere, so the generated code does not change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a3df7663d5
commit
ee3d6c987b
24 files changed
+66
-65
Notes:
git
2026-10-10 07:46:23 +00:00
No files matched your search
@@ -7163,16 +7163,16 @@ ary_sample0(rb_execution_context_t *ec, VALUE ary)
|
||||
static VALUE
|
||||
rb_ary_cycle_size(VALUE self, VALUE args, VALUE eobj)
|
||||
{
|
||||
long mul;
|
||||
rb_len_t mul;
|
||||
VALUE n = Qnil;
|
||||
if (args && (RARRAY_LEN(args) > 0)) {
|
||||
n = RARRAY_AREF(args, 0);
|
||||
}
|
||||
if (RARRAY_LEN(self) == 0) return INT2FIX(0);
|
||||
if (NIL_P(n)) return DBL2NUM(HUGE_VAL);
|
||||
mul = NUM2LONG(n);
|
||||
mul = NUM2LEN(n);
|
||||
if (mul <= 0) return INT2FIX(0);
|
||||
n = LONG2NUM(mul);
|
||||
n = LEN2NUM(mul);
|
||||
return rb_int_mul(rb_ary_length(self), n);
|
||||
}
|
||||
|
||||
|
||||
@@ -1199,10 +1199,10 @@ dump_classext_i(rb_classext_t *ext, bool is_prime, VALUE _recv, void *data)
|
||||
|
||||
tbl = RCLASSEXT_M_TBL(ext);
|
||||
if (tbl) {
|
||||
ary = rb_ary_new_capa((long)rb_id_table_size(tbl));
|
||||
ary = rb_ary_new_capa((rb_len_t)rb_id_table_size(tbl));
|
||||
rb_id_table_foreach(RCLASSEXT_M_TBL(ext), dump_classext_methods_i, (void *)ary);
|
||||
rb_ary_sort_bang(ary);
|
||||
snprintf(buf, 4096, " Methods(%ld): ", RARRAY_LEN(ary));
|
||||
snprintf(buf, 4096, " Methods(%"PRIdLEN"): ", RARRAY_LEN(ary));
|
||||
rb_str_cat_cstr(res, buf);
|
||||
rb_str_concat(res, rb_ary_join(ary, rb_str_new_cstr(",")));
|
||||
rb_str_cat_cstr(res, "\n");
|
||||
@@ -1213,10 +1213,10 @@ dump_classext_i(rb_classext_t *ext, bool is_prime, VALUE _recv, void *data)
|
||||
|
||||
tbl = RCLASSEXT_CONST_TBL(ext);
|
||||
if (tbl) {
|
||||
ary = rb_ary_new_capa((long)rb_id_table_size(tbl));
|
||||
ary = rb_ary_new_capa((rb_len_t)rb_id_table_size(tbl));
|
||||
rb_id_table_foreach(tbl, dump_classext_constants_i, (void *)ary);
|
||||
rb_ary_sort_bang(ary);
|
||||
snprintf(buf, 4096, " Constants(%ld): ", RARRAY_LEN(ary));
|
||||
snprintf(buf, 4096, " Constants(%"PRIdLEN"): ", RARRAY_LEN(ary));
|
||||
rb_str_cat_cstr(res, buf);
|
||||
rb_str_concat(res, rb_ary_join(ary, rb_str_new_cstr(",")));
|
||||
rb_str_cat_cstr(res, "\n");
|
||||
|
||||
@@ -14477,7 +14477,7 @@ ibf_load_object_string(const struct ibf_load *load, const struct ibf_object_head
|
||||
ibf_offset_t reading_pos = offset;
|
||||
|
||||
int encindex = (int)ibf_load_small_value(load, &reading_pos);
|
||||
const long len = (long)ibf_load_small_value(load, &reading_pos);
|
||||
const rb_len_t len = (rb_len_t)ibf_load_small_value(load, &reading_pos);
|
||||
const char *ptr = load->current_buffer->buff + reading_pos;
|
||||
|
||||
if (encindex > RUBY_ENCINDEX_BUILTIN_MAX) {
|
||||
@@ -14542,7 +14542,7 @@ ibf_load_object_array(const struct ibf_load *load, const struct ibf_object_heade
|
||||
{
|
||||
ibf_offset_t reading_pos = offset;
|
||||
|
||||
const long len = (long)ibf_load_small_value(load, &reading_pos);
|
||||
const rb_len_t len = (rb_len_t)ibf_load_small_value(load, &reading_pos);
|
||||
|
||||
VALUE ary = header->internal ? rb_ary_hidden_new(len) : rb_ary_new_capa(len);
|
||||
int i;
|
||||
@@ -14790,7 +14790,7 @@ ibf_load_object_symbol(const struct ibf_load *load, const struct ibf_object_head
|
||||
ibf_offset_t reading_pos = offset;
|
||||
|
||||
int encindex = (int)ibf_load_small_value(load, &reading_pos);
|
||||
const long len = (long)ibf_load_small_value(load, &reading_pos);
|
||||
const rb_len_t len = (rb_len_t)ibf_load_small_value(load, &reading_pos);
|
||||
const char *ptr = load->current_buffer->buff + reading_pos;
|
||||
|
||||
if (encindex > RUBY_ENCINDEX_BUILTIN_MAX) {
|
||||
|
||||
@@ -1651,9 +1651,9 @@ rb_dir_getwd_ospath(void)
|
||||
if (!cached_cwd || (size_t)RSTRING_LEN(cached_cwd) != len ||
|
||||
memcmp(RSTRING_PTR(cached_cwd), path, len) != 0) {
|
||||
#ifdef __APPLE__
|
||||
cached_cwd = rb_str_normalize_ospath(path, (long)len);
|
||||
cached_cwd = rb_str_normalize_ospath(path, (rb_len_t)len);
|
||||
#else
|
||||
cached_cwd = rb_str_new(path, (long)len);
|
||||
cached_cwd = rb_str_new(path, (rb_len_t)len);
|
||||
#endif
|
||||
rb_str_freeze(cached_cwd);
|
||||
RB_OBJ_SET_SHAREABLE(cached_cwd);
|
||||
|
||||
+1
-1
@@ -58,7 +58,7 @@ enum ruby_preserved_encindex {
|
||||
#define rb_utf8_encindex() RUBY_ENCINDEX_UTF_8
|
||||
#define rb_usascii_encindex() RUBY_ENCINDEX_US_ASCII
|
||||
|
||||
int rb_enc_find_index2(const char *name, long len);
|
||||
int rb_enc_find_index2(const char *name, rb_len_t len);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
#if 0
|
||||
|
||||
+1
-1
@@ -917,7 +917,7 @@ rb_enc_find_index(const char *name)
|
||||
}
|
||||
|
||||
int
|
||||
rb_enc_find_index2(const char *name, long len)
|
||||
rb_enc_find_index2(const char *name, rb_len_t len)
|
||||
{
|
||||
char buf[ENCODING_NAMELEN_MAX+1];
|
||||
|
||||
|
||||
@@ -3762,13 +3762,13 @@ cycle_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, ary))
|
||||
static VALUE
|
||||
enum_cycle_size(VALUE self, VALUE args, VALUE eobj)
|
||||
{
|
||||
long mul = 0;
|
||||
rb_len_t mul = 0;
|
||||
VALUE n = Qnil;
|
||||
VALUE size;
|
||||
|
||||
if (args && (RARRAY_LEN(args) > 0)) {
|
||||
n = RARRAY_AREF(args, 0);
|
||||
if (!NIL_P(n)) mul = NUM2LONG(n);
|
||||
if (!NIL_P(n)) mul = NUM2LEN(n);
|
||||
}
|
||||
|
||||
size = enum_size(self, args, 0);
|
||||
@@ -3776,7 +3776,7 @@ enum_cycle_size(VALUE self, VALUE args, VALUE eobj)
|
||||
|
||||
if (NIL_P(n)) return DBL2NUM(HUGE_VAL);
|
||||
if (mul <= 0) return INT2FIX(0);
|
||||
n = LONG2NUM(mul);
|
||||
n = LEN2NUM(mul);
|
||||
return rb_funcallv(size, '*', 1, &n);
|
||||
}
|
||||
|
||||
@@ -3812,7 +3812,7 @@ enum_cycle(int argc, VALUE *argv, VALUE obj)
|
||||
{
|
||||
VALUE ary;
|
||||
VALUE nv = Qnil;
|
||||
long n;
|
||||
rb_len_t n;
|
||||
rb_len_t i, len;
|
||||
|
||||
rb_check_arity(argc, 0, 1);
|
||||
@@ -3822,7 +3822,7 @@ enum_cycle(int argc, VALUE *argv, VALUE obj)
|
||||
n = -1;
|
||||
}
|
||||
else {
|
||||
n = NUM2LONG(nv);
|
||||
n = NUM2LEN(nv);
|
||||
if (n <= 0) return Qnil;
|
||||
}
|
||||
ary = rb_ary_new();
|
||||
|
||||
+3
-3
@@ -4017,13 +4017,13 @@ rb_arithmetic_sequence_beg_len_step(VALUE obj, rb_len_t *begp, rb_len_t *lenp, r
|
||||
return Qfalse;
|
||||
}
|
||||
|
||||
long step = NIL_P(aseq.step) ? 1 : NUM2LONG(aseq.step);
|
||||
rb_len_t step = NIL_P(aseq.step) ? 1 : NUM2LEN(aseq.step);
|
||||
*stepp = step;
|
||||
|
||||
if (step < 0) {
|
||||
if (aseq.exclude_end && !NIL_P(aseq.end)) {
|
||||
/* Handle exclusion before range reversal */
|
||||
aseq.end = LONG2NUM(NUM2LONG(aseq.end) + 1);
|
||||
aseq.end = LEN2NUM(NUM2LEN(aseq.end) + 1);
|
||||
|
||||
/* Don't exclude the previous beginning */
|
||||
aseq.exclude_end = 0;
|
||||
@@ -4093,7 +4093,7 @@ arith_seq_take(VALUE self, VALUE num)
|
||||
long i = FIX2LONG(b);
|
||||
long end = FIX2LONG(e);
|
||||
long unit = FIX2LONG(s);
|
||||
long len;
|
||||
rb_len_t len;
|
||||
|
||||
if (unit >= 0) {
|
||||
if (!x) end += 1;
|
||||
|
||||
+2
-2
@@ -12,7 +12,7 @@
|
||||
#ifdef HAVE_BUILTIN___BUILTIN_CONSTANT_P
|
||||
#define warn_print(x) RB_GNUC_EXTENSION_BLOCK( \
|
||||
(__builtin_constant_p(x)) ? \
|
||||
rb_write_error2((x), (long)strlen(x)) : \
|
||||
rb_write_error2((x), (rb_len_t)strlen(x)) : \
|
||||
rb_write_error(x) \
|
||||
)
|
||||
#else
|
||||
@@ -342,7 +342,7 @@ rb_error_write0(VALUE errinfo, VALUE emesg, VALUE errat, VALUE str, VALUE opt, V
|
||||
const int bold_part = rb_strlen_lit("Traceback");
|
||||
char buff[sizeof(traceback)+sizeof(bold)+sizeof(reset)-2], *p = buff;
|
||||
const char *msg = traceback;
|
||||
long len = sizeof(traceback) - 1;
|
||||
rb_len_t len = sizeof(traceback) - 1;
|
||||
if (RTEST(highlight)) {
|
||||
#define APPEND(s, l) (memcpy(p, s, l), p += (l))
|
||||
APPEND(bold, sizeof(bold)-1);
|
||||
|
||||
@@ -6,9 +6,9 @@ arith_seq_s_beg_len_step(VALUE mod, VALUE obj, VALUE len, VALUE err)
|
||||
VALUE r;
|
||||
rb_len_t beg, len2, step;
|
||||
|
||||
r = rb_arithmetic_sequence_beg_len_step(obj, &beg, &len2, &step, NUM2LONG(len), NUM2INT(err));
|
||||
r = rb_arithmetic_sequence_beg_len_step(obj, &beg, &len2, &step, NUM2LEN(len), NUM2INT(err));
|
||||
|
||||
return rb_ary_new_from_args(4, r, LONG2NUM(beg), LONG2NUM(len2), LONG2NUM(step));
|
||||
return rb_ary_new_from_args(4, r, LEN2NUM(beg), LEN2NUM(len2), LEN2NUM(step));
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -5488,7 +5488,7 @@ env_encoding(void)
|
||||
}
|
||||
|
||||
static VALUE
|
||||
env_enc_str_new(const char *ptr, long len, rb_encoding *enc)
|
||||
env_enc_str_new(const char *ptr, rb_len_t len, rb_encoding *enc)
|
||||
{
|
||||
VALUE str = rb_external_str_new_with_enc(ptr, len, enc);
|
||||
|
||||
@@ -5497,7 +5497,7 @@ env_enc_str_new(const char *ptr, long len, rb_encoding *enc)
|
||||
}
|
||||
|
||||
static VALUE
|
||||
env_str_new(const char *ptr, long len, rb_encoding *enc)
|
||||
env_str_new(const char *ptr, rb_len_t len, rb_encoding *enc)
|
||||
{
|
||||
return env_enc_str_new(ptr, len, enc);
|
||||
}
|
||||
@@ -6691,7 +6691,7 @@ env_has_value(VALUE dmy, VALUE obj)
|
||||
while (*env) {
|
||||
char *s = strchr(*env, '=');
|
||||
if (s++) {
|
||||
long len = strlen(s);
|
||||
rb_len_t len = strlen(s);
|
||||
if (RSTRING_LEN(obj) == len && strncmp(s, RSTRING_PTR(obj), len) == 0) {
|
||||
ret = Qtrue;
|
||||
break;
|
||||
@@ -6734,7 +6734,7 @@ env_rassoc(VALUE dmy, VALUE obj)
|
||||
const char *p = *env;
|
||||
const char *s = strchr(p, '=');
|
||||
if (s++) {
|
||||
long len = strlen(s);
|
||||
rb_len_t len = strlen(s);
|
||||
if (RSTRING_LEN(obj) == len && strncmp(s, RSTRING_PTR(obj), len) == 0) {
|
||||
result = rb_assoc_new(rb_str_new(p, s-p-1), obj);
|
||||
break;
|
||||
@@ -6776,7 +6776,7 @@ env_key(VALUE dmy, VALUE value)
|
||||
while (*env) {
|
||||
char *s = strchr(*env, '=');
|
||||
if (s++) {
|
||||
long len = strlen(s);
|
||||
rb_len_t len = strlen(s);
|
||||
if (RSTRING_LEN(value) == len && strncmp(s, RSTRING_PTR(value), len) == 0) {
|
||||
str = env_str_new(*env, s-*env-1, enc);
|
||||
break;
|
||||
|
||||
+1
-1
@@ -898,7 +898,7 @@ VALUE
|
||||
rb_io_buffer_type_string(VALUE klass, VALUE length)
|
||||
{
|
||||
klass = io_buffer_storage_class(klass);
|
||||
VALUE string = rb_str_new(NULL, RB_NUM2LONG(length));
|
||||
VALUE string = rb_str_new(NULL, RB_NUM2LEN(length));
|
||||
|
||||
struct io_buffer_for_yield_instance_arguments arguments = {
|
||||
.klass = klass,
|
||||
|
||||
@@ -3666,7 +3666,7 @@ iseq_data_to_ary(const rb_iseq_t *iseq)
|
||||
if (vm_ci_flag(ci) & VM_CALL_KWARG) {
|
||||
const struct rb_callinfo_kwarg *kwarg = vm_ci_kwarg(ci);
|
||||
int i;
|
||||
VALUE kw = rb_ary_new2((long)kwarg->keyword_len);
|
||||
VALUE kw = rb_ary_new2((rb_len_t)kwarg->keyword_len);
|
||||
|
||||
argc -= kwarg->keyword_len;
|
||||
for (i = 0; i < kwarg->keyword_len; i++) {
|
||||
|
||||
@@ -755,7 +755,7 @@ inspect_i(ID id, VALUE value, st_data_t a)
|
||||
if (!rb_is_instance_id(id)) return ST_CONTINUE;
|
||||
if (!NIL_P(ivars)) {
|
||||
VALUE name = ID2SYM(id);
|
||||
for (long i = 0; RARRAY_AREF(ivars, i) != name; ) {
|
||||
for (rb_len_t i = 0; RARRAY_AREF(ivars, i) != name; ) {
|
||||
if (++i >= RARRAY_LEN(ivars)) return ST_CONTINUE;
|
||||
}
|
||||
}
|
||||
@@ -2662,7 +2662,7 @@ rb_mod_const_get(int argc, VALUE *argv, VALUE mod)
|
||||
|
||||
while (p < pend) {
|
||||
VALUE part;
|
||||
long len, beglen;
|
||||
rb_len_t len, beglen;
|
||||
|
||||
while (p < pend && *p != ':') p++;
|
||||
|
||||
@@ -2835,7 +2835,7 @@ rb_mod_const_defined(int argc, VALUE *argv, VALUE mod)
|
||||
|
||||
while (p < pend) {
|
||||
VALUE part;
|
||||
long len, beglen;
|
||||
rb_len_t len, beglen;
|
||||
|
||||
while (p < pend && *p != ':') p++;
|
||||
|
||||
@@ -2995,7 +2995,7 @@ rb_mod_const_source_location(int argc, VALUE *argv, VALUE mod)
|
||||
|
||||
while (p < pend) {
|
||||
VALUE part;
|
||||
long len, beglen;
|
||||
rb_len_t len, beglen;
|
||||
|
||||
while (p < pend && *p != ':') p++;
|
||||
|
||||
|
||||
+6
-6
@@ -1760,7 +1760,7 @@ pm_setup_args_core(const pm_arguments_node_t *arguments_node, const pm_node_t *b
|
||||
// then mark the array at that index as false and
|
||||
// decrement the keyword size.
|
||||
if (!NIL_P(stored_index)) {
|
||||
rb_ary_store(keyword_indices, NUM2LONG(stored_index), Qfalse);
|
||||
rb_ary_store(keyword_indices, NUM2LEN(stored_index), Qfalse);
|
||||
size--;
|
||||
}
|
||||
|
||||
@@ -1768,7 +1768,7 @@ pm_setup_args_core(const pm_arguments_node_t *arguments_node, const pm_node_t *b
|
||||
// keyword in the hash, mark the array at that index
|
||||
// as true, and increment the keyword size.
|
||||
rb_hash_aset(stored_indices, keyword, ULONG2NUM(element_index));
|
||||
rb_ary_store(keyword_indices, (long) element_index, Qtrue);
|
||||
rb_ary_store(keyword_indices, (rb_len_t) element_index, Qtrue);
|
||||
size++;
|
||||
}
|
||||
|
||||
@@ -1789,7 +1789,7 @@ pm_setup_args_core(const pm_arguments_node_t *arguments_node, const pm_node_t *b
|
||||
const pm_assoc_node_t *assoc = (const pm_assoc_node_t *) elements->nodes[element_index];
|
||||
bool popped = true;
|
||||
|
||||
if (rb_ary_entry(keyword_indices, (long) element_index) == Qtrue) {
|
||||
if (rb_ary_entry(keyword_indices, (rb_len_t) element_index) == Qtrue) {
|
||||
keywords[keyword_index++] = pm_static_literal_value(iseq, assoc->key, scope_node);
|
||||
popped = false;
|
||||
}
|
||||
@@ -10773,7 +10773,7 @@ pm_parse_process_error(const pm_parse_result_t *result)
|
||||
pm_error_level_t error_level = pm_errors_format(parser, buffer, format_type);
|
||||
|
||||
rb_encoding *message_encoding = (error_level == PM_ERROR_LEVEL_LOAD) ? rb_locale_encoding() : rb_enc_find(pm_parser_encoding_name(parser));
|
||||
VALUE message = rb_enc_str_new(pm_buffer_value(buffer), (long) pm_buffer_length(buffer), message_encoding);
|
||||
VALUE message = rb_enc_str_new(pm_buffer_value(buffer), (rb_len_t) pm_buffer_length(buffer), message_encoding);
|
||||
pm_buffer_free(buffer);
|
||||
|
||||
VALUE error = Qnil;
|
||||
@@ -11286,8 +11286,8 @@ pm_parse_stdin_fgets(char *string, int size, void *stream)
|
||||
* than requested; we must never write past the caller's buffer. One byte
|
||||
* is reserved for the NUL terminator.
|
||||
*/
|
||||
if (length > (long) (size - 1)) {
|
||||
length = (long) (size - 1);
|
||||
if (length > (rb_len_t) (size - 1)) {
|
||||
length = (rb_len_t) (size - 1);
|
||||
}
|
||||
|
||||
memcpy(string, cstr, (size_t) length);
|
||||
|
||||
@@ -482,7 +482,7 @@ refinement_recipe_match(VALUE recipe, const rb_cref_t *base_cref, VALUE src_reci
|
||||
rb_len_t inherited = refinement_recipe_modc(src_recipe);
|
||||
if (RARRAY_AREF(recipe, REFINEMENT_RECIPE_BASE_CREF) != (VALUE)base_cref) return false;
|
||||
if (refinement_recipe_modc(recipe) != inherited + argc) return false;
|
||||
for (long i = 0; i < inherited; i++) {
|
||||
for (rb_len_t i = 0; i < inherited; i++) {
|
||||
if (RARRAY_AREF(recipe, REFINEMENT_RECIPE_MODS + i) !=
|
||||
RARRAY_AREF(src_recipe, REFINEMENT_RECIPE_MODS + i)) return false;
|
||||
}
|
||||
@@ -502,7 +502,7 @@ refinement_recipe_new(const rb_cref_t *base_cref, const rb_cref_t *cref,
|
||||
rb_ary_push(recipe, (VALUE)base_cref);
|
||||
rb_ary_push(recipe, (VALUE)cref);
|
||||
rb_ary_push(recipe, (VALUE)src_iseq);
|
||||
for (long i = 0; i < inherited; i++) {
|
||||
for (rb_len_t i = 0; i < inherited; i++) {
|
||||
rb_ary_push(recipe, RARRAY_AREF(src_recipe, REFINEMENT_RECIPE_MODS + i));
|
||||
}
|
||||
for (long i = 0; i < argc; i++) {
|
||||
@@ -2331,7 +2331,7 @@ rb_sym_to_proc(VALUE sym)
|
||||
}
|
||||
|
||||
ID id = SYM2ID(sym);
|
||||
long index = (id % SYM_PROC_CACHE_SIZE);
|
||||
rb_len_t index = (id % SYM_PROC_CACHE_SIZE);
|
||||
VALUE procval = RARRAY_AREF(sym_proc_cache, index);
|
||||
if (RTEST(procval)) {
|
||||
rb_proc_t *proc;
|
||||
|
||||
@@ -2208,7 +2208,7 @@ check_exec_fds(struct rb_execarg *eargp)
|
||||
int oldfd = FIX2INT(RARRAY_AREF(elt, 1));
|
||||
int lastfd = oldfd;
|
||||
VALUE val = rb_hash_lookup(h, INT2FIX(lastfd));
|
||||
long depth = 0;
|
||||
rb_len_t depth = 0;
|
||||
while (FIXNUM_P(val) && 0 <= FIX2INT(val)) {
|
||||
lastfd = FIX2INT(val);
|
||||
val = rb_hash_lookup(h, val);
|
||||
@@ -5599,7 +5599,7 @@ rb_getlogin(void)
|
||||
typedef size_t getlogin_r_size_t;
|
||||
# endif
|
||||
|
||||
long loginsize = GETLOGIN_R_SIZE_INIT; /* maybe -1 */
|
||||
rb_len_t loginsize = GETLOGIN_R_SIZE_INIT; /* maybe -1 */
|
||||
|
||||
if (loginsize < 0)
|
||||
loginsize = GETLOGIN_R_SIZE_DEFAULT;
|
||||
@@ -5707,7 +5707,7 @@ rb_getpwdirnam_for_login(VALUE login_name)
|
||||
# ifdef USE_GETPWNAM_R
|
||||
|
||||
char *bufnm;
|
||||
long bufsizenm = GETPW_R_SIZE_INIT; /* maybe -1 */
|
||||
rb_len_t bufsizenm = GETPW_R_SIZE_INIT; /* maybe -1 */
|
||||
|
||||
if (bufsizenm < 0)
|
||||
bufsizenm = GETPW_R_SIZE_DEFAULT;
|
||||
@@ -5731,7 +5731,7 @@ rb_getpwdirnam_for_login(VALUE login_name)
|
||||
rb_syserr_fail(enm, "getpwnam_r");
|
||||
}
|
||||
|
||||
rb_str_modify_expand(getpwnm_tmp, (long)args.bufsize);
|
||||
rb_str_modify_expand(getpwnm_tmp, (rb_len_t)args.bufsize);
|
||||
args.buf = RSTRING_PTR(getpwnm_tmp);
|
||||
args.bufsize = (size_t)rb_str_capacity(getpwnm_tmp);
|
||||
}
|
||||
@@ -5803,7 +5803,7 @@ rb_getpwdiruid(void)
|
||||
# ifdef USE_GETPWUID_R
|
||||
|
||||
char *bufid;
|
||||
long bufsizeid = GETPW_R_SIZE_INIT; /* maybe -1 */
|
||||
rb_len_t bufsizeid = GETPW_R_SIZE_INIT; /* maybe -1 */
|
||||
|
||||
if (bufsizeid < 0)
|
||||
bufsizeid = GETPW_R_SIZE_DEFAULT;
|
||||
@@ -5827,7 +5827,7 @@ rb_getpwdiruid(void)
|
||||
rb_syserr_fail(eid, "getpwuid_r");
|
||||
}
|
||||
|
||||
rb_str_modify_expand(getpwid_tmp, (long)args.bufsize);
|
||||
rb_str_modify_expand(getpwid_tmp, (rb_len_t)args.bufsize);
|
||||
args.buf = RSTRING_PTR(getpwid_tmp);
|
||||
args.bufsize = (size_t)rb_str_capacity(getpwid_tmp);
|
||||
}
|
||||
@@ -5895,7 +5895,7 @@ obj2uid(VALUE id
|
||||
struct passwd *pwptr;
|
||||
#ifdef USE_GETPWNAM_R
|
||||
char *getpw_buf;
|
||||
long getpw_buf_len;
|
||||
rb_len_t getpw_buf_len;
|
||||
int e;
|
||||
if (!*getpw_tmp) {
|
||||
getpw_buf_len = GETPW_R_SIZE_INIT;
|
||||
@@ -5913,7 +5913,7 @@ obj2uid(VALUE id
|
||||
rb_str_resize(*getpw_tmp, 0);
|
||||
rb_syserr_fail(e, "getpwnam_r");
|
||||
}
|
||||
rb_str_modify_expand(*getpw_tmp, (long)args.bufsize);
|
||||
rb_str_modify_expand(*getpw_tmp, (rb_len_t)args.bufsize);
|
||||
args.buf = RSTRING_PTR(*getpw_tmp);
|
||||
args.bufsize = (size_t)rb_str_capacity(*getpw_tmp);
|
||||
}
|
||||
@@ -5994,7 +5994,7 @@ obj2gid(VALUE id
|
||||
struct group *grptr;
|
||||
#ifdef USE_GETGRNAM_R
|
||||
char *getgr_buf;
|
||||
long getgr_buf_len;
|
||||
rb_len_t getgr_buf_len;
|
||||
int e;
|
||||
if (!*getgr_tmp) {
|
||||
getgr_buf_len = GETGR_R_SIZE_INIT;
|
||||
@@ -6012,7 +6012,7 @@ obj2gid(VALUE id
|
||||
rb_str_resize(*getgr_tmp, 0);
|
||||
rb_syserr_fail(e, "getgrnam_r");
|
||||
}
|
||||
rb_str_modify_expand(*getgr_tmp, (long)args.bufsize);
|
||||
rb_str_modify_expand(*getgr_tmp, (rb_len_t)args.bufsize);
|
||||
args.buf = RSTRING_PTR(*getgr_tmp);
|
||||
args.bufsize = (size_t)rb_str_capacity(*getgr_tmp);
|
||||
}
|
||||
|
||||
@@ -459,7 +459,7 @@ ruby_push_include(const char *path, VALUE (*filter)(VALUE))
|
||||
if (path == 0) return;
|
||||
p = path;
|
||||
while (*p) {
|
||||
long len;
|
||||
rb_len_t len;
|
||||
while (is_path_sep(*p))
|
||||
p++;
|
||||
if (!*p) break;
|
||||
@@ -895,7 +895,8 @@ static long proc_options(long argc, char **argv, ruby_cmdline_options_t *opt, in
|
||||
static void
|
||||
moreswitches(const char *s, ruby_cmdline_options_t *opt, int envopt)
|
||||
{
|
||||
long argc, i, len;
|
||||
long argc, i;
|
||||
rb_len_t len;
|
||||
char **argv, *p;
|
||||
const char *ap = 0;
|
||||
VALUE argstr, argary;
|
||||
@@ -1176,7 +1177,7 @@ dump_option(const char *str, int len, void *arg)
|
||||
}
|
||||
|
||||
static void
|
||||
set_option_encoding_once(const char *type, VALUE *name, const char *e, long elen)
|
||||
set_option_encoding_once(const char *type, VALUE *name, const char *e, rb_len_t elen)
|
||||
{
|
||||
VALUE ename;
|
||||
|
||||
|
||||
@@ -8619,7 +8619,7 @@ str_undump(VALUE str)
|
||||
if (s_end - s != 2) goto invalid_format;
|
||||
if (s[0] != '"' || s[1] != ')') goto invalid_format;
|
||||
|
||||
encidx = rb_enc_find_index2(encname, (long)size);
|
||||
encidx = rb_enc_find_index2(encname, (rb_len_t)size);
|
||||
if (encidx < 0) {
|
||||
rb_raise(rb_eRuntimeError, "dumped string has unknown encoding name");
|
||||
}
|
||||
|
||||
+1
-1
@@ -1093,7 +1093,7 @@ native_set_another_thread_name(rb_nativethread_id_t thread_id, VALUE name)
|
||||
if (!pthread_equal(pthread_self(), thread_id)) return;
|
||||
# endif
|
||||
if (!NIL_P(name)) {
|
||||
long n;
|
||||
rb_len_t n;
|
||||
RSTRING_GETMEM(name, s, n);
|
||||
if (n >= (int)sizeof(buf)) {
|
||||
memcpy(buf, s, sizeof(buf)-1);
|
||||
|
||||
+1
-1
@@ -72,7 +72,7 @@ wakeup_one(struct ccan_list_head *head)
|
||||
static void
|
||||
wakeup_all(struct ccan_list_head *head)
|
||||
{
|
||||
sync_wakeup(head, LONG_MAX);
|
||||
sync_wakeup(head, RB_LEN_MAX);
|
||||
}
|
||||
|
||||
#if defined(HAVE_WORKING_FORK)
|
||||
|
||||
+1
-1
@@ -2394,7 +2394,7 @@ transcode_loop(const unsigned char **in_pos, unsigned char **out_pos,
|
||||
VALUE fallback = Qnil;
|
||||
VALUE (*fallback_func)(VALUE, VALUE) = 0;
|
||||
const unsigned char *source_start = *in_pos;
|
||||
long source_len = in_stop - *in_pos;
|
||||
rb_len_t source_len = in_stop - *in_pos;
|
||||
|
||||
ec = rb_econv_open_opts(src_encoding, dst_encoding, ecflags, ecopts);
|
||||
if (!ec)
|
||||
|
||||
@@ -2117,7 +2117,7 @@ VALUE rb_vm_bh_to_procval(const rb_execution_context_t *ec, VALUE block_handler)
|
||||
void rb_vm_register_special_exception_str(enum ruby_special_exceptions sp, VALUE exception_class, VALUE mesg);
|
||||
|
||||
#define rb_vm_register_special_exception(sp, e, m) \
|
||||
rb_vm_register_special_exception_str(sp, e, rb_usascii_str_new_static((m), (long)rb_strlen_lit(m)))
|
||||
rb_vm_register_special_exception_str(sp, e, rb_usascii_str_new_static((m), (rb_len_t)rb_strlen_lit(m)))
|
||||
|
||||
void rb_gc_mark_machine_context(const rb_execution_context_t *ec);
|
||||
|
||||
|
||||
+1
-1
@@ -1670,7 +1670,7 @@ static VALUE
|
||||
tracepoint_new_s(rb_execution_context_t *ec, VALUE self, VALUE args)
|
||||
{
|
||||
rb_event_flag_t events = 0;
|
||||
long i;
|
||||
rb_len_t i;
|
||||
rb_len_t argc = RARRAY_LEN(args);
|
||||
|
||||
if (argc > 0) {
|
||||
|
||||
Reference in new issue
Block a user