From 771de37f8b2fbe994b2c309149f0d4db6b703a36 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Wed, 19 Aug 2026 14:49:23 +0900 Subject: [PATCH] Set the long path bit only in ruby_setup `ruby_setup` runs for `ruby.exe` too, so calling this from `rb_w32_sysinit` as well was redundant. Nothing between the two touches a path long enough to care, including the wildcard expansion in `w32_cmdvector`, which does not expand a result over 260 characters either way. Co-Authored-By: Claude Opus 5 --- win32/win32.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/win32/win32.c b/win32/win32.c index 4bf16bc0187..d6d4acbb817 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -853,9 +853,8 @@ static int w32_cmdvector(const WCHAR *, char ***, UINT, rb_encoding *); * runtime , whose maintainers have * proposed to drop it . * - * Called from rb_w32_sysinit, which runs before the VM exists, and from - * ruby_setup, so that a program which embeds libruby without calling - * ruby_sysinit gets it as well. */ + * Called from ruby_setup, not from rb_w32_sysinit, which a program that + * embeds libruby is not expected to call. */ void rb_w32_init_long_paths(void) { @@ -863,15 +862,11 @@ rb_w32_init_long_paths(void) enum {peb_bit_field_offset = 3, is_long_path_aware_process = 0x80}; typedef long (WINAPI version_func)(OSVERSIONINFOW *); typedef void *(WINAPI peb_func)(void); - static int done = 0; version_func *pRtlGetVersion; peb_func *pRtlGetCurrentPeb; OSVERSIONINFOW osvi; BYTE *bit_field; - if (done) return; - done = 1; - pRtlGetVersion = (version_func *)get_proc_address("ntdll.dll", "RtlGetVersion", NULL); if (!pRtlGetVersion) return; memset(&osvi, 0, sizeof(osvi)); @@ -900,7 +895,6 @@ rb_w32_sysinit(int *argc, char ***argv) SetErrorMode(SEM_FAILCRITICALERRORS|SEM_NOGPFAULTERRORBOX); get_version(); - rb_w32_init_long_paths(); // // subvert cmd.exe's feeble attempt at command line parsing