mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-15 16:26:08 +03:00
os: unset lang completely setlocale fails
This commit is contained in:
@ -35,17 +35,10 @@ pub fn ensureLocale() void {
|
|||||||
// default.
|
// default.
|
||||||
if (std.os.getenv("LANG")) |old_lang| {
|
if (std.os.getenv("LANG")) |old_lang| {
|
||||||
if (old_lang.len > 0) {
|
if (old_lang.len > 0) {
|
||||||
// The old_lang pointer can be invalidated by unsetenv so we need
|
// We don't need to do both of these things but we do them
|
||||||
// to make a copy. LANG should never be longer than 128 bytes. If
|
// both to be sure that lang is either empty or unset completely.
|
||||||
// it is, we just set it to "".
|
_ = setenv("LANG", "", 1);
|
||||||
var buf: [128]u8 = undefined;
|
|
||||||
var fba = std.heap.FixedBufferAllocator.init(&buf);
|
|
||||||
const alloc = fba.allocator();
|
|
||||||
const old_copy = alloc.dupeZ(u8, old_lang) catch "";
|
|
||||||
|
|
||||||
// Unset the lang and defer to reset the copy.
|
|
||||||
_ = unsetenv("LANG");
|
_ = unsetenv("LANG");
|
||||||
defer _ = setenv("LANG", old_copy.ptr, 1);
|
|
||||||
|
|
||||||
if (setlocale(LC_ALL, "")) |v| {
|
if (setlocale(LC_ALL, "")) |v| {
|
||||||
log.info("setlocale after unset lang result={s}", .{v});
|
log.info("setlocale after unset lang result={s}", .{v});
|
||||||
|
Reference in New Issue
Block a user