mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-03-23 11:15:14 +08:00
drop confstr implementation
Added in libc 0.2.163. The constants for _CS_PATH are not implemented for some of the BSDs yet (rust-lang/cmake#3612), so we need to keep our linking of this via the C compiler for now.
This commit is contained in:
parent
6714818e5d
commit
70bd49f612
4
src/env/environment.rs
vendored
4
src/env/environment.rs
vendored
@ -27,7 +27,7 @@ use crate::wcstringutil::join_strings;
|
|||||||
use crate::wutil::{fish_wcstol, wgetcwd, wgettext};
|
use crate::wutil::{fish_wcstol, wgetcwd, wgettext};
|
||||||
use std::sync::atomic::Ordering;
|
use std::sync::atomic::Ordering;
|
||||||
|
|
||||||
use libc::{c_int, uid_t, STDOUT_FILENO, _IONBF};
|
use libc::{c_int, confstr, uid_t, STDOUT_FILENO, _IONBF};
|
||||||
use once_cell::sync::OnceCell;
|
use once_cell::sync::OnceCell;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::ffi::CStr;
|
use std::ffi::CStr;
|
||||||
@ -568,7 +568,7 @@ fn setup_user(vars: &EnvStack) {
|
|||||||
|
|
||||||
/// Make sure the PATH variable contains something.
|
/// Make sure the PATH variable contains something.
|
||||||
fn setup_path() {
|
fn setup_path() {
|
||||||
use crate::libc::{confstr, _CS_PATH};
|
use crate::libc::_CS_PATH;
|
||||||
|
|
||||||
let vars = EnvStack::globals();
|
let vars = EnvStack::globals();
|
||||||
let path = vars.get_unless_empty(L!("PATH"));
|
let path = vars.get_unless_empty(L!("PATH"));
|
||||||
|
15
src/libc.c
15
src/libc.c
@ -19,21 +19,6 @@ uint64_t C_ST_LOCAL() {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// confstr + _CS_PATH is only available on macOS with rust's libc
|
|
||||||
// we could just declare extern "C" confstr directly in Rust
|
|
||||||
// that would panic if it failed to link, which C++ did not
|
|
||||||
// therefore we define a backup, which just returns an error
|
|
||||||
// which for confstr is 0
|
|
||||||
#if defined(_CS_PATH)
|
|
||||||
#else
|
|
||||||
size_t confstr(int name, char* buf, size_t size) {
|
|
||||||
UNUSED(name);
|
|
||||||
UNUSED(buf);
|
|
||||||
UNUSED(size);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int C_CS_PATH() {
|
int C_CS_PATH() {
|
||||||
#if defined(_CS_PATH)
|
#if defined(_CS_PATH)
|
||||||
return _CS_PATH;
|
return _CS_PATH;
|
||||||
|
@ -14,11 +14,6 @@ extern "C" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub(crate) fn confstr(
|
|
||||||
name: libc::c_int,
|
|
||||||
buf: *mut libc::c_char,
|
|
||||||
len: libc::size_t,
|
|
||||||
) -> libc::size_t;
|
|
||||||
pub fn stdout_stream() -> *mut libc::FILE;
|
pub fn stdout_stream() -> *mut libc::FILE;
|
||||||
pub fn setlinebuf(stream: *mut libc::FILE);
|
pub fn setlinebuf(stream: *mut libc::FILE);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user