mirror of
https://github.com/fish-shell/fish-shell
synced 2024-11-10 07:04:29 +00:00
Rename compat.rs to libc.rs
Matches Rust convention better.
This commit is contained in:
parent
e110d4c672
commit
f7c9753c4b
20 changed files with 25 additions and 25 deletions
|
@ -46,9 +46,9 @@ fn main() {
|
|||
rsconf::link_libraries(&curses_libnames, LinkType::Default);
|
||||
|
||||
cc::Build::new()
|
||||
.file("fish-rust/src/compat.c")
|
||||
.file("fish-rust/src/libc.c")
|
||||
.include(&build_dir)
|
||||
.compile("libcompat.a");
|
||||
.compile("flibc.a");
|
||||
|
||||
if compiles("fish-rust/src/cfg/w_exitcode.cpp") {
|
||||
println!("cargo:rustc-cfg=HAVE_WAITSTATUS_SIGNAL_RET");
|
||||
|
|
|
@ -9,11 +9,11 @@ use crate::common::unescape_string;
|
|||
use crate::common::valid_var_name;
|
||||
use crate::common::ScopeGuard;
|
||||
use crate::common::UnescapeStringStyle;
|
||||
use crate::compat::MB_CUR_MAX;
|
||||
use crate::env::EnvMode;
|
||||
use crate::env::Environment;
|
||||
use crate::env::READ_BYTE_LIMIT;
|
||||
use crate::env::{EnvVar, EnvVarFlags};
|
||||
use crate::libc::MB_CUR_MAX;
|
||||
use crate::nix::isatty;
|
||||
use crate::reader::commandline_set_buffer;
|
||||
use crate::reader::ReaderConfig;
|
||||
|
|
|
@ -4,8 +4,8 @@ use libc::{c_uint, rlim_t, RLIM_INFINITY};
|
|||
use nix::errno::Errno;
|
||||
use once_cell::sync::Lazy;
|
||||
|
||||
use crate::compat::*;
|
||||
use crate::fallback::{fish_wcswidth, wcscasecmp};
|
||||
use crate::libc::*;
|
||||
use crate::wutil::perror;
|
||||
|
||||
use super::prelude::*;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
//! Prototypes for various functions, mostly string utilities, that are used by most parts of fish.
|
||||
|
||||
use crate::compat::MB_CUR_MAX;
|
||||
use crate::expand::{
|
||||
BRACE_BEGIN, BRACE_END, BRACE_SEP, BRACE_SPACE, HOME_DIRECTORY, INTERNAL_SEPARATOR,
|
||||
PROCESS_EXPAND_SELF, PROCESS_EXPAND_SELF_STR, VARIABLE_EXPAND, VARIABLE_EXPAND_SINGLE,
|
||||
|
@ -9,6 +8,7 @@ use crate::fallback::fish_wcwidth;
|
|||
use crate::flog::FLOG;
|
||||
use crate::future_feature_flags::{feature_test, FeatureFlag};
|
||||
use crate::global_safety::RelaxedAtomicBool;
|
||||
use crate::libc::MB_CUR_MAX;
|
||||
use crate::termsize::Termsize;
|
||||
use crate::wchar::{decode_byte_from_char, encode_byte_to_char, prelude::*};
|
||||
use crate::wcstringutil::wcs2string_callback;
|
||||
|
|
4
fish-rust/src/env/environment.rs
vendored
4
fish-rust/src/env/environment.rs
vendored
|
@ -5,7 +5,6 @@ use super::environment_impl::{
|
|||
use super::{ConfigPaths, ElectricVar};
|
||||
use crate::abbrs::{abbrs_get_set, Abbreviation, Position};
|
||||
use crate::common::{str2wcstring, unescape_string, wcs2zstring, UnescapeStringStyle};
|
||||
use crate::compat::{stdout_stream, C_PATH_BSHELL, _PATH_BSHELL};
|
||||
use crate::env::{EnvMode, EnvVar, Statuses};
|
||||
use crate::env_dispatch::{env_dispatch_init, env_dispatch_var_change};
|
||||
use crate::env_universal_common::{CallbackDataList, EnvUniversal};
|
||||
|
@ -13,6 +12,7 @@ use crate::event::Event;
|
|||
use crate::flog::FLOG;
|
||||
use crate::global_safety::RelaxedAtomicBool;
|
||||
use crate::input::init_input;
|
||||
use crate::libc::{stdout_stream, C_PATH_BSHELL, _PATH_BSHELL};
|
||||
use crate::nix::{geteuid, getpid, isatty};
|
||||
use crate::null_terminated_array::OwningNullTerminatedArray;
|
||||
use crate::path::{
|
||||
|
@ -544,7 +544,7 @@ fn setup_user(vars: &EnvStack) {
|
|||
|
||||
/// Make sure the PATH variable contains something.
|
||||
fn setup_path() {
|
||||
use crate::compat::{confstr, _CS_PATH};
|
||||
use crate::libc::{confstr, _CS_PATH};
|
||||
|
||||
let vars = &GLOBALS;
|
||||
let path = vars.get_unless_empty(L!("PATH"));
|
||||
|
|
|
@ -726,7 +726,7 @@ fn init_locale(vars: &EnvStack) {
|
|||
.map(|allow_c| !crate::wcstringutil::bool_from_string(&allow_c))
|
||||
.unwrap_or(true);
|
||||
|
||||
if fix_locale && crate::compat::MB_CUR_MAX() == 1 {
|
||||
if fix_locale && crate::libc::MB_CUR_MAX() == 1 {
|
||||
FLOG!(env_locale, "Have singlebyte locale, trying to fix.");
|
||||
for locale in UTF8_LOCALES {
|
||||
{
|
||||
|
@ -734,13 +734,13 @@ fn init_locale(vars: &EnvStack) {
|
|||
// this can fail, that is fine
|
||||
unsafe { libc::setlocale(libc::LC_CTYPE, locale.as_ptr()) };
|
||||
}
|
||||
if crate::compat::MB_CUR_MAX() > 1 {
|
||||
if crate::libc::MB_CUR_MAX() > 1 {
|
||||
FLOG!(env_locale, "Fixed locale:", locale);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if crate::compat::MB_CUR_MAX() == 1 {
|
||||
if crate::libc::MB_CUR_MAX() == 1 {
|
||||
FLOG!(env_locale, "Failed to fix locale.");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,12 +2,12 @@ use crate::common::{
|
|||
read_loop, str2wcstring, timef, unescape_string, valid_var_name, wcs2zstring, write_loop,
|
||||
UnescapeFlags, UnescapeStringStyle,
|
||||
};
|
||||
use crate::compat::{C_O_EXLOCK, UVAR_FILE_SET_MTIME_HACK};
|
||||
use crate::env::{EnvVar, EnvVarFlags, VarTable};
|
||||
use crate::fallback::fish_mkstemp_cloexec;
|
||||
use crate::fds::AutoCloseFd;
|
||||
use crate::fds::{open_cloexec, wopen_cloexec};
|
||||
use crate::flog::{FLOG, FLOGF};
|
||||
use crate::libc::{C_O_EXLOCK, UVAR_FILE_SET_MTIME_HACK};
|
||||
use crate::path::path_get_config;
|
||||
use crate::path::{path_get_config_remoteness, DirRemoteness};
|
||||
use crate::wchar::prelude::*;
|
||||
|
|
|
@ -11,7 +11,6 @@ use crate::common::{
|
|||
exit_without_destructors, scoped_push_replacer, str2wcstring, wcs2string, wcs2zstring,
|
||||
write_loop, ScopeGuard,
|
||||
};
|
||||
use crate::compat::_PATH_BSHELL;
|
||||
use crate::env::{EnvMode, EnvStack, Environment, Statuses, READ_BYTE_LIMIT};
|
||||
use crate::env_dispatch::use_posix_spawn;
|
||||
use crate::fds::make_fd_blocking;
|
||||
|
@ -29,6 +28,7 @@ use crate::io::{
|
|||
BufferedOutputStream, FdOutputStream, IoBufferfill, IoChain, IoClose, IoMode, IoPipe,
|
||||
IoStreams, OutputStream, SeparatedBuffer, StringOutputStream,
|
||||
};
|
||||
use crate::libc::_PATH_BSHELL;
|
||||
use crate::nix::isatty;
|
||||
use crate::null_terminated_array::{
|
||||
null_terminated_array_length, AsNullTerminatedArray, OwningNullTerminatedArray,
|
||||
|
|
|
@ -27,7 +27,6 @@ use crate::{
|
|||
restore_term_foreground_process_group_for_exit, save_term_foreground_process_group,
|
||||
scoped_push_replacer, str2wcstring, wcs2string, PROFILING_ACTIVE, PROGRAM_NAME,
|
||||
},
|
||||
compat::setlinebuf,
|
||||
env::Statuses,
|
||||
env::{
|
||||
environment::{env_init, EnvStack, Environment},
|
||||
|
@ -39,6 +38,7 @@ use crate::{
|
|||
function, future_feature_flags as features, history,
|
||||
history::start_private_mode,
|
||||
io::IoChain,
|
||||
libc::setlinebuf,
|
||||
nix::{getpid, isatty},
|
||||
parse_constants::{ParseErrorList, ParseTreeFlags},
|
||||
parse_tree::ParsedSource,
|
||||
|
|
|
@ -15,7 +15,6 @@ use crate::common::{
|
|||
str2wcstring, unescape_string, wcs2string, wcs2zstring, UnescapeFlags, UnescapeStringStyle,
|
||||
PROGRAM_NAME,
|
||||
};
|
||||
use crate::compat::setlinebuf;
|
||||
use crate::env::env_init;
|
||||
use crate::env::environment::Environment;
|
||||
use crate::env::EnvStack;
|
||||
|
@ -25,6 +24,7 @@ use crate::fds::set_cloexec;
|
|||
use crate::future::{IsOkAnd, IsSomeAnd, IsSorted};
|
||||
use crate::global_safety::RelaxedAtomicBool;
|
||||
use crate::highlight::{colorize, highlight_shell, HighlightRole, HighlightSpec};
|
||||
use crate::libc::setlinebuf;
|
||||
use crate::operation_context::OperationContext;
|
||||
use crate::parse_constants::{ParseTokenType, ParseTreeFlags, SourceRange};
|
||||
use crate::parse_util::parse_util_compute_indents;
|
||||
|
|
|
@ -10,7 +10,6 @@ use crate::common::{
|
|||
unescape_string_in_place, valid_var_name, valid_var_name_char, UnescapeFlags, ASCII_MAX,
|
||||
EXPAND_RESERVED_BASE, EXPAND_RESERVED_END,
|
||||
};
|
||||
use crate::compat::_PC_CASE_SENSITIVE;
|
||||
use crate::env::Environment;
|
||||
use crate::expand::{
|
||||
expand_one, expand_tilde, expand_to_command_and_args, ExpandFlags, ExpandResultCode,
|
||||
|
@ -23,6 +22,7 @@ use crate::expand::{
|
|||
use crate::function;
|
||||
use crate::future_feature_flags::{feature_test, FeatureFlag};
|
||||
use crate::history::{all_paths_are_valid, HistoryItem};
|
||||
use crate::libc::_PC_CASE_SENSITIVE;
|
||||
use crate::operation_context::OperationContext;
|
||||
use crate::output::{parse_color, Outputter};
|
||||
use crate::parse_constants::{
|
||||
|
|
|
@ -408,7 +408,7 @@ pub trait InputEventQueuer {
|
|||
}
|
||||
|
||||
ReadbResult::Byte(read_byte) => {
|
||||
if crate::compat::MB_CUR_MAX() == 1 {
|
||||
if crate::libc::MB_CUR_MAX() == 1 {
|
||||
// single-byte locale, all values are legal
|
||||
// FIXME: this looks wrong, this falsely assumes that
|
||||
// the single-byte locale is compatible with Unicode upper-ASCII.
|
||||
|
|
|
@ -35,8 +35,6 @@ mod ast;
|
|||
mod autoload;
|
||||
mod builtins;
|
||||
mod color;
|
||||
#[allow(non_snake_case)]
|
||||
mod compat;
|
||||
mod complete;
|
||||
mod curses;
|
||||
mod editable_line;
|
||||
|
@ -67,6 +65,8 @@ mod input_common;
|
|||
mod io;
|
||||
mod job_group;
|
||||
mod kill;
|
||||
#[allow(non_snake_case)]
|
||||
mod libc;
|
||||
mod locale;
|
||||
mod nix;
|
||||
mod null_terminated_array;
|
||||
|
|
|
@ -6,13 +6,13 @@ use std::collections::HashMap;
|
|||
use crate::common::{
|
||||
escape_string, get_ellipsis_char, get_ellipsis_str, EscapeFlags, EscapeStringStyle,
|
||||
};
|
||||
use crate::compat::MB_CUR_MAX;
|
||||
use crate::complete::Completion;
|
||||
use crate::editable_line::EditableLine;
|
||||
use crate::fallback::{fish_wcswidth, fish_wcwidth};
|
||||
#[allow(unused_imports)]
|
||||
use crate::future::IsSomeAnd;
|
||||
use crate::highlight::{highlight_shell, HighlightRole, HighlightSpec};
|
||||
use crate::libc::MB_CUR_MAX;
|
||||
use crate::operation_context::OperationContext;
|
||||
use crate::screen::{Line, ScreenData};
|
||||
use crate::termsize::Termsize;
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
//! path-related issues.
|
||||
|
||||
use crate::common::wcs2zstring;
|
||||
#[cfg(not(target_os = "linux"))]
|
||||
use crate::compat::{MNT_LOCAL, ST_LOCAL};
|
||||
use crate::env::{EnvMode, EnvStack, Environment};
|
||||
use crate::expand::{expand_tilde, HOME_DIRECTORY};
|
||||
use crate::flog::{FLOG, FLOGF};
|
||||
#[cfg(not(target_os = "linux"))]
|
||||
use crate::libc::{MNT_LOCAL, ST_LOCAL};
|
||||
use crate::wchar::prelude::*;
|
||||
use crate::wutil::{normalize_path, path_normalize_for_cd, waccess, wdirname, wmkdir, wstat};
|
||||
use errno::{errno, set_errno, Errno};
|
||||
|
|
|
@ -42,7 +42,6 @@ use crate::common::{
|
|||
shell_modes, str2wcstring, wcs2string, write_loop, EscapeFlags, EscapeStringStyle, ScopeGuard,
|
||||
PROGRAM_NAME, UTF8_BOM_WCHAR,
|
||||
};
|
||||
use crate::compat::MB_CUR_MAX;
|
||||
use crate::complete::{
|
||||
complete, complete_load, sort_and_prioritize, CompleteFlags, Completion, CompletionList,
|
||||
CompletionRequestOptions,
|
||||
|
@ -71,6 +70,7 @@ use crate::input::Inputter;
|
|||
use crate::input_common::{CharEvent, CharInputStyle, ReadlineCmd};
|
||||
use crate::io::IoChain;
|
||||
use crate::kill::{kill_add, kill_replace, kill_yank, kill_yank_rotate};
|
||||
use crate::libc::MB_CUR_MAX;
|
||||
use crate::operation_context::{get_bg_context, OperationContext};
|
||||
use crate::output::{parse_color, Outputter};
|
||||
use crate::pager::{PageRendering, Pager, SelectionMotion};
|
||||
|
|
|
@ -18,13 +18,13 @@ fn setlocale() {
|
|||
const UTF8_LOCALES: &[&str] = &[
|
||||
"C.UTF-8", "en_US.UTF-8", "en_GB.UTF-8", "de_DE.UTF-8", "C.utf8", "UTF-8",
|
||||
];
|
||||
if crate::compat::MB_CUR_MAX() > 1 {
|
||||
if crate::libc::MB_CUR_MAX() > 1 {
|
||||
return;
|
||||
}
|
||||
for locale in UTF8_LOCALES {
|
||||
let locale = std::ffi::CString::new(locale.to_owned()).unwrap();
|
||||
unsafe { libc::setlocale(libc::LC_CTYPE, locale.as_ptr()) };
|
||||
if crate::compat::MB_CUR_MAX() > 1 {
|
||||
if crate::libc::MB_CUR_MAX() > 1 {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
//! Helper functions for working with wcstring.
|
||||
|
||||
use crate::common::{get_ellipsis_char, get_ellipsis_str};
|
||||
use crate::compat::MB_CUR_MAX;
|
||||
use crate::expand::INTERNAL_SEPARATOR;
|
||||
use crate::fallback::{fish_wcwidth, wcscasecmp};
|
||||
use crate::flog::FLOGF;
|
||||
use crate::libc::MB_CUR_MAX;
|
||||
use crate::wchar::{decode_byte_from_char, prelude::*};
|
||||
use crate::wutil::encoding::{wcrtomb, zero_mbstate, AT_LEAST_MB_LEN_MAX};
|
||||
|
||||
|
|
Loading…
Reference in a new issue