From d584f36f5d68cc623d3b4fa685d0cb250fe68552 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Thu, 12 Jun 2025 00:23:46 +0200 Subject: [PATCH] Remove support for elf-patching LOCALEDIR Commit bf65b9e3a74 (Change `gettext` paths to be relocatable (#11195), 2025-03-30) is difficult to follow because it combines code movement with two behavior changes. Our parent commit fixed the first behavior change. The second behavior change made us tolerate trailing NUL bytes in LOCALEDIR. This was motivated because conda wants to use binary patching to change the effective prefix at runtime, presumably so the user can move around the "fish" executable program arbitraily. This turned out to be unnecessary because fish is already "relocatable" (see our parent commit). Let's remove the special case for LOCALEDIR. Treat it like other paths. Closes #11574 Closes #11474 --- src/wutil/gettext.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/wutil/gettext.rs b/src/wutil/gettext.rs index 550e85254..07123c884 100644 --- a/src/wutil/gettext.rs +++ b/src/wutil/gettext.rs @@ -1,5 +1,6 @@ use std::collections::HashMap; use std::ffi::CString; +use std::os::unix::ffi::OsStrExt; use std::sync::Mutex; use crate::common::{charptr2wcstring, wcs2zstring, PACKAGE_NAME}; @@ -52,9 +53,7 @@ fn wgettext_really_init() { return; }; let package_name = CString::new(PACKAGE_NAME).unwrap(); - // This contains `datadir`; which when replaced to make the binary relocatable, - // causes null bytes at the end of the string. - let localedir = CString::new(localepath.display().to_string()).unwrap(); + let localedir = CString::new(localepath.as_os_str().as_bytes()).unwrap(); fish_bindtextdomain(&package_name, &localedir); fish_textdomain(&package_name); }