From 174130fe2f3b2a1a8d9523653bfb660a79025a27 Mon Sep 17 00:00:00 2001 From: Peter Ammon Date: Sun, 10 Aug 2025 18:49:56 -0700 Subject: [PATCH] Adopt Rust libc _CS_PATH This is now supported directly by the libc crate - no need for fish to expose this via C. --- src/env/environment.rs | 5 ++--- src/libc.c | 10 +--------- src/libc.rs | 1 - 3 files changed, 3 insertions(+), 13 deletions(-) diff --git a/src/env/environment.rs b/src/env/environment.rs index 699d463d6..86d3e3878 100644 --- a/src/env/environment.rs +++ b/src/env/environment.rs @@ -569,13 +569,12 @@ fn setup_user(vars: &EnvStack) { } pub(crate) static FALLBACK_PATH: Lazy<&[WString]> = Lazy::new(|| { - use crate::libc::_CS_PATH; // _CS_PATH: colon-separated paths to find POSIX utilities - let buf_size = unsafe { confstr(_CS_PATH(), std::ptr::null_mut(), 0) }; + let buf_size = unsafe { confstr(libc::_CS_PATH, std::ptr::null_mut(), 0) }; Box::leak( (if buf_size > 0 { let mut buf = vec![b'\0' as libc::c_char; buf_size]; - unsafe { confstr(_CS_PATH(), buf.as_mut_ptr(), buf_size) }; + unsafe { confstr(libc::_CS_PATH, buf.as_mut_ptr(), buf_size) }; let buf = buf; // safety: buf should contain a null-byte, and is not mutable unless we move ownership let cstr = unsafe { CStr::from_ptr(buf.as_ptr()) }; diff --git a/src/libc.c b/src/libc.c index 07bdd7d3c..072609ef5 100644 --- a/src/libc.c +++ b/src/libc.c @@ -7,7 +7,7 @@ #include // MNT_LOCAL #include #include // ST_LOCAL -#include // _CS_PATH, _PC_CASE_SENSITIVE +#include // _PC_CASE_SENSITIVE uint64_t C_ST_LOCAL() { #if defined(ST_LOCAL) @@ -17,14 +17,6 @@ uint64_t C_ST_LOCAL() { #endif } -int C_CS_PATH() { -#if defined(_CS_PATH) - return _CS_PATH; -#else - return -1; -#endif -} - uint64_t C_MNT_LOCAL() { #if defined(MNT_LOCAL) return MNT_LOCAL; diff --git a/src/libc.rs b/src/libc.rs index 02244cfc3..ba1791fea 100644 --- a/src/libc.rs +++ b/src/libc.rs @@ -31,7 +31,6 @@ pub fn $cvar() -> $type { CVAR!(C_ST_LOCAL, ST_LOCAL, u64); CVAR!(C_MNT_LOCAL, MNT_LOCAL, u64); -CVAR!(C_CS_PATH, _CS_PATH, i32); CVAR!(C_RLIMIT_SBSIZE, RLIMIT_SBSIZE, i32); CVAR!(C_RLIMIT_CORE, RLIMIT_CORE, i32);