From ba8b0b3a9c867421166083c2eb35204c616beb4b Mon Sep 17 00:00:00 2001 From: git Date: Thu, 29 Jan 2026 07:04:29 +0000 Subject: [PATCH 01/11] Update bundled gems list as of 2026-01-29 --- NEWS.md | 1 + gems/bundled_gems | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index 38ca8667a87ecb..9a1dd9c9337587 100644 --- a/NEWS.md +++ b/NEWS.md @@ -62,6 +62,7 @@ releases. * debug 1.11.1 * mutex_m 0.3.0 * resolv-replace 0.2.0 +* syslog 0.4.0 * rdoc 7.1.0 ### RubyGems and Bundler diff --git a/gems/bundled_gems b/gems/bundled_gems index 98a6ca2cea8ea2..e85061bc0f842e 100644 --- a/gems/bundled_gems +++ b/gems/bundled_gems @@ -32,7 +32,7 @@ resolv-replace 0.2.0 https://github.com/ruby/resolv-replace rinda 0.2.0 https://github.com/ruby/rinda drb 2.2.3 https://github.com/ruby/drb nkf 0.2.0 https://github.com/ruby/nkf -syslog 0.3.0 https://github.com/ruby/syslog +syslog 0.4.0 https://github.com/ruby/syslog csv 3.3.5 https://github.com/ruby/csv repl_type_completor 0.1.12 https://github.com/ruby/repl_type_completor 26b8e964557690c0b539cff8940bcfb1591f1fe6 ostruct 0.6.3 https://github.com/ruby/ostruct From cd26647f537e6c3d1ab3fe5675df47fdbddf8d48 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Thu, 29 Jan 2026 15:30:10 +0900 Subject: [PATCH 02/11] Remove dangling taintedness macros --- include/ruby/internal/fl_type.h | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/include/ruby/internal/fl_type.h b/include/ruby/internal/fl_type.h index 2afb3f1fa348f2..e3878d9ed7d567 100644 --- a/include/ruby/internal/fl_type.h +++ b/include/ruby/internal/fl_type.h @@ -108,8 +108,6 @@ #define RB_OBJ_FREEZE_RAW RB_OBJ_FREEZE_RAW #define RB_OBJ_FROZEN RB_OBJ_FROZEN #define RB_OBJ_FROZEN_RAW RB_OBJ_FROZEN_RAW -#define RB_OBJ_UNTRUST RB_OBJ_TAINT -#define RB_OBJ_UNTRUSTED RB_OBJ_TAINTED /** @endcond */ /** @@ -134,15 +132,6 @@ #define OBJ_FREEZE_RAW RB_OBJ_FREEZE_RAW /**< @old{RB_OBJ_FREEZE_RAW} */ #define OBJ_FROZEN RB_OBJ_FROZEN /**< @old{RB_OBJ_FROZEN} */ #define OBJ_FROZEN_RAW RB_OBJ_FROZEN_RAW /**< @old{RB_OBJ_FROZEN_RAW} */ -#define OBJ_INFECT RB_OBJ_INFECT /**< @old{RB_OBJ_INFECT} */ -#define OBJ_INFECT_RAW RB_OBJ_INFECT_RAW /**< @old{RB_OBJ_INFECT_RAW} */ -#define OBJ_TAINT RB_OBJ_TAINT /**< @old{RB_OBJ_TAINT} */ -#define OBJ_TAINTABLE RB_OBJ_TAINTABLE /**< @old{RB_OBJ_TAINT_RAW} */ -#define OBJ_TAINTED RB_OBJ_TAINTED /**< @old{RB_OBJ_TAINTED} */ -#define OBJ_TAINTED_RAW RB_OBJ_TAINTED_RAW /**< @old{RB_OBJ_TAINTED_RAW} */ -#define OBJ_TAINT_RAW RB_OBJ_TAINT_RAW /**< @old{RB_OBJ_TAINT_RAW} */ -#define OBJ_UNTRUST RB_OBJ_UNTRUST /**< @old{RB_OBJ_TAINT} */ -#define OBJ_UNTRUSTED RB_OBJ_UNTRUSTED /**< @old{RB_OBJ_TAINTED} */ /** @} */ /** From 62493b572d2b6a6984cbbdc32db942dbf894d056 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Thu, 29 Jan 2026 12:18:26 +0900 Subject: [PATCH 03/11] Fix assertions not to be affected by the default encoding --- spec/ruby/core/io/buffer/map_spec.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/spec/ruby/core/io/buffer/map_spec.rb b/spec/ruby/core/io/buffer/map_spec.rb index d980eb0ae0451a..80ee65125ee170 100644 --- a/spec/ruby/core/io/buffer/map_spec.rb +++ b/spec/ruby/core/io/buffer/map_spec.rb @@ -12,11 +12,11 @@ end def open_fixture - File.open("#{__dir__}/../fixtures/read_text.txt", "r+") + File.open("#{__dir__}/../fixtures/read_text.txt", "rb+") end def open_big_file_fixture - File.open(@big_file_name, "r+") + File.open(@big_file_name, "rb+") end after :each do @@ -308,11 +308,11 @@ def open_big_file_fixture @buffer.set_string("test12345") @buffer.get_string.should == "test12345".b - @file.read.should == "abcâdef\n" + @file.read.should == "abcâdef\n".b end it "allows mapping read-only files and modifying the buffer" do - @file = File.open("#{__dir__}/../fixtures/read_text.txt", "r") + @file = File.open("#{__dir__}/../fixtures/read_text.txt", "rb") @buffer = IO::Buffer.map(@file, nil, 0, IO::Buffer::PRIVATE) @buffer.should.private? @@ -323,7 +323,7 @@ def open_big_file_fixture @buffer.set_string("test12345") @buffer.get_string.should == "test12345".b - @file.read.should == "abcâdef\n" + @file.read.should == "abcâdef\n".b end platform_is_not :windows do From d3ea389dec2914e8c247f83091ccea922aadae80 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Thu, 29 Jan 2026 12:23:10 +0900 Subject: [PATCH 04/11] Remove too platform sensitive assertions --- spec/ruby/core/io/buffer/map_spec.rb | 36 ++++------------------------ 1 file changed, 4 insertions(+), 32 deletions(-) diff --git a/spec/ruby/core/io/buffer/map_spec.rb b/spec/ruby/core/io/buffer/map_spec.rb index 80ee65125ee170..7ab08fd425d582 100644 --- a/spec/ruby/core/io/buffer/map_spec.rb +++ b/spec/ruby/core/io/buffer/map_spec.rb @@ -89,24 +89,17 @@ def open_big_file_fixture end context "with an empty file" do - ruby_version_is ""..."4.0" do - it "raises a SystemCallError" do - @file = File.open("#{__dir__}/../fixtures/empty.txt", "r+") - -> { IO::Buffer.map(@file) }.should raise_error(SystemCallError) - end - end - ruby_version_is "4.0" do it "raises ArgumentError" do - @file = File.open("#{__dir__}/../fixtures/empty.txt", "r+") + @file = File.open("#{__dir__}/../fixtures/empty.txt", "rb+") -> { IO::Buffer.map(@file) }.should raise_error(ArgumentError, "Invalid negative or zero file size!") end end end context "with a file opened only for reading" do - it "raises a SystemCallError if no flags are used" do - @file = File.open("#{__dir__}/../fixtures/read_text.txt", "r") + it "raises a SystemCallError unless read-only" do + @file = File.open("#{__dir__}/../fixtures/read_text.txt", "rb") -> { IO::Buffer.map(@file) }.should raise_error(SystemCallError) end end @@ -128,15 +121,6 @@ def open_big_file_fixture end context "if size is 0" do - ruby_version_is ""..."4.0" do - platform_is_not :windows do - it "raises a SystemCallError" do - @file = open_fixture - -> { IO::Buffer.map(@file, 0) }.should raise_error(SystemCallError) - end - end - end - ruby_version_is "4.0" do it "raises ArgumentError" do @file = open_fixture @@ -247,18 +231,6 @@ def open_big_file_fixture -> { IO::Buffer.map(@file, 4, nil) }.should raise_error(TypeError, /no implicit conversion/) end - it "raises a SystemCallError if offset is not an allowed value" do - @file = open_fixture - -> { IO::Buffer.map(@file, 4, 3) }.should raise_error(SystemCallError) - end - - ruby_version_is ""..."4.0" do - it "raises a SystemCallError if offset is negative" do - @file = open_fixture - -> { IO::Buffer.map(@file, 4, -1) }.should raise_error(SystemCallError) - end - end - ruby_version_is "4.0" do it "raises ArgumentError if offset is negative" do @file = open_fixture @@ -279,7 +251,7 @@ def open_big_file_fixture end it "allows mapping read-only files" do - @file = File.open("#{__dir__}/../fixtures/read_text.txt", "r") + @file = File.open("#{__dir__}/../fixtures/read_text.txt", "rb") @buffer = IO::Buffer.map(@file, nil, 0, IO::Buffer::READONLY) @buffer.should.readonly? From e48ed4b979b5c9105238011707465c84a2154060 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Thu, 29 Jan 2026 13:33:32 +0900 Subject: [PATCH 05/11] Do not open to write the fixture files --- spec/ruby/core/io/buffer/map_spec.rb | 31 ++++++++++++++++++------- spec/ruby/core/io/buffer/shared_spec.rb | 9 +++++-- 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/spec/ruby/core/io/buffer/map_spec.rb b/spec/ruby/core/io/buffer/map_spec.rb index 7ab08fd425d582..715aa9d34400ba 100644 --- a/spec/ruby/core/io/buffer/map_spec.rb +++ b/spec/ruby/core/io/buffer/map_spec.rb @@ -2,20 +2,32 @@ describe "IO::Buffer.map" do before :all do - @big_file_name = tmp("big_file") - # Usually 4 kibibytes + 16 bytes - File.write(@big_file_name, "12345678" * (IO::Buffer::PAGE_SIZE / 8 + 2)) + @tmp_files = [] + + @big_file_name = nil + @small_file_name = nil end after :all do - File.delete(@big_file_name) + @tmp_files.each {|file| File.delete(file)} end def open_fixture - File.open("#{__dir__}/../fixtures/read_text.txt", "rb+") + unless @small_file_name + @small_file_name = tmp("read_text.txt") + File.copy_stream(fixture(__dir__, "read_text.txt"), @small_file_name) + @tmp_files << @small_file_name + end + File.open(@small_file_name, "rb+") end def open_big_file_fixture + unless @big_file_name + @big_file_name = tmp("big_file") + # Usually 4 kibibytes + 16 bytes + File.write(@big_file_name, "12345678" * (IO::Buffer::PAGE_SIZE / 8 + 2)) + @tmp_files << @big_file_name + end File.open(@big_file_name, "rb+") end @@ -91,7 +103,8 @@ def open_big_file_fixture context "with an empty file" do ruby_version_is "4.0" do it "raises ArgumentError" do - @file = File.open("#{__dir__}/../fixtures/empty.txt", "rb+") + file_name = tmp("empty.txt") + @file = File.open(file_name, "wb+") -> { IO::Buffer.map(@file) }.should raise_error(ArgumentError, "Invalid negative or zero file size!") end end @@ -99,7 +112,7 @@ def open_big_file_fixture context "with a file opened only for reading" do it "raises a SystemCallError unless read-only" do - @file = File.open("#{__dir__}/../fixtures/read_text.txt", "rb") + @file = File.open(fixture(__dir__, "read_text.txt"), "rb") -> { IO::Buffer.map(@file) }.should raise_error(SystemCallError) end end @@ -251,7 +264,7 @@ def open_big_file_fixture end it "allows mapping read-only files" do - @file = File.open("#{__dir__}/../fixtures/read_text.txt", "rb") + @file = File.open(fixture(__dir__, "read_text.txt"), "rb") @buffer = IO::Buffer.map(@file, nil, 0, IO::Buffer::READONLY) @buffer.should.readonly? @@ -284,7 +297,7 @@ def open_big_file_fixture end it "allows mapping read-only files and modifying the buffer" do - @file = File.open("#{__dir__}/../fixtures/read_text.txt", "rb") + @file = File.open(fixture(__dir__, "read_text.txt"), "rb") @buffer = IO::Buffer.map(@file, nil, 0, IO::Buffer::PRIVATE) @buffer.should.private? diff --git a/spec/ruby/core/io/buffer/shared_spec.rb b/spec/ruby/core/io/buffer/shared_spec.rb index 4f3bce5448fee0..be8c29471af880 100644 --- a/spec/ruby/core/io/buffer/shared_spec.rb +++ b/spec/ruby/core/io/buffer/shared_spec.rb @@ -12,10 +12,15 @@ end it "is true for a non-private buffer created with .map" do - file = File.open("#{__dir__}/../fixtures/read_text.txt", "r+") + path = tmp("read_text.txt") + File.copy_stream(fixture(__dir__, "read_text.txt"), path) + file = File.open(path, "r+") @buffer = IO::Buffer.map(file) - file.close @buffer.shared?.should be_true + ensure + @buffer.free + file.close + File.unlink(path) end it "is false for an unshared buffer" do From d3d1a97486136801f9a37d959f32652385ebc741 Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Thu, 29 Jan 2026 11:13:19 +0100 Subject: [PATCH 06/11] Update to ruby/spec@8c98a84 --- spec/ruby/core/io/buffer/map_spec.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/ruby/core/io/buffer/map_spec.rb b/spec/ruby/core/io/buffer/map_spec.rb index 715aa9d34400ba..d60036307f8774 100644 --- a/spec/ruby/core/io/buffer/map_spec.rb +++ b/spec/ruby/core/io/buffer/map_spec.rb @@ -105,6 +105,7 @@ def open_big_file_fixture it "raises ArgumentError" do file_name = tmp("empty.txt") @file = File.open(file_name, "wb+") + @tmp_files << file_name -> { IO::Buffer.map(@file) }.should raise_error(ArgumentError, "Invalid negative or zero file size!") end end From 6d07151eb141daffa0f36149dcff1cc044c37893 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 28 Jan 2026 15:55:05 +0900 Subject: [PATCH 07/11] Win32: Mark batch files in gitattributes --- .gitattributes | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.gitattributes b/.gitattributes index 6ac6e6fcc3f579..f98c091e3f0464 100644 --- a/.gitattributes +++ b/.gitattributes @@ -7,3 +7,8 @@ tool/update-deps diff=ruby tool/make-snapshot diff=ruby tool/format-release diff=ruby tool/leaked-globals diff=ruby + +# To strip CR from the batch files, set the `diff.dos.textconv` filter +# like as `git config diff.dos.textconv $'sed \'s/\r$//\''`. +*.bat diff=dos +*.cmd diff=dos From 1cc2e68fdc7cb85e5a581a96559fe00e86421998 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Fri, 22 Nov 2024 10:19:46 +0900 Subject: [PATCH 08/11] Win32: Refactor configure * Enable double-quoted options with an `=` sign. * Replace `$` with `$$` in the batch file without CPP. * Support for `--with-destdir`. * Allow Makefile macro definition. (Close GH-15935) --- configure.ac | 7 +- win32/configure.bat | 370 ++++++++++++++++++-------------------------- win32/enc-setup.mak | 4 +- win32/setup.mak | 2 +- 4 files changed, 160 insertions(+), 223 deletions(-) diff --git a/configure.ac b/configure.ac index 4e7367804d3d6b..2d9ccf1442920e 100644 --- a/configure.ac +++ b/configure.ac @@ -743,6 +743,12 @@ AS_CASE(["$GCC:${warnflags+set}:${extra_warnflags:+set}:"], AS_CASE([ $CFLAGS ], [*" -save-temps="*|*" -save-temps "*], [], [ extra_warnflags="$extra_warnflags -Werror=misleading-indentation" ]) + AS_CASE([$target_os], [mingw*], [ + # 64bit Windows is IL32P64; shorten-64-to-32 causes tons of warnigs + extra_warnflags="$extra_warnflags -Wno-shorten-64-to-32" + ], [ + extra_warnflags="$extra_warnflags -Werror=shorten-64-to-32" + ]) # ICC doesn't support -Werror= AS_IF([test $icc_version -gt 0], [ @@ -756,7 +762,6 @@ AS_CASE(["$GCC:${warnflags+set}:${extra_warnflags:+set}:"], -Werror=implicit-function-declaration \ -Werror=implicit-int \ -Werror=pointer-arith \ - -Werror=shorten-64-to-32 \ -Werror=write-strings \ -Werror=old-style-definition \ -Wimplicit-fallthrough=0 \ diff --git a/win32/configure.bat b/win32/configure.bat index 9355caa4d852da..fbe2233d63b8bb 100755 --- a/win32/configure.bat +++ b/win32/configure.bat @@ -1,7 +1,6 @@ @echo off @setlocal EnableExtensions DisableDelayedExpansion || exit /b -1 set PROMPT=$E[94m+$E[m$S -set witharg= if "%~dp0" == "%CD%\" ( echo don't run in win32 directory. @@ -19,180 +18,128 @@ call set "WIN32DIR=%%WIN32DIR:%~x0:/:=:/:%%" call set "WIN32DIR=%%WIN32DIR:/%~n0:/:=:/:%%" set "WIN32DIR=%WIN32DIR:~0,-3%" -set XINCFLAGS= -set XLDFLAGS= +set configure=%~0 +set XINCFLAGS= +set XLDFLAGS= set pathlist= set config_make=confargs~%RANDOM%.mak -set confargs=%config_make:.mak=.c% +set confargs=%config_make:.mak=.sub% +set debug_configure= echo>%config_make% # CONFIGURE -( - echo #define $ $$ // - echo !ifndef CONFIGURE_ARGS - echo #define CONFIGURE_ARGS \ -) >%confargs% +type nul > %confargs% :loop -set opt=%1 -if "%1" == "" goto :end -if "%1" == "--debug-configure" (echo on & shift & goto :loop) -if "%1" == "--no-debug-configure" (echo off & shift & goto :loop) -if "%1" == "--prefix" goto :prefix -if "%1" == "--srcdir" goto :srcdir -if "%1" == "srcdir" goto :srcdir -if "%1" == "--target" goto :target -if "%1" == "target" goto :target -if "%1" == "--with-static-linked-ext" goto :extstatic -if "%1" == "--program-prefix" goto :pprefix -if "%1" == "--program-suffix" goto :suffix -if "%1" == "--program-transform-name" goto :transform_name -if "%1" == "--program-name" goto :installname -if "%1" == "--install-name" goto :installname -if "%1" == "--so-name" goto :soname -if "%1" == "--enable-install-doc" goto :enable-rdoc -if "%1" == "--disable-install-doc" goto :disable-rdoc -if "%1" == "--enable-install-static-library" goto :enable-lib -if "%1" == "--disable-install-static-library" goto :disable-lib -if "%1" == "--enable-debug-env" goto :enable-debug-env -if "%1" == "--disable-debug-env" goto :disable-debug-env -if "%1" == "--enable-devel" goto :enable-devel -if "%1" == "--disable-devel" goto :disable-devel -if "%1" == "--enable-rubygems" goto :enable-rubygems -if "%1" == "--disable-rubygems" goto :disable-rubygems -if "%1" == "--extout" goto :extout -if "%1" == "--path" goto :path -if "%1" == "--with-baseruby" goto :baseruby -if "%1" == "--without-baseruby" goto :nobaseruby -if "%1" == "--with-ntver" goto :ntver -if "%1" == "--with-libdir" goto :libdir -if "%1" == "--with-git" goto :git -if "%1" == "--without-git" goto :nogit -if "%1" == "--without-ext" goto :witharg -if "%1" == "--without-extensions" goto :witharg -if "%1" == "--with-opt-dir" goto :opt-dir -if "%1" == "--with-gmp" goto :gmp -if "%1" == "--with-gmp-dir" goto :gmp-dir -if "%opt:~0,10%" == "--without-" goto :withoutarg -if "%opt:~0,7%" == "--with-" goto :witharg -if "%1" == "-h" goto :help -if "%1" == "--help" goto :help - if "%opt:~0,1%" == "-" ( - echo>>%confargs% %1 \ - set witharg= - ) else if "%witharg%" == "" ( - echo>>%confargs% %1 \ - ) else ( - echo>>%confargs% ,%1\ +if [%1] == [] goto :end ; +if "%~1" == "" (shift & goto :loop) +for /f "delims== tokens=1,*" %%I in ("%~1") do ((set "opt=%%I") && (set "arg=%%J")) + set "eq==" + if "%arg%" == "" if not "%~1" == "%opt%=%arg%" (set "eq=") + shift + if "%opt%" == "--debug-configure" ( + echo on + set "debug_configure=yes" + goto :loop ; ) - shift -goto :loop ; -:srcdir - echo>> %config_make% srcdir = %~2 - echo>>%confargs% --srcdir=%2 \ - shift - shift -goto :loop ; -:prefix - echo>> %config_make% prefix = %~2 - echo>>%confargs% %1=%2 \ - shift - shift -goto :loop ; -:pprefix - echo>> %config_make% PROGRAM_PREFIX = %~2 - echo>>%confargs% %1=%2 \ - shift - shift -goto :loop ; -:suffix - echo>> %config_make% PROGRAM_SUFFIX = %~2 - echo>>%confargs% %1=%2 \ - shift - shift -goto :loop ; -:installname - echo>> %config_make% RUBY_INSTALL_NAME = %~2 - echo>>%confargs% %1=%2 \ - shift - shift -goto :loop ; -:soname - echo>> %config_make% RUBY_SO_NAME = %~2 - echo>>%confargs% %1=%2 \ - shift - shift -goto :loop ; -:transform_name - - shift - shift -goto :loop ; -:target - echo>> %config_make% target = %~2 - echo>>%confargs% --target=%2 \ - if "%~2" == "x64-mswin64" ( - echo>> %config_make% TARGET_OS = mswin64 + if "%opt%" == "--no-debug-configure" ( + echo off + set "debug_configure=" + goto :loop ; ) - shift - shift -goto :loop ; -:extstatic - echo>> %config_make% EXTSTATIC = static - echo>>%confargs% %1 \ - shift -goto :loop ; -:enable-rdoc - echo>> %config_make% RDOCTARGET = rdoc - echo>>%confargs% %1 \ - shift -goto :loop ; -:disable-rdoc - echo>> %config_make% RDOCTARGET = nodoc - echo>>%confargs% %1 \ - shift -goto :loop ; -:enable-lib - echo>> %config_make% INSTALL_STATIC_LIBRARY = yes - echo>>%confargs% %1 \ - shift -goto :loop ; -:disable-lib - echo>> %config_make% INSTALL_STATIC_LIBRARY = no - echo>>%confargs% %1 \ - shift -goto :loop ; -:enable-debug-env - echo>> %config_make% ENABLE_DEBUG_ENV = yes - echo>>%confargs% %1 \ - shift -goto :loop ; -:disable-debug-env - echo>> %config_make% ENABLE_DEBUG_ENV = no - echo>>%confargs% %1 \ - shift -goto :loop ; -:enable-devel - echo>> %config_make% RUBY_DEVEL = yes - echo>>%confargs% %1 \ - shift -goto :loop ; -:disable-devel - echo>> %config_make% RUBY_DEVEL = no - echo>>%confargs% %1 \ - shift -goto :loop ; -:enable-rubygems - echo>> %config_make% USE_RUBYGEMS = yes - echo>>%confargs% %1 \ - shift -goto :loop ; -:disable-rubygems - echo>> %config_make% USE_RUBYGEMS = no - echo>>%confargs% %1 \ - shift + if "%opt%" == "--prefix" goto :dir + if "%opt%" == "srcdir" set "opt=--srcdir" + if "%opt%" == "--srcdir" goto :dir + if "%opt%" == "--target" goto :target + if "%opt%" == "target" goto :target + if "%opt:~0,10%" == "--program-" goto :program_name + if "%opt%" == "--install-name" (set "var=RUBY_INSTALL_NAME" & goto :name) + if "%opt%" == "--so-name" (set "var=RUBY_SO_NAME" & goto :name) + if "%opt%" == "--extout" goto :extout + if "%opt%" == "--path" goto :path + if "%opt:~0,9%" == "--enable-" (set "enable=yes" & goto :enable) + if "%opt:~0,10%" == "--disable-" (set "enable=no" & goto :enable) + if "%opt:~0,10%" == "--without-" goto :withoutarg + if "%opt:~0,7%" == "--with-" goto :witharg + if "%opt%" == "-h" goto :help + if "%opt%" == "--help" goto :help + if "%opt:~0,1%" == "-" ( + goto :unknown_opt + ) + if "%eq%" == "=" ( + set "var=%opt%" + goto :name + ) + set "eq==" +:target + if "%eq%" == "" (set "arg=%~1" & shift) + echo>> %config_make% target = %arg% + echo>>%confargs% "--target=%arg:$=$$%" \ + if "%arg%" == "x64-mswin64" ( + echo>> %config_make% TARGET_OS = mswin64 + ) +goto :loop +:program_name + if "%eq%" == "" (set "arg=%~1" & shift) + for /f "delims=- tokens=1,*" %I in ("%opt%") do set "var=%%J" + if "%var%" == "prefix" (set "var=PROGRAM_PREFIX" & goto :name) + if "%var%" == "suffix" (set "var=PROGRAM_SUFFIX" & goto :name) + if "%var%" == "name" (set "var=RUBY_INSTALL_NAME" & goto :name) + if "%var%" == "transform-name" ( + echo.1>&2 %configure%: --program-transform-name option is not supported + exit /b 1 + ) +goto :unknown_opt +:name + if "%eq%" == "" (set "arg=%~1" & shift) + echo>> %config_make% %var% = %arg% + echo>>%confargs% "%opt%=%arg:$=$$%" \ +goto :loop ; +:dir + if "%eq%" == "" (set "arg=%~1" & shift) + echo>> %config_make% %opt:~2% = %arg:\=/% + echo>>%confargs% "%opt%=%arg:$=$$%" \ +goto :loop ; +:enable + echo>>%confargs% "%opt%" \ + if %enable% == yes (set "opt=%opt:~9%") else (set "opt=%opt:~10%") + if "%opt%" == "rdoc" ( + echo>> %config_make% RDOCTARGET = %enable:yes=r%doc + ) + if "%opt%" == "install-static-library" ( + echo>> %config_make% INSTALL_STATIC_LIBRARY = %enable% + ) + if "%opt%" == "debug-env" ( + echo>> %config_make% ENABLE_DEBUG_ENV = %enable% + ) + if "%opt%" == "devel" ( + echo>> %config_make% RUBY_DEVEL = %enable% + ) + if "%opt%" == "rubygems" ( + echo>> %config_make% USE_RUBYGEMS = %enable% + ) +goto :loop ; +:withoutarg + echo>>%confargs% "%opt%" \ + if "%opt%" == "--without-baseruby" goto :nobaseruby + if "%opt%" == "--without-git" goto :nogit + if "%opt%" == "--without-ext" goto :witharg + if "%opt%" == "--without-extensions" goto :witharg +goto :loop ; +:witharg + if "%opt%" == "--with-static-linked-ext" goto :extstatic + if "%eq%" == "" (set "arg=%~1" & shift) + echo>>%confargs% "%opt%=%arg:$=$$%" \ + if "%opt%" == "--with-baseruby" goto :baseruby + if "%opt%" == "--with-ntver" goto :ntver + if "%opt%" == "--with-libdir" goto :libdir + if "%opt%" == "--with-git" goto :git + if "%opt%" == "--with-opt-dir" goto :opt-dir + if "%opt%" == "--with-gmp-dir" goto :opt-dir + if "%opt%" == "--with-gmp" goto :gmp + if "%opt%" == "--with-destdir" goto :destdir goto :loop ; :ntver ::- For version constants, see ::- https://learn.microsoft.com/en-us/cpp/porting/modifying-winver-and-win32-winnt#remarks - set NTVER=%~2 + if "%eq%" == "" (set "NTVER=%~1" & shift) else (set "NTVER=%arg%") if /i not "%NTVER:~0,2%" == "0x" if /i not "%NTVER:~0,13%" == "_WIN32_WINNT_" ( for %%i in (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) do ( call set NTVER=%%NTVER:%%i=%%i%% @@ -200,62 +147,53 @@ goto :loop ; call set NTVER=_WIN32_WINNT_%%NTVER%% ) echo>> %config_make% NTVER = %NTVER% - echo>>%confargs% %1=%2 \ - shift - shift + echo>>%confargs% "%opt%=%arg:$=$$%" \ goto :loop ; :extout - if not "%~2" == ".ext" (echo>> %config_make% EXTOUT = %~2) - echo>>%confargs% %1=%2 \ - shift - shift + if "%eq%" == "" (set "arg=%~1" & shift) + if not "%arg%" == ".ext" (echo>> %config_make% EXTOUT = %arg%) + echo>>%confargs% "%opt%=%arg:$=$$%" \ goto :loop ; :path - set pathlist=%pathlist%%~2; - echo>>%confargs% %1=%2 \ - shift - shift -goto :loop ; + if "%eq%" == "" (set "arg=%~1" & shift) + set pathlist=%pathlist%%arg%; + echo>>%confargs% "%opt%=%arg:$=$$%" \ +goto :loop ; +:extstatic + if "%eq%" == "" (set "arg=static" & shift) + echo>> %config_make% EXTSTATIC = %arg% + echo>>%confargs% "%opt%=%arg:$=$$%" \ +goto :loop ; :baseruby echo>> %config_make% HAVE_BASERUBY = yes - echo>> %config_make% BASERUBY = %~2 - echo>>%confargs% %1=%2 \ - shift - shift + echo>> %config_make% BASERUBY = %arg% goto :loop ; :nobaseruby echo>> %config_make% HAVE_BASERUBY = no echo>> %config_make% BASERUBY = - echo>>%confargs% %1 \ - shift goto :loop ; :libdir - echo>> %config_make% libdir_basename = %~2 - echo>>%confargs% %1=%2 \ - shift - shift + echo>> %config_make% libdir_basename = %arg% goto :loop ; :git - echo>> %config_make% GIT = %~2 - echo>>%confargs% %1=%2 \ - shift - shift + echo>> %config_make% GIT = %arg% goto :loop ; :nogit echo>> %config_make% GIT = never-use echo>> %config_make% HAVE_GIT = no - echo>>%confargs% %1 \ - shift goto :loop ; :gmp echo>> %config_make% WITH_GMP = yes - echo>>%confargs% %1 \ - shift goto :loop ; -:gmp-dir +:destdir + echo>> %config_make% DESTDIR = %arg% +goto :loop ; :opt-dir - set opt=%~2 - for %%I in (%opt:;= %) do ( + if "%arg%" == "" ( + echo 1>&2 %configure%: missing argument for %opt% + exit /b 1 + ) + for %%I in (%arg:;= %) do ( set d=%%I call pushd %%d:/=\%% && ( call set XINCFLAGS=%%XINCFLAGS%% -I%%CD:\=/%%/include @@ -263,20 +201,11 @@ goto :loop ; popd ) ) -:witharg - echo>>%confargs% %1=%2\ - set witharg=1 - shift - shift -goto :loop ; -:withoutarg - echo>>%confargs% %1 \ - shift goto :loop ; :help echo Configuration: echo --help display this help - echo --srcdir=DIR find the sources in DIR [configure dir or `..'] + echo --srcdir=DIR find the sources in DIR [configure dir or '..'] echo Installation directories: echo --prefix=PREFIX install files in PREFIX [/usr] echo System types: @@ -286,24 +215,26 @@ goto :loop ; echo --with-static-linked-ext link external modules statically echo --with-ext="a,b,..." use extensions a, b, ... echo --without-ext="a,b,..." ignore extensions a, b, ... - echo --with-opt-dir="DIR-LIST" add optional headers and libraries directories separated by `;' + echo --with-opt-dir="DIR-LIST" add optional headers and libraries directories separated by ';' echo --disable-install-doc do not install rdoc indexes during install echo --with-ntver=0xXXXX target NT version (shouldn't use with old SDK) echo --with-ntver=_WIN32_WINNT_XXXX echo --with-ntver=XXXX same as --with-ntver=_WIN32_WINNT_XXXX - echo Note that `,' and `;' need to be enclosed within double quotes in batch file command line. + echo Note that '=,;' need to be enclosed within double quotes in batch file command line. del %confargs% %config_make% goto :exit +:unknown_opt + ( + echo %configure%: unknown option %opt% + echo Try --help option. + ) 1>&2 + exit /b 1 :end +if "%debug_configure%" == "yes" (type %confargs%) ( - echo // - echo configure_args = CONFIGURE_ARGS - echo !endif - echo #undef $ -) >> %confargs% -( - cl -EP %confargs% 2>nul | findstr "! =" - echo. + echo configure_args = \ + type %confargs% + echo # configure_args if NOT "%XINCFLAGS%" == "" echo XINCFLAGS = %XINCFLAGS% if NOT "%XLDFLAGS%" == "" echo XLDFLAGS = %XLDFLAGS% if NOT "%pathlist%" == "" ( @@ -312,7 +243,8 @@ goto :exit call echo LIB = %%pathlist:;=/lib;%%$^(LIB^) ) ) >> %config_make% -del %confargs% > nul +del %confargs% +if "%debug_configure%" == "yes" (type %config_make%) nmake -al -f %WIN32DIR%/setup.mak "WIN32DIR=%WIN32DIR%" ^ config_make=%config_make% ^ diff --git a/win32/enc-setup.mak b/win32/enc-setup.mak index 44345a2f45d6ed..b012161e3256cc 100644 --- a/win32/enc-setup.mak +++ b/win32/enc-setup.mak @@ -4,7 +4,7 @@ BUILTIN_ENCOBJS BUILTIN_TRANSOBJS: $(srcdir)/enc/Makefile.in !include $(srcdir)/enc/Makefile.in BUILTIN_ENCOBJS: - @echo BUILTIN_ENCOBJS = $(BUILTIN_ENCS:.c=.obj) >> $(MAKEFILE) + @echo>> $(MAKEFILE) BUILTIN_ENCOBJS = $(BUILTIN_ENCS:.c=.obj) BUILTIN_TRANSOBJS: - @echo BUILTIN_TRANSOBJS = $(BUILTIN_TRANSES:.trans=.obj) >> $(MAKEFILE) + @echo>> $(MAKEFILE) BUILTIN_TRANSOBJS = $(BUILTIN_TRANSES:.trans=.obj) diff --git a/win32/setup.mak b/win32/setup.mak index 6fc28ebafbc996..3f14e251cd52e0 100644 --- a/win32/setup.mak +++ b/win32/setup.mak @@ -277,5 +277,5 @@ $(BANG)include $$(srcdir)/win32/Makefile.sub << @$(COMSPEC) /C $(srcdir:/=\)\win32\rm.bat config.h config.status -@move /y $(MAKEFILE_NEW) $(MAKEFILE_BACK) > nul 2> nul - @ren $(MAKEFILE) $(MAKEFILE_NEW) + @move /y $(MAKEFILE) $(MAKEFILE_NEW) > nul @echo type 'nmake' to make ruby. From 6cc209600df111549c159ee828c900141ce98f00 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 28 Jan 2026 13:12:02 +0900 Subject: [PATCH 09/11] Win32: Make `optdirs` and `pathlist` macros overridable Also consider paths with space at splitting the `--with-opt-dir` argument. --- win32/configure.bat | 234 +++++++++++++++++++++++--------------------- 1 file changed, 121 insertions(+), 113 deletions(-) diff --git a/win32/configure.bat b/win32/configure.bat index fbe2233d63b8bb..4699457c8d1c32 100755 --- a/win32/configure.bat +++ b/win32/configure.bat @@ -19,8 +19,7 @@ call set "WIN32DIR=%%WIN32DIR:/%~n0:/:=:/:%%" set "WIN32DIR=%WIN32DIR:~0,-3%" set configure=%~0 -set XINCFLAGS= -set XLDFLAGS= +set optdirs= set pathlist= set config_make=confargs~%RANDOM%.mak set confargs=%config_make:.mak=.sub% @@ -44,97 +43,97 @@ for /f "delims== tokens=1,*" %%I in ("%~1") do ((set "opt=%%I") && (set "arg=%%J set "debug_configure=" goto :loop ; ) - if "%opt%" == "--prefix" goto :dir - if "%opt%" == "srcdir" set "opt=--srcdir" - if "%opt%" == "--srcdir" goto :dir - if "%opt%" == "--target" goto :target - if "%opt%" == "target" goto :target - if "%opt:~0,10%" == "--program-" goto :program_name - if "%opt%" == "--install-name" (set "var=RUBY_INSTALL_NAME" & goto :name) - if "%opt%" == "--so-name" (set "var=RUBY_SO_NAME" & goto :name) + if "%opt%" == "--prefix" goto :dir + if "%opt%" == "srcdir" set "opt=--srcdir" + if "%opt%" == "--srcdir" goto :dir + if "%opt%" == "--target" goto :target + if "%opt%" == "target" goto :target + if "%opt:~0,10%" == "--program-" goto :program_name + if "%opt%" == "--install-name" (set "var=RUBY_INSTALL_NAME" & goto :name) + if "%opt%" == "--so-name" (set "var=RUBY_SO_NAME" & goto :name) if "%opt%" == "--extout" goto :extout if "%opt%" == "--path" goto :path - if "%opt:~0,9%" == "--enable-" (set "enable=yes" & goto :enable) - if "%opt:~0,10%" == "--disable-" (set "enable=no" & goto :enable) - if "%opt:~0,10%" == "--without-" goto :withoutarg - if "%opt:~0,7%" == "--with-" goto :witharg - if "%opt%" == "-h" goto :help - if "%opt%" == "--help" goto :help - if "%opt:~0,1%" == "-" ( - goto :unknown_opt - ) - if "%eq%" == "=" ( - set "var=%opt%" - goto :name - ) - set "eq==" -:target - if "%eq%" == "" (set "arg=%~1" & shift) - echo>> %config_make% target = %arg% - echo>>%confargs% "--target=%arg:$=$$%" \ - if "%arg%" == "x64-mswin64" ( - echo>> %config_make% TARGET_OS = mswin64 - ) -goto :loop -:program_name - if "%eq%" == "" (set "arg=%~1" & shift) - for /f "delims=- tokens=1,*" %I in ("%opt%") do set "var=%%J" - if "%var%" == "prefix" (set "var=PROGRAM_PREFIX" & goto :name) - if "%var%" == "suffix" (set "var=PROGRAM_SUFFIX" & goto :name) - if "%var%" == "name" (set "var=RUBY_INSTALL_NAME" & goto :name) - if "%var%" == "transform-name" ( - echo.1>&2 %configure%: --program-transform-name option is not supported - exit /b 1 - ) -goto :unknown_opt -:name - if "%eq%" == "" (set "arg=%~1" & shift) - echo>> %config_make% %var% = %arg% - echo>>%confargs% "%opt%=%arg:$=$$%" \ -goto :loop ; -:dir - if "%eq%" == "" (set "arg=%~1" & shift) - echo>> %config_make% %opt:~2% = %arg:\=/% - echo>>%confargs% "%opt%=%arg:$=$$%" \ -goto :loop ; -:enable - echo>>%confargs% "%opt%" \ - if %enable% == yes (set "opt=%opt:~9%") else (set "opt=%opt:~10%") - if "%opt%" == "rdoc" ( - echo>> %config_make% RDOCTARGET = %enable:yes=r%doc - ) - if "%opt%" == "install-static-library" ( - echo>> %config_make% INSTALL_STATIC_LIBRARY = %enable% - ) - if "%opt%" == "debug-env" ( - echo>> %config_make% ENABLE_DEBUG_ENV = %enable% - ) - if "%opt%" == "devel" ( - echo>> %config_make% RUBY_DEVEL = %enable% - ) - if "%opt%" == "rubygems" ( - echo>> %config_make% USE_RUBYGEMS = %enable% - ) -goto :loop ; -:withoutarg - echo>>%confargs% "%opt%" \ + if "%opt:~0,9%" == "--enable-" (set "enable=yes" & goto :enable) + if "%opt:~0,10%" == "--disable-" (set "enable=no" & goto :enable) + if "%opt:~0,10%" == "--without-" goto :withoutarg + if "%opt:~0,7%" == "--with-" goto :witharg + if "%opt%" == "-h" goto :help + if "%opt%" == "--help" goto :help + if "%opt:~0,1%" == "-" ( + goto :unknown_opt + ) + if "%eq%" == "=" ( + set "var=%opt%" + goto :name + ) + set "eq==" +:target + if "%eq%" == "" (set "arg=%~1" & shift) + echo>> %config_make% target = %arg% + echo>>%confargs% "--target=%arg:$=$$%" \ + if "%arg%" == "x64-mswin64" ( + echo>> %config_make% TARGET_OS = mswin64 + ) +goto :loop +:program_name + if "%eq%" == "" (set "arg=%~1" & shift) + for /f "delims=- tokens=1,*" %I in ("%opt%") do set "var=%%J" + if "%var%" == "prefix" (set "var=PROGRAM_PREFIX" & goto :name) + if "%var%" == "suffix" (set "var=PROGRAM_SUFFIX" & goto :name) + if "%var%" == "name" (set "var=RUBY_INSTALL_NAME" & goto :name) + if "%var%" == "transform-name" ( + echo.1>&2 %configure%: --program-transform-name option is not supported + exit /b 1 + ) +goto :unknown_opt +:name + if "%eq%" == "" (set "arg=%~1" & shift) + echo>> %config_make% %var% = %arg% + echo>>%confargs% "%opt%=%arg:$=$$%" \ +goto :loop ; +:dir + if "%eq%" == "" (set "arg=%~1" & shift) + echo>> %config_make% %opt:~2% = %arg:\=/% + echo>>%confargs% "%opt%=%arg:$=$$%" \ +goto :loop ; +:enable + echo>>%confargs% "%opt%" \ + if %enable% == yes (set "opt=%opt:~9%") else (set "opt=%opt:~10%") + if "%opt%" == "rdoc" ( + echo>> %config_make% RDOCTARGET = %enable:yes=r%doc + ) + if "%opt%" == "install-static-library" ( + echo>> %config_make% INSTALL_STATIC_LIBRARY = %enable% + ) + if "%opt%" == "debug-env" ( + echo>> %config_make% ENABLE_DEBUG_ENV = %enable% + ) + if "%opt%" == "devel" ( + echo>> %config_make% RUBY_DEVEL = %enable% + ) + if "%opt%" == "rubygems" ( + echo>> %config_make% USE_RUBYGEMS = %enable% + ) +goto :loop ; +:withoutarg + echo>>%confargs% "%opt%" \ if "%opt%" == "--without-baseruby" goto :nobaseruby if "%opt%" == "--without-git" goto :nogit if "%opt%" == "--without-ext" goto :witharg if "%opt%" == "--without-extensions" goto :witharg -goto :loop ; -:witharg - if "%opt%" == "--with-static-linked-ext" goto :extstatic - if "%eq%" == "" (set "arg=%~1" & shift) - echo>>%confargs% "%opt%=%arg:$=$$%" \ - if "%opt%" == "--with-baseruby" goto :baseruby - if "%opt%" == "--with-ntver" goto :ntver - if "%opt%" == "--with-libdir" goto :libdir - if "%opt%" == "--with-git" goto :git +goto :loop ; +:witharg + if "%opt%" == "--with-static-linked-ext" goto :extstatic + if "%eq%" == "" (set "arg=%~1" & shift) + echo>>%confargs% "%opt%=%arg:$=$$%" \ + if "%opt%" == "--with-baseruby" goto :baseruby + if "%opt%" == "--with-ntver" goto :ntver + if "%opt%" == "--with-libdir" goto :libdir + if "%opt%" == "--with-git" goto :git if "%opt%" == "--with-opt-dir" goto :opt-dir - if "%opt%" == "--with-gmp-dir" goto :opt-dir + if "%opt%" == "--with-gmp-dir" goto :opt-dir if "%opt%" == "--with-gmp" goto :gmp - if "%opt%" == "--with-destdir" goto :destdir + if "%opt%" == "--with-destdir" goto :destdir goto :loop ; :ntver ::- For version constants, see @@ -156,14 +155,14 @@ goto :loop ; goto :loop ; :path if "%eq%" == "" (set "arg=%~1" & shift) - set pathlist=%pathlist%%arg%; + set "pathlist=%pathlist%%arg:\=/%;" + echo>>%confargs% "%opt%=%arg:$=$$%" \ +goto :loop ; +:extstatic + if "%eq%" == "" (set "arg=static" & shift) + echo>> %config_make% EXTSTATIC = %arg% echo>>%confargs% "%opt%=%arg:$=$$%" \ goto :loop ; -:extstatic - if "%eq%" == "" (set "arg=static" & shift) - echo>> %config_make% EXTSTATIC = %arg% - echo>>%confargs% "%opt%=%arg:$=$$%" \ -goto :loop ; :baseruby echo>> %config_make% HAVE_BASERUBY = yes echo>> %config_make% BASERUBY = %arg% @@ -185,22 +184,21 @@ goto :loop ; :gmp echo>> %config_make% WITH_GMP = yes goto :loop ; -:destdir - echo>> %config_make% DESTDIR = %arg% -goto :loop ; +:destdir + echo>> %config_make% DESTDIR = %arg% +goto :loop ; :opt-dir - if "%arg%" == "" ( - echo 1>&2 %configure%: missing argument for %opt% - exit /b 1 - ) - for %%I in (%arg:;= %) do ( - set d=%%I - call pushd %%d:/=\%% && ( - call set XINCFLAGS=%%XINCFLAGS%% -I%%CD:\=/%%/include - call set XLDFLAGS=%%XLDFLAGS%% -libpath:%%CD:\=/%%/lib + if "%arg%" == "" ( + echo 1>&2 %configure%: missing argument for %opt% + exit /b 1 + ) + :optdir-loop + for /f "delims=; tokens=1,*" %%I in ("%arg%") do (set "d=%%I" & set "arg=%%J") + pushd %d:/=\% && ( + set "optdirs=%optdirs%;%CD:\=/%" popd ) - ) + if not "%arg%" == "" goto :optdir-loop goto :loop ; :help echo Configuration: @@ -223,26 +221,36 @@ goto :loop ; echo Note that '=,;' need to be enclosed within double quotes in batch file command line. del %confargs% %config_make% goto :exit -:unknown_opt - ( - echo %configure%: unknown option %opt% - echo Try --help option. - ) 1>&2 - exit /b 1 +:unknown_opt + ( + echo %configure%: unknown option %opt% + echo Try --help option. + ) 1>&2 + exit /b 1 :end if "%debug_configure%" == "yes" (type %confargs%) +if not "%optdirs%" == "" (echo>>%config_make% optdirs = %optdirs:~1%) ( + echo. echo configure_args = \ type %confargs% echo # configure_args - if NOT "%XINCFLAGS%" == "" echo XINCFLAGS = %XINCFLAGS% - if NOT "%XLDFLAGS%" == "" echo XLDFLAGS = %XLDFLAGS% - if NOT "%pathlist%" == "" ( + + echo. + echo !if "$(optdirs)" != "" + for %%I in ("$(optdirs:\=/)" "$(optdirs:/;=;)") do @echo optdirs = %%~I + echo XINCFLAGS = -I"$(optdirs:;=/include" -I")/include" + echo XLDFLAGS = -libpath:"$(optdirs:;=/lib" -libpath:")/lib" + echo !endif + + if not "%pathlist%" == "" ( + echo. call echo PATH = %%pathlist:;=/bin;%%$^(PATH^) call echo INCLUDE = %%pathlist:;=/include;%%$^(INCLUDE^) call echo LIB = %%pathlist:;=/lib;%%$^(LIB^) ) ) >> %config_make% + del %confargs% if "%debug_configure%" == "yes" (type %config_make%) From b5ecfd1eba928d577d100fc3377375b55bf3cbb1 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 28 Jan 2026 15:53:15 +0900 Subject: [PATCH 10/11] Win32: Refactor target detection Previously, Visual C++ had only one toolchain for the x86 family, and the only option was to select the target processor level. In recent versions, there are multiple toolchains with the same command name for each host/target platform combination, so it is no longer possible to select the target with a command-line option. Also, configure.bat assumes that the toolchain has been configured before it is executed, so selecting it from this batch file is meaningless. Therefore, the only possible check is whether the specified target and compiler match. --- win32/configure.bat | 24 +++++++++------ win32/setup.mak | 75 ++++++++++++++++++++++++++++++++++----------- 2 files changed, 71 insertions(+), 28 deletions(-) diff --git a/win32/configure.bat b/win32/configure.bat index 4699457c8d1c32..94eed7bc128b72 100755 --- a/win32/configure.bat +++ b/win32/configure.bat @@ -66,15 +66,18 @@ for /f "delims== tokens=1,*" %%I in ("%~1") do ((set "opt=%%I") && (set "arg=%%J set "var=%opt%" goto :name ) - set "eq==" + set "target=%opt%" + echo>>%confargs% "--target=%opt:$=$$%" \ +goto :loop ; :target if "%eq%" == "" (set "arg=%~1" & shift) - echo>> %config_make% target = %arg% - echo>>%confargs% "--target=%arg:$=$$%" \ - if "%arg%" == "x64-mswin64" ( - echo>> %config_make% TARGET_OS = mswin64 + if "%arg%" == "" ( + echo 1>&2 %configure%: missing argument for %opt% + exit /b 1 ) -goto :loop + set "target=%arg%" + echo>>%confargs% "--target=%arg:$=$$%" \ +goto :loop ; :program_name if "%eq%" == "" (set "arg=%~1" & shift) for /f "delims=- tokens=1,*" %I in ("%opt%") do set "var=%%J" @@ -220,7 +223,7 @@ goto :loop ; echo --with-ntver=XXXX same as --with-ntver=_WIN32_WINNT_XXXX echo Note that '=,;' need to be enclosed within double quotes in batch file command line. del %confargs% %config_make% -goto :exit +goto :EOF :unknown_opt ( echo %configure%: unknown option %opt% @@ -256,6 +259,7 @@ if "%debug_configure%" == "yes" (type %config_make%) nmake -al -f %WIN32DIR%/setup.mak "WIN32DIR=%WIN32DIR%" ^ config_make=%config_make% ^ - MAKEFILE=Makefile.new MAKEFILE_BACK=Makefile.old MAKEFILE_NEW=Makefile -:exit -@endlocal + MAKEFILE=Makefile.new MAKEFILE_BACK=Makefile.old MAKEFILE_NEW=Makefile ^ + %target% +set error=%ERRORLEVEL% +if exist %config_make% del /q %config_make% diff --git a/win32/setup.mak b/win32/setup.mak index 3f14e251cd52e0..19ace3445c2568 100644 --- a/win32/setup.mak +++ b/win32/setup.mak @@ -22,7 +22,7 @@ MAKE = $(MAKE) -f $(MAKEFILE) MAKEFILE = Makefile !endif CPU = PROCESSOR_LEVEL -CC = $(CC) -nologo -source-charset:utf-8 +CC = $(CC) -nologo CPP = $(CC) -EP !if "$(HAVE_BASERUBY)" != "no" && "$(BASERUBY)" == "" BASERUBY = ruby @@ -35,13 +35,14 @@ i586-mswin32: -prologue- -i586- -epilogue- i686-mswin32: -prologue- -i686- -epilogue- alpha-mswin32: -prologue- -alpha- -epilogue- x64-mswin64: -prologue- -x64- -epilogue- +arm64-mswin64: -prologue- -arm64- -epilogue- -prologue-: -basic-vars- -baseruby- -gmp- -generic-: -osname- -basic-vars-: nul @rem <<$(MAKEFILE) -### Makefile for ruby $(TARGET_OS) ### +### Makefile for ruby ### MAKE = nmake srcdir = $(srcdir:\=/) prefix = $(prefix:\=/) @@ -70,20 +71,31 @@ int main(void) {mpz_init(x); return 0;} @echo # TARGET>>$(MAKEFILE) -osname32-: -osname-section- - @echo TARGET_OS = mswin32>>$(MAKEFILE) + @$(CPP) -Tc <<"checking if target OS is 32bit" >>$(MAKEFILE) +#ifdef _WIN64 +#error +#else +TARGET_OS = mswin32 +#endif +<< -osname64-: -osname-section- - @echo TARGET_OS = mswin64>>$(MAKEFILE) + @$(CPP) -Tc <<"checking if target OS is 64bit" >>$(MAKEFILE) +#ifndef _WIN64 +#error +#else +TARGET_OS = mswin64 +#endif +<< -osname-: -osname-section- - @echo !ifndef TARGET_OS>>$(MAKEFILE) - @($(CC) -c < nul && (echo TARGET_OS = mswin32) || (echo TARGET_OS = mswin64)) >>$(MAKEFILE) + @$(CPP) -Tc <<"checking for target OS" 2>nul | findstr = >>$(MAKEFILE) #ifdef _WIN64 -#error +TARGET_OS = mswin64 +#else +TARGET_OS = mswin32 #endif << - @echo !endif>>$(MAKEFILE) - @$(WIN32DIR:/=\)\rm.bat conftest.* -compiler-: -compiler-section- -version- -runtime- -headers- @@ -211,27 +223,54 @@ del %0 & exit << -generic-: nul - @$(CPP) <nul | findstr = >>$(MAKEFILE) + @$(CPP) -Tc <nul | findstr = >>$(MAKEFILE) #if defined _M_ARM64 MACHINE = arm64 #elif defined _M_X64 MACHINE = x64 #else MACHINE = x86 -#endif -<< !if defined($(CPU)) - @echo>>$(MAKEFILE) $(CPU) = $(PROCESSOR_LEVEL) +$(CPU) = $(PROCESSOR_LEVEL) !endif +#endif -alpha-: -osname32- - @echo MACHINE = alpha>>$(MAKEFILE) + @$(CPP) -Tc <<"checking if compiler is for $(@:-=)" >>$(MAKEFILE) +#ifndef _M_ALPHA +#error Not compiler for $(@:-=) +#else +MACHINE = $(@:-=) +#endif +<< + -x64-: -osname64- - @echo MACHINE = x64>>$(MAKEFILE) + @$(CPP) -Tc <<"checking if compiler is for $(@:-=)" >>$(MAKEFILE) +#ifndef _M_AMD64 +#error Not compiler for $(@:-=) +#else +MACHINE = $(@:-=) +#endif +<< + -ix86-: -osname32- - @echo MACHINE = x86>>$(MAKEFILE) + @$(CPP) -Tc <<"checking if compiler is for $(@:-=)" >>$(MAKEFILE) +#ifndef _M_IX86 +#error Not compiler for $(@:-=) +#else +#define ix86 x86 +MACHINE = $(@:-=) +#endif +<< + -arm64-: -osname64- - @echo MACHINE = arm64>>$(MAKEFILE) + @$(CPP) -Tc <<"checking if compiler is for $(@:-=)" >>$(MAKEFILE) +#ifndef _M_ARM64 +#error Not compiler for $(@:-=) +#else +MACHINE = $(@:-=) +#endif +<< -i386-: -ix86- @echo $(CPU) = 3>>$(MAKEFILE) @@ -261,7 +300,7 @@ MACHINE = x86 # XLDFLAGS = # RFLAGS = -r # EXTLIBS = -CC = $(CC) +CC = $(CC) -source-charset:utf-8 !if "$(AS)" != "ml64" AS = $(AS) -nologo !endif From 5299276e421c3f11c944069fe5c655628634b9e1 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 28 Jan 2026 18:35:27 +0900 Subject: [PATCH 11/11] win32: Prevent broken substitution string when variable is undefined Avoids an issue where `%undefined:A=B%` expands to a literal `A=B` because the parser fails to find the variable before the colon, then parses the following percent as the next variable expansion. Added a definition check to ensure safe expansion. --- win32/configure.bat | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/win32/configure.bat b/win32/configure.bat index 94eed7bc128b72..d4e010ac4b0374 100755 --- a/win32/configure.bat +++ b/win32/configure.bat @@ -66,8 +66,16 @@ for /f "delims== tokens=1,*" %%I in ("%~1") do ((set "opt=%%I") && (set "arg=%%J set "var=%opt%" goto :name ) - set "target=%opt%" - echo>>%confargs% "--target=%opt:$=$$%" \ + set "arg=%opt%" + set "eq==" + set "opt=--target" + set "target=%arg%" +:loopend + if not "%arg%" == "" ( + echo>>%confargs% "%opt%=%arg:$=$$%" \ + ) else ( + echo>>%confargs% "%opt%%eq%" \ + ) goto :loop ; :target if "%eq%" == "" (set "arg=%~1" & shift) @@ -76,6 +84,7 @@ goto :loop ; exit /b 1 ) set "target=%arg%" + set "opt=--target" echo>>%confargs% "--target=%arg:$=$$%" \ goto :loop ; :program_name @@ -92,13 +101,11 @@ goto :unknown_opt :name if "%eq%" == "" (set "arg=%~1" & shift) echo>> %config_make% %var% = %arg% - echo>>%confargs% "%opt%=%arg:$=$$%" \ -goto :loop ; +goto :loopend ; :dir if "%eq%" == "" (set "arg=%~1" & shift) echo>> %config_make% %opt:~2% = %arg:\=/% - echo>>%confargs% "%opt%=%arg:$=$$%" \ -goto :loop ; +goto :loopend ; :enable echo>>%confargs% "%opt%" \ if %enable% == yes (set "opt=%opt:~9%") else (set "opt=%opt:~10%") @@ -128,7 +135,11 @@ goto :loop ; :witharg if "%opt%" == "--with-static-linked-ext" goto :extstatic if "%eq%" == "" (set "arg=%~1" & shift) - echo>>%confargs% "%opt%=%arg:$=$$%" \ + if not "%arg%" == "" ( + echo>>%confargs% "%opt%=%arg:$=$$%" \ + ) else ( + echo>>%confargs% "%opt%%eq%" \ + ) if "%opt%" == "--with-baseruby" goto :baseruby if "%opt%" == "--with-ntver" goto :ntver if "%opt%" == "--with-libdir" goto :libdir @@ -149,23 +160,19 @@ goto :loop ; call set NTVER=_WIN32_WINNT_%%NTVER%% ) echo>> %config_make% NTVER = %NTVER% - echo>>%confargs% "%opt%=%arg:$=$$%" \ -goto :loop ; +goto :loopend ; :extout if "%eq%" == "" (set "arg=%~1" & shift) if not "%arg%" == ".ext" (echo>> %config_make% EXTOUT = %arg%) - echo>>%confargs% "%opt%=%arg:$=$$%" \ -goto :loop ; +goto :loopend ; :path if "%eq%" == "" (set "arg=%~1" & shift) set "pathlist=%pathlist%%arg:\=/%;" - echo>>%confargs% "%opt%=%arg:$=$$%" \ -goto :loop ; +goto :loopend ; :extstatic if "%eq%" == "" (set "arg=static" & shift) echo>> %config_make% EXTSTATIC = %arg% - echo>>%confargs% "%opt%=%arg:$=$$%" \ -goto :loop ; +goto :loopend ; :baseruby echo>> %config_make% HAVE_BASERUBY = yes echo>> %config_make% BASERUBY = %arg%