From 5d299d21a1c5b212c8ed851d4301388ca159e2ec Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Mon, 1 Jan 2024 19:22:35 +0100 Subject: [PATCH] Remove some obsolete bridged C++ functions Most of these were doubled and the C++ variant is obsolete. --- fish-rust/src/env/environment.rs | 2 -- fish-rust/src/ffi.rs | 8 -------- fish-rust/src/fish.rs | 9 ++------- fish-rust/src/fish_indent.rs | 4 +--- fish-rust/src/flog.rs | 6 +++++- fish-rust/src/trace.rs | 7 ++++--- 6 files changed, 12 insertions(+), 24 deletions(-) diff --git a/fish-rust/src/env/environment.rs b/fish-rust/src/env/environment.rs index 709e8ceeb..02f4e2f60 100644 --- a/fish-rust/src/env/environment.rs +++ b/fish-rust/src/env/environment.rs @@ -10,7 +10,6 @@ use crate::env_dispatch::{env_dispatch_init, env_dispatch_var_change}; use crate::env_universal_common::{CallbackDataList, EnvUniversal}; use crate::event::Event; -use crate::ffi; use crate::flog::FLOG; use crate::global_safety::RelaxedAtomicBool; use crate::input::init_input; @@ -576,7 +575,6 @@ pub fn env_init(paths: Option<&ConfigPaths>, do_uvars: bool, default_paths: bool INHERITED_VARS .set(inherited_vars) .expect("env_init is being called multiple times"); - ffi::set_inheriteds_ffi(); if let Some(paths) = paths { vars.set_one( diff --git a/fish-rust/src/ffi.rs b/fish-rust/src/ffi.rs index 1e9c29e67..8f18b341f 100644 --- a/fish-rust/src/ffi.rs +++ b/fish-rust/src/ffi.rs @@ -39,14 +39,6 @@ generate_pod!("wcharz_t") generate!("wcstring_list_ffi_t") - generate!("set_inheriteds_ffi") - - generate!("set_profiling_active") - generate!("set_flog_output_file_ffi") - generate!("flog_setlinebuf_ffi") - generate!("activate_flog_categories_by_pattern") - - generate!("log_extra_to_flog_file") generate!("wgettext_ptr") diff --git a/fish-rust/src/fish.rs b/fish-rust/src/fish.rs index 095c2b2c9..07b0f6bfa 100644 --- a/fish-rust/src/fish.rs +++ b/fish-rust/src/fish.rs @@ -27,6 +27,7 @@ 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}, @@ -34,7 +35,6 @@ }, event::{self, Event}, fds::set_cloexec, - ffi::{self}, flog::{self, activate_flog_categories_by_pattern, set_flog_file_fd, FLOG, FLOGF}, function, future_feature_flags as features, history, history::start_private_mode, @@ -387,7 +387,6 @@ fn fish_parse_opt(args: &mut [WString], opts: &mut FishCmdOpts) -> usize { .postconfig_cmds .push(OsString::from_vec(wcs2string(w.woptarg.unwrap()))), 'd' => { - ffi::activate_flog_categories_by_pattern(w.woptarg.unwrap()); activate_flog_categories_by_pattern(w.woptarg.unwrap()); for cat in flog::categories::all_categories() { if cat.enabled.load(Ordering::Relaxed) { @@ -432,7 +431,6 @@ fn fish_parse_opt(args: &mut [WString], opts: &mut FishCmdOpts) -> usize { opts.profile_startup_output = Some(OsString::from_vec(wcs2string(w.woptarg.unwrap()))); PROFILING_ACTIVE.store(true); - ffi::set_profiling_active(true); } 'P' => opts.enable_private_mode = true, 'v' => { @@ -525,7 +523,6 @@ fn main() -> i32 { if let Some(debug_categories) = env::var_os("FISH_DEBUG") { let s = str2wcstring(debug_categories.as_bytes()); activate_flog_categories_by_pattern(&s); - ffi::activate_flog_categories_by_pattern(s); } let mut opts = FishCmdOpts::default(); @@ -552,8 +549,7 @@ fn main() -> i32 { } set_cloexec(unsafe { libc::fileno(debug_file) }, true); - ffi::flog_setlinebuf_ffi(debug_file as *mut _); - ffi::set_flog_output_file_ffi(debug_file as *mut _); + unsafe { setlinebuf(debug_file) }; set_flog_file_fd(unsafe { libc::fileno(debug_file) }); debug_output = debug_file; @@ -675,7 +671,6 @@ fn main() -> i32 { } PROFILING_ACTIVE.store(opts.profile_output.is_some()); - ffi::set_profiling_active(opts.profile_output.is_some()); // Run post-config commands specified as arguments, if any. if !opts.postconfig_cmds.is_empty() { diff --git a/fish-rust/src/fish_indent.rs b/fish-rust/src/fish_indent.rs index 2bac06545..79b010ce7 100755 --- a/fish-rust/src/fish_indent.rs +++ b/fish-rust/src/fish_indent.rs @@ -28,16 +28,15 @@ use crate::operation_context::OperationContext; use crate::parse_constants::{ParseTokenType, ParseTreeFlags, SourceRange}; use crate::parse_util::parse_util_compute_indents; +use crate::print_help::print_help; use crate::threads; use crate::tokenizer::{TokenType, Tokenizer, TOK_SHOW_BLANK_LINES, TOK_SHOW_COMMENTS}; use crate::topic_monitor::topic_monitor_init; use crate::wchar::prelude::*; -use crate::wchar_ffi::WCharToFFI; use crate::wcstringutil::count_preceding_backslashes; use crate::wgetopt::{wgetopter_t, wopt, woption, woption_argument_t}; use crate::wutil::perror; use crate::wutil::{fish_iswalnum, write_to_fd}; -use crate::{ffi, print_help::print_help}; use crate::{ flog::{self, activate_flog_categories_by_pattern, set_flog_file_fd}, future_feature_flags, @@ -805,7 +804,6 @@ enum OutputType { '\x03' => output_type = OutputType::PygmentsCsv, 'c' => output_type = OutputType::Check, 'd' => { - ffi::activate_flog_categories_by_pattern(w.woptarg.unwrap().to_ffi()); activate_flog_categories_by_pattern(w.woptarg.unwrap()); for cat in flog::categories::all_categories() { if cat.enabled.load(Ordering::Relaxed) { diff --git a/fish-rust/src/flog.rs b/fish-rust/src/flog.rs index 60f8d0449..1150abd3e 100644 --- a/fish-rust/src/flog.rs +++ b/fish-rust/src/flog.rs @@ -1,7 +1,7 @@ -use crate::parse_util::parse_util_unescape_wildcards; use crate::wchar::prelude::*; use crate::wildcard::wildcard_match; use crate::wutil::write_to_fd; +use crate::{parse_util::parse_util_unescape_wildcards, wutil::wwrite_to_fd}; use libc::c_int; use std::sync::atomic::{AtomicI32, Ordering}; @@ -251,3 +251,7 @@ pub fn set_flog_file_fd(fd: c_int) { pub fn get_flog_file_fd() -> c_int { FLOG_FD.load(Ordering::Relaxed) } + +pub fn log_extra_to_flog_file(s: &wstr) { + wwrite_to_fd(s, get_flog_file_fd()); +} diff --git a/fish-rust/src/trace.rs b/fish-rust/src/trace.rs index 2251046f5..5866caa6f 100644 --- a/fish-rust/src/trace.rs +++ b/fish-rust/src/trace.rs @@ -1,10 +1,11 @@ +use crate::flog::log_extra_to_flog_file; use crate::parser::Parser; use crate::{ common::escape, - ffi::{self, wcharz_t, wcstring_list_ffi_t}, + ffi::{wcharz_t, wcstring_list_ffi_t}, global_safety::RelaxedAtomicBool, wchar::prelude::*, - wchar_ffi::{WCharFromFFI, WCharToFFI}, + wchar_ffi::WCharFromFFI, }; #[cxx::bridge] @@ -65,7 +66,7 @@ pub fn trace_argv>(parser: &Parser, command: &wstr, args: &[S]) { trace_text.push_utfstr(&escape(arg.as_ref())); } trace_text.push('\n'); - ffi::log_extra_to_flog_file(&trace_text.to_ffi()); + log_extra_to_flog_file(&trace_text); } pub fn trace_if_enabled_ffi>(parser: &Parser, command: &wstr, args: &[S]) {