diff --git a/dir.c b/dir.c index b1a7a3b8519..9c04e244d1b 100644 --- a/dir.c +++ b/dir.c @@ -1704,7 +1704,7 @@ check_dirname(VALUE dir) { VALUE d = dir; char *path, *pend; - long len; + rb_len_t len; rb_encoding *enc; FilePathValue(d); @@ -3570,7 +3570,7 @@ static VALUE dir_globs(VALUE args, VALUE base, int flags) { VALUE ary = rb_ary_new(); - long i; + rb_len_t i; for (i = 0; i < RARRAY_LEN(args); ++i) { int status; diff --git a/file.c b/file.c index 056a18033ec..24d424c9ec3 100644 --- a/file.c +++ b/file.c @@ -288,7 +288,7 @@ rb_str_encode_ospath(VALUE path) # ifdef HAVE_WORKING_FORK static CFMutableStringRef -mutable_CFString_new(CFStringRef *s, const char *ptr, long len) +mutable_CFString_new(CFStringRef *s, const char *ptr, rb_len_t len) { const CFAllocatorRef alloc = kCFAllocatorDefault; *s = CFStringCreateWithBytesNoCopy(alloc, (const UInt8 *)ptr, len, @@ -324,7 +324,7 @@ rb_CFString_class_initialize_before_fork(void) /* Enough small but non-empty ASCII string to fit in NSTaggedPointerString. */ const char small_str[] = "/"; - long len = sizeof(small_str) - 1; + rb_len_t len = sizeof(small_str) - 1; CFStringRef s; /* * Touch `CFStringCreateWithBytesNoCopy` *twice* because the implementation @@ -340,13 +340,13 @@ rb_CFString_class_initialize_before_fork(void) # endif /* HAVE_WORKING_FORK */ static VALUE -rb_str_append_normalized_ospath(VALUE str, const char *ptr, long len) +rb_str_append_normalized_ospath(VALUE str, const char *ptr, rb_len_t len) { CFIndex buflen = 0; CFRange all; CFStringRef s; CFMutableStringRef m = mutable_CFString_new(&s, ptr, len); - long oldlen = RSTRING_LEN(str); + rb_len_t oldlen = RSTRING_LEN(str); CFStringNormalize(m, kCFStringNormalizationFormC); all = CFRangeMake(0, CFStringGetLength(m)); @@ -360,7 +360,7 @@ rb_str_append_normalized_ospath(VALUE str, const char *ptr, long len) } VALUE -rb_str_normalize_ospath(const char *ptr, long len) +rb_str_normalize_ospath(const char *ptr, rb_len_t len) { const char *p = ptr; const char *e = ptr + len; @@ -484,7 +484,7 @@ apply2files(int (*func)(const char *, void *), int argc, VALUE *argv, void *arg) { VALUE v; const size_t size = sizeof(struct apply_filename); - const long len = (long)(offsetof(struct apply_arg, fn) + (size * argc)); + const rb_len_t len = (rb_len_t)(offsetof(struct apply_arg, fn) + (size * argc)); struct apply_arg *aa = ALLOCV(v, len); aa->errnum = 0; @@ -4812,7 +4812,7 @@ ntfs_tail(const char *path, const char *end, bool mb_enc, rb_encoding *enc) } while (0) #define WITH_ROOTDIFF(stmt) do { \ - long rootdiff = root - buf; \ + rb_len_t rootdiff = root - buf; \ stmt; \ root = buf + rootdiff; \ } while (0) @@ -4821,7 +4821,7 @@ static VALUE copy_home_path(VALUE result, const char *dir) { char *buf; - long dirlen; + rb_len_t dirlen; int encidx; dirlen = strlen(dir); @@ -4929,7 +4929,7 @@ rb_default_home_dir(VALUE result) } static VALUE -ospath_new(const char *ptr, long len, rb_encoding *fsenc) +ospath_new(const char *ptr, rb_len_t len, rb_encoding *fsenc) { #if NORMALIZE_UTF8PATH VALUE path = rb_str_normalize_ospath(ptr, len); @@ -4994,7 +4994,7 @@ rb_file_expand_path_internal(VALUE fname, VALUE dname, int abs_mode, int long_na if (s < fend && s[0] == '~' && abs_mode == 0) { /* execute only if NOT absolute_path() */ BUFINIT(result, buf, p, pend); // TOOD: right size the buffer - long userlen = 0; + rb_len_t userlen = 0; if (s + 1 == fend || isdirsep(s[1])) { buf = 0; b = 0; @@ -5227,7 +5227,7 @@ str_shrink(VALUE str) (void)(NIL_P(dname) ? (dname) : ((dname) = rb_get_path(dname)))) static VALUE -file_expand_path_1(VALUE fname, long extra_capa) +file_expand_path_1(VALUE fname, rb_len_t extra_capa) { VALUE buffer = rb_usascii_str_new(0, RSTRING_LEN(fname) + extra_capa); return rb_file_expand_path_internal(fname, Qnil, 0, 0, buffer); @@ -5395,7 +5395,7 @@ enum rb_realpath_mode { }; static int -realpath_rec(long *prefixlenp, VALUE *resolvedp, const char *unresolved, VALUE fallback, +realpath_rec(rb_len_t *prefixlenp, VALUE *resolvedp, const char *unresolved, VALUE fallback, VALUE loopcheck, enum rb_realpath_mode mode, int last) { const char *pend = unresolved + strlen(unresolved); @@ -5405,7 +5405,7 @@ realpath_rec(long *prefixlenp, VALUE *resolvedp, const char *unresolved, VALUE f while (unresolved < pend) { const char *testname = unresolved; const char *unresolved_firstsep = rb_enc_path_next(unresolved, pend, enc); - long testnamelen = unresolved_firstsep - unresolved; + rb_len_t testnamelen = unresolved_firstsep - unresolved; const char *unresolved_nextname = unresolved_firstsep; while (unresolved_nextname < pend && isdirsep(*unresolved_nextname)) unresolved_nextname++; @@ -5418,7 +5418,7 @@ realpath_rec(long *prefixlenp, VALUE *resolvedp, const char *unresolved, VALUE f const char *resolved_str = RSTRING_PTR(*resolvedp); const char *resolved_names = resolved_str + *prefixlenp; const char *lastsep = strrdirsep(resolved_names, resolved_str + RSTRING_LEN(*resolvedp), mb_enc, enc); - long len = lastsep ? lastsep - resolved_names : 0; + rb_len_t len = lastsep ? lastsep - resolved_names : 0; rb_str_resize(*resolvedp, *prefixlenp + len); } } @@ -5476,7 +5476,7 @@ realpath_rec(long *prefixlenp, VALUE *resolvedp, const char *unresolved, VALUE f VALUE link; VALUE link_orig = Qnil; const char *link_prefix, *link_names; - long link_prefixlen; + rb_len_t link_prefixlen; rb_hash_aset(loopcheck, testpath, ID2SYM(resolving)); link = rb_readlink(testpath, enc); link_prefix = RSTRING_PTR(link); @@ -5528,7 +5528,7 @@ ospath_for_expand(VALUE path) static VALUE rb_check_realpath_emulate(VALUE basedir, VALUE path, rb_encoding *origenc, enum rb_realpath_mode mode) { - long prefixlen; + rb_len_t prefixlen; VALUE resolved; VALUE unresolved_path; VALUE loopcheck; @@ -5537,7 +5537,7 @@ rb_check_realpath_emulate(VALUE basedir, VALUE path, rb_encoding *origenc, enum rb_encoding *enc; char *path_names = NULL, *basedir_names = NULL, *curdir_names = NULL; char *ptr, *prefixptr = NULL, *pend; - long len; + rb_len_t len; #ifdef DOSISH_DRIVE_LETTER VALUE rootdir = path; @@ -5636,7 +5636,7 @@ rb_check_realpath_emulate(VALUE basedir, VALUE path, rb_encoding *origenc, enum return resolved; } -static VALUE rb_file_join(long argc, VALUE *args); +static VALUE rb_file_join(rb_len_t argc, VALUE *args); #ifndef HAVE_REALPATH static VALUE @@ -5797,7 +5797,7 @@ rb_file_s_realdirpath(int argc, VALUE *argv, VALUE klass) } static size_t -rmext(const char *p, long l0, long l1, const char *e, long l2, rb_encoding *enc) +rmext(const char *p, rb_len_t l0, rb_len_t l1, const char *e, rb_len_t l2, rb_encoding *enc) { int len1, len2; unsigned int c; @@ -5836,9 +5836,9 @@ static inline const char * 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; + rb_len_t f = 0, n = -1; - long len = (alllen ? (size_t)*alllen : strlen(name)); + rb_len_t len = (alllen ? (size_t)*alllen : strlen(name)); if (len <= 0) { return name; @@ -6093,7 +6093,7 @@ rb_file_dirname_n(VALUE fname, int n) static inline const char * 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)); + const char *p, *e, *end = name + (len ? *len : (rb_len_t)strlen(name)); p = strrdirsep(name, end, mb_enc, enc); /* get the last path component */ if (!p) @@ -6281,7 +6281,7 @@ file_inspect_join(VALUE ary, VALUE arg, int recur) static VALUE rb_file_join_ary(VALUE ary) { - long len, i; + rb_len_t len, i; VALUE result, tmp; const char *name, *tail; int checked = TRUE; @@ -6345,11 +6345,11 @@ rb_file_join_ary(VALUE ary) } static inline VALUE -rb_file_join_fastpath(long argc, VALUE *args) +rb_file_join_fastpath(rb_len_t argc, VALUE *args) { - long size = argc; + rb_len_t size = argc; - long i; + rb_len_t i; for (i = 0; i < argc; i++) { VALUE tmp = args[i]; if (RB_LIKELY(RB_TYPE_P(tmp, T_STRING) && rb_str_enc_fastpath(tmp))) { @@ -6369,15 +6369,15 @@ rb_file_join_fastpath(long argc, VALUE *args) const char *name = RSTRING_PTR(result); for (i = 1; i < argc; i++) { VALUE tmp = args[i]; - long len = RSTRING_LEN(result); + rb_len_t len = RSTRING_LEN(result); const char *tmp_s; - long tmp_len; + rb_len_t tmp_len; RSTRING_GETMEM(tmp, tmp_s, tmp_len); if (tmp_len > 0 && isdirsep(tmp_s[0])) { // right side has a leading separator, remove left side separators. - long chomp = len; + rb_len_t chomp = len; while (chomp > 0 && isdirsep(name[chomp - 1])) { --chomp; } @@ -6402,7 +6402,7 @@ rb_file_join_fastpath(long argc, VALUE *args) } static inline VALUE -rb_file_join(long argc, VALUE *args) +rb_file_join(rb_len_t argc, VALUE *args) { if (RB_UNLIKELY(argc == 0)) { return rb_str_new(0, 0); @@ -8018,7 +8018,7 @@ static bool fname_need_expansion_p(VALUE fname) { const char *s = RSTRING_PTR(fname); - const long len = RSTRING_LEN(fname); + const rb_len_t len = RSTRING_LEN(fname); const char *send = s + len; if (nav_component_p(s, send)) { @@ -8042,7 +8042,7 @@ fname_need_expansion_p(VALUE fname) static bool expand_feature(VALUE fname, VALUE dname, VALUE buffer, bool need_expansion) { - long dname_len = RSTRING_LEN(dname); + rb_len_t dname_len = RSTRING_LEN(dname); const char *dname_ptr = RSTRING_PTR(dname); RUBY_ASSERT(dname_len > 0); @@ -8066,7 +8066,7 @@ rb_find_file_ext(VALUE *filep, const char *const *ext) { const char *f = StringValueCStr(*filep); VALUE fname = *filep; - long i, j, fnlen; + rb_len_t i, j, fnlen; int expanded = 0; if (!ext[0]) return 0; @@ -8092,7 +8092,7 @@ rb_find_file_ext(VALUE *filep, const char *const *ext) return 0; } - long expanded_load_path_maxlen; + rb_len_t expanded_load_path_maxlen; VALUE load_path = rb_get_expanded_load_path(&expanded_load_path_maxlen); if (!load_path) return 0; @@ -8143,14 +8143,14 @@ rb_find_file(VALUE path) return path; } - long expanded_load_path_maxlen; + rb_len_t expanded_load_path_maxlen; VALUE load_path = rb_get_expanded_load_path(&expanded_load_path_maxlen); if (load_path) { bool need_expansion = fname_need_expansion_p(path); VALUE tmp = rb_str_tmp_new(expanded_load_path_maxlen + RSTRING_LEN(path) + 2); rb_enc_associate_index(tmp, rb_usascii_encindex()); - for (long i = 0; i < RARRAY_LEN(load_path); i++) { + for (rb_len_t i = 0; i < RARRAY_LEN(load_path); i++) { VALUE dname = rb_get_path(RARRAY_AREF(load_path, i)); if (!RSTRING_LEN(dname)) continue; expand_feature(path, dname, tmp, need_expansion); diff --git a/internal/box.h b/internal/box.h index b5ebc2c3d2c..a03d34bbd7c 100644 --- a/internal/box.h +++ b/internal/box.h @@ -25,7 +25,7 @@ struct rb_box_struct { VALUE load_path_snapshot; VALUE load_path_check_cache; VALUE expanded_load_path; - long expanded_load_path_maxlen; + rb_len_t expanded_load_path_maxlen; VALUE loaded_features; VALUE loaded_features_snapshot; VALUE loaded_features_realpaths; diff --git a/internal/file.h b/internal/file.h index 1aa4c670433..859af8d6c3d 100644 --- a/internal/file.h +++ b/internal/file.h @@ -33,7 +33,7 @@ RUBY_SYMBOL_EXPORT_BEGIN VALUE rb_readlink(VALUE path, rb_encoding *enc); #endif #ifdef __APPLE__ -VALUE rb_str_normalize_ospath(const char *ptr, long len); +VALUE rb_str_normalize_ospath(const char *ptr, rb_len_t len); #endif RUBY_SYMBOL_EXPORT_END diff --git a/internal/load.h b/internal/load.h index 745a6e46075..7e7d806637d 100644 --- a/internal/load.h +++ b/internal/load.h @@ -11,7 +11,7 @@ #include "ruby/ruby.h" /* for VALUE */ /* load.c */ -VALUE rb_get_expanded_load_path(long *maxlen); +VALUE rb_get_expanded_load_path(rb_len_t *maxlen); VALUE rb_load_entrypoint(VALUE fname, VALUE wrap); VALUE rb_require_relative_entrypoint(VALUE fname); int rb_require_internal(VALUE fname); diff --git a/load.c b/load.c index c6b151abd3c..52a265f40ee 100644 --- a/load.c +++ b/load.c @@ -55,13 +55,13 @@ enum expand_type { string objects in $LOAD_PATH are frozen. */ static void -rb_construct_expanded_load_path(rb_box_t *box, enum expand_type type, int *has_relative, int *has_non_cache, long *maxlen_out) +rb_construct_expanded_load_path(rb_box_t *box, enum expand_type type, int *has_relative, int *has_non_cache, rb_len_t *maxlen_out) { VALUE load_path = box->load_path; VALUE expanded_load_path = box->expanded_load_path; VALUE snapshot; VALUE ary; - long i, maxlen = 0; + rb_len_t i, maxlen = 0; ary = rb_ary_hidden_new(RARRAY_LEN(load_path)); for (i = 0; i < RARRAY_LEN(load_path); ++i) { @@ -82,7 +82,7 @@ rb_construct_expanded_load_path(rb_box_t *box, enum expand_type type, int *has_r (type == EXPAND_NON_CACHE)) { /* Use cached expanded path. */ expanded_path = RARRAY_AREF(expanded_load_path, i); - long len = RSTRING_LEN(expanded_path); + rb_len_t len = RSTRING_LEN(expanded_path); if (len > maxlen) maxlen = len; rb_ary_push(ary, expanded_path); continue; @@ -98,7 +98,7 @@ rb_construct_expanded_load_path(rb_box_t *box, enum expand_type type, int *has_r as_str = rb_get_path_check_convert(as_str); expanded_path = rb_check_realpath(Qnil, as_str, NULL); if (NIL_P(expanded_path)) expanded_path = as_str; - long len = RSTRING_LEN(expanded_path); + rb_len_t len = RSTRING_LEN(expanded_path); if (len > maxlen) maxlen = len; rb_ary_push(ary, rb_fstring(expanded_path)); } @@ -117,7 +117,7 @@ get_expanded_load_path(rb_box_t *box) const VALUE non_cache = Qtrue; const VALUE load_path_snapshot = box->load_path_snapshot; const VALUE load_path = box->load_path; - long maxlen = 0; + rb_len_t maxlen = 0; if (!rb_ary_shared_with_p(load_path_snapshot, load_path)) { /* The load path was modified. Rebuild the expanded load path. */ @@ -163,7 +163,7 @@ get_expanded_load_path(rb_box_t *box) } VALUE -rb_get_expanded_load_path(long *maxlen) +rb_get_expanded_load_path(rb_len_t *maxlen) { rb_box_t *box = (rb_box_t *)rb_loading_box(); VALUE load_path = get_expanded_load_path((rb_box_t *)box); @@ -208,8 +208,8 @@ feature_key(const char *str, size_t len) static bool is_rbext_path(VALUE feature_path) { - long len = RSTRING_LEN(feature_path); - long rbext_len = rb_strlen_lit(".rb"); + rb_len_t len = RSTRING_LEN(feature_path); + rb_len_t rbext_len = rb_strlen_lit(".rb"); if (len <= rbext_len) return false; return IS_RBEXT(RSTRING_PTR(feature_path) + len - rbext_len); } @@ -401,7 +401,7 @@ get_loaded_features_index(const rb_box_t *box) reset_loaded_features_snapshot(box); features = box->loaded_features_snapshot; - long j = RARRAY_LEN(features); + rb_len_t j = RARRAY_LEN(features); for (i = 0; i < j; i++) { VALUE as_str = rb_ary_entry(features, i); VALUE realpath = rb_hash_aref(previous_realpath_map, as_str); @@ -429,11 +429,11 @@ get_loaded_features_index(const rb_box_t *box) or have any value matching `%r{^\.[^./]*$}`. */ static VALUE -loaded_feature_path(const char *name, long vlen, const char *feature, long len, +loaded_feature_path(const char *name, rb_len_t vlen, const char *feature, rb_len_t len, int type, VALUE load_path) { - long i; - long plen; + rb_len_t i; + rb_len_t plen; const char *e; if (vlen < len+1) return 0; @@ -463,7 +463,7 @@ loaded_feature_path(const char *name, long vlen, const char *feature, long len, for (i = 0; i < RARRAY_LEN(load_path); ++i) { VALUE p = RARRAY_AREF(load_path, i); const char *s = StringValuePtr(p); - long n = RSTRING_LEN(p); + rb_len_t n = RSTRING_LEN(p); if (n != plen) continue; if (n && strncmp(name, s, n)) continue; @@ -474,7 +474,7 @@ loaded_feature_path(const char *name, long vlen, const char *feature, long len, struct loaded_feature_searching { const char *name; - long len; + rb_len_t len; int type; VALUE load_path; const char *result; @@ -503,7 +503,7 @@ rb_feature_p(const rb_box_t *box, const char *feature, const char *ext, int rb, { VALUE features, this_feature_index = Qnil, v, p, load_path = 0; const char *f, *e; - long i, len, elen, n; + rb_len_t i, len, elen, n; st_table *loading_tbl, *features_index; st_data_t data; st_data_t key; @@ -1118,7 +1118,7 @@ rb_f_require_relative(VALUE obj, VALUE fname) static char * find_ext(VALUE str, char **ptr, const char **end) { - long len = RSTRING_LEN(str); + rb_len_t len = RSTRING_LEN(str); *ptr = RSTRING_PTR(str); *end = *ptr + len; return memrchr(*ptr, '.', len); diff --git a/pathname.c b/pathname.c index d221b9ed141..5e2eebc1d00 100644 --- a/pathname.c +++ b/pathname.c @@ -247,7 +247,7 @@ path_absolute_p(VALUE self) { VALUE path = get_strpath(self); const char *ptr = RSTRING_PTR(path); - long len = RSTRING_LEN(path); + rb_len_t len = RSTRING_LEN(path); if (len < 1) return Qfalse; if (drive_letter) { if (len >= 2 && ISALPHA(ptr[0]) && (ptr[1] == ':')) return Qtrue; @@ -387,7 +387,7 @@ add_trailing_separator(VALUE self, VALUE path) static VALUE del_trailing_separator(VALUE self, VALUE path) { - long len = RSTRING_LEN(check_strpath(path)); + rb_len_t len = RSTRING_LEN(check_strpath(path)); if (len <= 0) return path; rb_encoding *enc = rb_enc_get(path); const char *name = RSTRING_PTR(path); diff --git a/ruby.c b/ruby.c index 3d4931ab5e0..31b6ba6c6b2 100644 --- a/ruby.c +++ b/ruby.c @@ -829,7 +829,7 @@ static int process_sflag(int sflag) { if (sflag > 0) { - long n; + rb_len_t n; const VALUE *args; VALUE argv = rb_argv; @@ -2384,7 +2384,7 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt) int i = (int)proc_options(argc, argv, opt, 0); unsigned int dump = opt->dump & dump_exit_bits; const rb_box_t *box = rb_root_box(); - const long loaded_before_enc = RARRAY_LEN(box->loaded_features); + const rb_len_t loaded_before_enc = RARRAY_LEN(box->loaded_features); if (opt->dump & (DUMP_BIT(usage)|DUMP_BIT(help))) { const char *const progname = @@ -2536,7 +2536,7 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt) #endif rb_obj_freeze(opt->script_name); if (IF_UTF8_PATH(uenc != lenc, 1)) { - long i; + rb_len_t i; VALUE load_path = box->load_path; const ID id_initial_load_path_mark = INITIAL_LOAD_PATH_MARK; int modifiable = FALSE; @@ -2566,7 +2566,7 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt) { VALUE loaded_features = box->loaded_features; bool modified = false; - for (long i = loaded_before_enc; i < RARRAY_LEN(loaded_features); ++i) { + for (rb_len_t i = loaded_before_enc; i < RARRAY_LEN(loaded_features); ++i) { VALUE path = RARRAY_AREF(loaded_features, i); if (!(path = copy_str(path, IF_UTF8_PATH(uenc, lenc), true))) continue; if (!modified) { @@ -2728,7 +2728,7 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt) #ifndef DOSISH static void -warn_cr_in_shebang(const char *str, long len) +warn_cr_in_shebang(const char *str, rb_len_t len) { if (len > 1 && str[len-1] == '\n' && str[len-2] == '\r') { rb_warn("shebang line ending with \\r may cause problems"); @@ -2769,7 +2769,7 @@ load_file_internal(VALUE argp_v) VALUE c = 1; /* something not nil */ VALUE line; char *p, *str; - long len; + rb_len_t len; int no_src_enc = !opt->src.enc.name; int no_ext_enc = !opt->ext.enc.name; int no_int_enc = !opt->intern.enc.name; @@ -2907,7 +2907,7 @@ open_load_file(VALUE fname_v, int *xflag) { const char *fname = (fname_v = rb_str_encode_ospath(fname_v), StringValueCStr(fname_v)); - long flen = RSTRING_LEN(fname_v); + rb_len_t flen = RSTRING_LEN(fname_v); VALUE f; int e; diff --git a/win32/file.c b/win32/file.c index b5bf663aee3..f961c09ecb8 100644 --- a/win32/file.c +++ b/win32/file.c @@ -312,10 +312,10 @@ rb_file_expand_path_internal(VALUE fname, VALUE dname, int abs_mode, int long_na /* convert char * to wchar_t */ if (!NIL_P(path)) { - const long path_len = RSTRING_LEN(path); + const rb_len_t path_len = RSTRING_LEN(path); #if SIZEOF_INT < SIZEOF_LONG - if ((long)(int)path_len != path_len) { - rb_raise(rb_eRangeError, "path (%ld bytes) is too long", + if ((rb_len_t)(int)path_len != path_len) { + rb_raise(rb_eRangeError, "path (%"PRIdLEN" bytes) is too long", path_len); } #endif @@ -390,11 +390,11 @@ rb_file_expand_path_internal(VALUE fname, VALUE dname, int abs_mode, int long_na /* convert char * to wchar_t */ if (!NIL_P(dir)) { - const long dir_len = RSTRING_LEN(dir); + const rb_len_t dir_len = RSTRING_LEN(dir); #if SIZEOF_INT < SIZEOF_LONG - if ((long)(int)dir_len != dir_len) { + if ((rb_len_t)(int)dir_len != dir_len) { free(wpath); - rb_raise(rb_eRangeError, "base directory (%ld bytes) is too long", + rb_raise(rb_eRangeError, "base directory (%"PRIdLEN" bytes) is too long", dir_len); } #endif @@ -622,12 +622,12 @@ rb_freopen(VALUE fname, const char *mode, FILE *file) WCHAR *wname, wmode[4]; VALUE wtmp; char *name; - long len; + rb_len_t len; int e = 0, n = MultiByteToWideChar(CP_ACP, 0, mode, -1, NULL, 0); if (n > numberof(wmode)) return EINVAL; MultiByteToWideChar(CP_ACP, 0, mode, -1, wmode, numberof(wmode)); RSTRING_GETMEM(fname, name, len); - n = rb_long2int(len); + n = rb_len2int(len); len = MultiByteToWideChar(CP_UTF8, 0, name, n, NULL, 0); wname = ALLOCV_N(WCHAR, wtmp, len + 1); len = MultiByteToWideChar(CP_UTF8, 0, name, n, wname, len);