Repository navigation
locale: decode $'\u/\U under the surviving locale after a failed setlocale - #3622
Merged
Merged
Conversation
…equested name GNU locale.c set_locale_var is stateful: a failed setlocale() warns but leaves the previously effective locale in force, so under an un-activatable name (zh_TW.big5 / bogus names) a surviving UTF-8 locale still decodes $'\u3b1' to α, while an ACTIVATABLE non-UTF-8 name (C) does impose byte semantics. locale_name_selects_utf8 decided from the requested name alone: any non-UTF-8 charset name returned false without checking whether setlocale could activate it — so $'\u3b1' stayed literal where GNU decodes (glob2.sub run-glob-test divergence, Refs #2666). Fix: when the named locale is not activatable, fall back to the effective codeset (nl_langinfo CODESET) instead of assuming bytes. Every consumer of the predicate — the ansi.rs $'\u'/'\U' gate, the echo -e face, and the multibyte flag in trap_stack_builtins — now shares the same stateful model. Fixes #3619 Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Member
Author
|
【WIN-AGENT-AUDIT】PR #3622 第1轮 — 建议:FAIL 机制核查:
腿(逐项给数字与名字):
F 点(建议 FAIL):
未跑/VOID 的腿:
|
…#3619) libc exposes neither nl_langinfo nor CODESET for Android targets, so the cfg(unix) arm failed the linux/android cross-target check. Android now shares the non-Unix fallback (requested-name model), matching its pre-change behavior; the pin gets the same gate since the fallback cannot observe the surviving locale there.
Member
Author
|
【WIN-AGENT-AUDIT】 机制核查:
腿:
F 点:无。 续作记录:
未跑/VOID 的腿:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
GNU
locale.c set_locale_varis stateful: a failedsetlocale()warns but leaves the previously effective locale in force. rubash's\u/\Udecode gate (src/lexer/ansi.rs→locale::locale_name_selects_utf8) decided from the requested locale name alone — any non-UTF-8 charset name returned false without checking whethersetlocalecould actually activate it. UnderLC_ALL=zh_TW.big5(no big5 archive) with a UTF-8 locale already in force, GNU still decodes$'\\u3b1'→αwhile rubash emitted the literal\u03B1(glob2.sub divergence, Refs #2666).Fix
locale_name_selects_utf8now falls back to the effective codeset (nl_langinfo(CODESET)) when the named locale is not activatable — same model for an un-activatable UTF-8 name. All consumers share the stateful result: the$'\u'decode gate,echo -e, and the multibyte flag intrap_stack_builtins.Verification
LC_ALL=zh_TW.big5/zh_CN.gb18030→a α/c 中;LC_ALL=C→ literal\u03B1. Identical stdout and identical setlocale warnings.tests/issue3619_ansic_surviving_locale_decode.rs: 2 tests, red pre-fix / green post-fix.issue353are pre-existing env-bound and identical without this change.Fixes #3619