Skip to content

Conversation

@larskanis
Copy link
Contributor

@larskanis larskanis commented Dec 27, 2022

_wputenv_s is available in all supported MSVC versions and in MINGW since years. Dropping support for _wputenv without _s allows to remove some complexity and duplication, since rb_w32_home_dir() is usable in the win32 initialization then.

Also fix a single ANSI call to SetEnvironmentVariable() by using the Unicode equivalent. I added a test case for it.

@larskanis larskanis force-pushed the remove-wputenv branch 2 times, most recently from 6d8c733 to 653444f Compare December 28, 2022 22:09
@larskanis larskanis force-pushed the remove-wputenv branch 3 times, most recently from 7925ef3 to c04c4cb Compare October 27, 2023 13:10
@larskanis
Copy link
Contributor Author

@nobu Now that #7033 is merged, I rebased and extended this PR.

Using _wputenv_s simplifies the code and we can avoid code duplication by using rb_w32_home_dir() to initialize ENV['HOME'].
Windows Vista removed the limit to 32768 bytes environment block.
Also MINGW supports _wputenv_s() for years.
This only makes a difference when setting an empty value to a Unicode key.
@larskanis
Copy link
Contributor Author

Thank you @hsbt for rebasing! I still believe that this PR is valuable, especially since it fixes a corner case bug on Windows.

@hsbt
Copy link
Member

hsbt commented Sep 24, 2024

The changes of hash.c seems fine. But I'm not sure about win32/* changes.

@nobu Can you review them?

@hsbt hsbt merged commit acf28e8 into ruby:master Sep 24, 2024
107 checks passed
@larskanis larskanis deleted the remove-wputenv branch September 24, 2024 05:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants