mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-29 05:13:43 +00:00
Make LC_GLOBAL_LOCALE shim less brittle
Make sure the function is defined on all platforms, and don't split conditional compilation logic between C and rust.
This commit is contained in:
parent
a9a70e0149
commit
5169302303
2 changed files with 4 additions and 6 deletions
|
@ -182,8 +182,10 @@ int C_RLIMIT_NTHR() {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef LC_GLOBAL_LOCALE
|
|
||||||
locale_t C_LC_GLOBAL_LOCALE() {
|
locale_t C_LC_GLOBAL_LOCALE() {
|
||||||
|
// LC_GLOBAL_LOCALE is usually -1, but not always (e.g. under NetBSD).
|
||||||
|
#ifdef LC_GLOBAL_LOCALE
|
||||||
return LC_GLOBAL_LOCALE;
|
return LC_GLOBAL_LOCALE;
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
return (locale_t)-1;
|
||||||
|
}
|
||||||
|
|
|
@ -65,11 +65,7 @@ unsafe fn read_locale() -> Option<Locale> {
|
||||||
extern "C" {
|
extern "C" {
|
||||||
fn localeconv_l(loc: libc::locale_t) -> *const libc::lconv;
|
fn localeconv_l(loc: libc::locale_t) -> *const libc::lconv;
|
||||||
}
|
}
|
||||||
/// Rust libc does not provide LC_GLOBAL_LOCALE, but it is usually -1.
|
|
||||||
#[cfg(not(target_os = "netbsd"))]
|
#[cfg(not(target_os = "netbsd"))]
|
||||||
const LC_GLOBAL_LOCALE: libc::locale_t = (-1_isize) as libc::locale_t;
|
|
||||||
// On NetBSD it's not.
|
|
||||||
#[cfg(target_os = "netbsd")]
|
|
||||||
let LC_GLOBAL_LOCALE: libc::locale_t = unsafe { crate::libc::C_LC_GLOBAL_LOCALE() };
|
let LC_GLOBAL_LOCALE: libc::locale_t = unsafe { crate::libc::C_LC_GLOBAL_LOCALE() };
|
||||||
|
|
||||||
const empty: [libc::c_char; 1] = [0];
|
const empty: [libc::c_char; 1] = [0];
|
||||||
|
|
Loading…
Reference in a new issue