From cd3657cf06bb3a32756deea35ea2b6cdfd19eb41 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Sun, 27 Sep 2026 05:23:48 +0900 Subject: [PATCH] Remove CharNext from eval_intern.h ruby_push_include was its last user. A path separator never appears inside a multibyte character, so walk RUBYLIB and -I by bytes everywhere. This also fixes the same skipped separator on Cygwin, where CharNext came from windows.h. Co-Authored-By: Claude Opus 5.5 --- eval_intern.h | 17 ----------------- ruby.c | 11 ++--------- 2 files changed, 2 insertions(+), 26 deletions(-) diff --git a/eval_intern.h b/eval_intern.h index 25ea8a9ef1d..ca4e4b50615 100644 --- a/eval_intern.h +++ b/eval_intern.h @@ -353,21 +353,4 @@ VALUE rb_ec_backtrace_object(const rb_execution_context_t *ec); VALUE rb_ec_backtrace_str_ary(const rb_execution_context_t *ec, long lev, long n); VALUE rb_ec_backtrace_location_ary(const rb_execution_context_t *ec, long lev, long n, bool skip_internal); -#ifndef CharNext /* defined as CharNext[AW] on Windows. */ -# ifdef HAVE_MBLEN -# define CharNext(p) rb_char_next(p) -static inline char * -rb_char_next(const char *p) -{ - if (p) { - int len = mblen(p, RUBY_MBCHAR_MAXSIZE); - p += len > 0 ? len : 1; - } - return (char *)p; -} -# else -# define CharNext(p) ((p) + 1) -# endif -#endif - #endif /* RUBY_EVAL_INTERN_H */ diff --git a/ruby.c b/ruby.c index 58b26320c7b..e1164da05c3 100644 --- a/ruby.c +++ b/ruby.c @@ -454,13 +454,6 @@ ruby_push_include(const char *path, VALUE (*filter)(VALUE)) # define is_path_sep(c) ((c) == sep || (c) == ';') #else # define is_path_sep(c) ((c) == sep) -#endif -#ifdef _WIN32 - /* RUBYLIB and -I are UTF-8 while CharNext() follows the ANSI code - * page, and neither has the separator in a multibyte character. */ -# define next_char(s) ((s) + 1) -#else -# define next_char(s) CharNext(s) #endif if (path == 0) return; @@ -470,10 +463,10 @@ ruby_push_include(const char *path, VALUE (*filter)(VALUE)) while (is_path_sep(*p)) p++; if (!*p) break; - for (s = p; *s && !is_path_sep(*s); s = next_char(s)); + /* separators never appear inside a multibyte character */ + for (s = p; *s && !is_path_sep(*s); s++); len = s - p; #undef is_path_sep -#undef next_char #ifdef __CYGWIN__ if (*s) {