From 21709a58682b9fef53e3e3dec97a0fe4498334e3 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Fri, 12 Sep 2025 14:58:07 -0700 Subject: [PATCH] merge revision(s) 7a05dbc47831a655a1ef8a1635f88292acd325da: [Backport #21561] File.dirname: return consistent encoding for `"."` [Bug #21561] It's preferable if the method is consistent in the encoding in the returned string. --- file.c | 7 +++++-- version.h | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/file.c b/file.c index 585dd90665..414479fae4 100644 --- a/file.c +++ b/file.c @@ -4947,8 +4947,11 @@ rb_file_dirname_n(VALUE fname, int n) break; } } - if (p == name) - return rb_usascii_str_new2("."); + if (p == name) { + dirname = rb_str_new(".", 1); + rb_enc_copy(dirname, fname); + return dirname; + } #ifdef DOSISH_DRIVE_LETTER if (has_drive_letter(name) && isdirsep(*(name + 2))) { const char *top = skiproot(name + 2, end, enc); diff --git a/version.h b/version.h index 631d03013b..66b6b78882 100644 --- a/version.h +++ b/version.h @@ -11,7 +11,7 @@ # define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR #define RUBY_VERSION_TEENY 5 #define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR -#define RUBY_PATCHLEVEL 53 +#define RUBY_PATCHLEVEL 54 #include "ruby/version.h" #include "ruby/internal/abi.h"