diff options
| author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2026-05-06 09:18:46 +0900 |
|---|---|---|
| committer | Nobuyoshi Nakada <nobu.nakada@gmail.com> | 2026-05-13 17:37:48 +0900 |
| commit | de8d33295d07c61783f5a68e435bc749faa87b25 (patch) | |
| tree | 480f21e9a299dfafab239aed7aa9fa7c6c61532d | |
| parent | 7dad6c043e3bb88b9e013cc471d62b162d8c352e (diff) | |
pathname: Move same_paths? to pathname.c
| -rw-r--r-- | internal/string.h | 1 | ||||
| -rw-r--r-- | pathname.c | 13 | ||||
| -rw-r--r-- | pathname_builtin.rb | 7 | ||||
| -rw-r--r-- | string.c | 2 |
4 files changed, 15 insertions, 8 deletions
diff --git a/internal/string.h b/internal/string.h index 02e708d341..94a46a9657 100644 --- a/internal/string.h +++ b/internal/string.h @@ -98,6 +98,7 @@ VALUE rb_str_upto_endless_each(VALUE, int (*each)(VALUE, VALUE), VALUE); VALUE rb_str_with_debug_created_info(VALUE, VALUE, int); VALUE rb_str_frozen_bare_string(VALUE); const char *rb_str_null_check(VALUE); +VALUE rb_str_casecmp(VALUE str1, VALUE str2); /* error.c */ void rb_warn_unchilled_literal(VALUE str); diff --git a/pathname.c b/pathname.c index b2f1da8f75..a294a0d730 100644 --- a/pathname.c +++ b/pathname.c @@ -120,6 +120,18 @@ path_sub(int argc, VALUE *argv, VALUE self) return rb_class_new_instance(1, &str, rb_obj_class(self)); } +/* :nodoc: */ +static VALUE +same_paths(VALUE self, VALUE a, VALUE b) +{ + check_strpath(a); + check_strpath(b); + if (CASEFOLD_FILESYSTEM) + return RBOOL(rb_str_casecmp(a, b) == INT2FIX(0)); + else + return rb_str_equal(a, b); +} + /* * Predicate method for root directories. Returns +true+ if the * pathname consists of consecutive slashes. @@ -339,6 +351,7 @@ InitVM_pathname(void) rb_define_method(rb_cPathname, "root?", path_root_p, 0); rb_define_method(rb_cPathname, "absolute?", path_absolute_p, 0); + rb_define_private_method(rb_cPathname, "same_paths?", same_paths, 2); rb_define_private_method(rb_cPathname, "has_separator?", has_separator_p, 1); rb_define_private_method(rb_cPathname, "chop_basename", chop_basename, 1); rb_define_private_method(rb_cPathname, "split_names", split_names, 1); diff --git a/pathname_builtin.rb b/pathname_builtin.rb index ea302c594b..4bd8b002f3 100644 --- a/pathname_builtin.rb +++ b/pathname_builtin.rb @@ -221,13 +221,6 @@ class Pathname # :stopdoc: - if File::FNM_SYSCASE.nonzero? - # Avoid #zero? here because #casecmp can return nil. - private def same_paths?(a, b) a.casecmp(b) == 0 end - else - private def same_paths?(a, b) a == b end - end - attr_reader :path protected :path @@ -4401,7 +4401,7 @@ static VALUE str_casecmp_p(VALUE str1, VALUE str2); * Related: see {Comparing}[rdoc-ref:String@Comparing]. */ -static VALUE +VALUE rb_str_casecmp(VALUE str1, VALUE str2) { VALUE s = rb_check_string_type(str2); |
