Remove wcs/wcwidth ffi calls

This was ported a while back, we can just call the rust version
This commit is contained in:
Fabian Boehm 2023-09-05 21:57:18 +02:00
parent fff320b56b
commit fa390334a8
3 changed files with 7 additions and 8 deletions

View file

@ -5,7 +5,8 @@ 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,
};
use crate::ffi::{self, fish_wcwidth};
use crate::fallback::fish_wcwidth;
use crate::ffi::{self};
use crate::flog::FLOG;
use crate::future_feature_flags::{feature_test, FeatureFlag};
use crate::global_safety::RelaxedAtomicBool;
@ -1553,7 +1554,7 @@ pub fn reformat_for_screen(msg: &wstr, termsize: &Termsize) -> WString {
while pos < msg.len() && ![' ', '\n', '\r', '\t'].contains(&msg.char_at(pos)) {
// Check is token is wider than one line. If so we mark it as an overflow and break
// the token.
let width = fish_wcwidth(msg.char_at(pos).into()).0 as isize;
let width = fish_wcwidth(msg.char_at(pos)) as isize;
if (tok_width + width) > (screen_width - 1) {
overflow = true;
break;

View file

@ -92,9 +92,6 @@ include_cpp! {
generate!("log_extra_to_flog_file")
generate!("fish_wcwidth")
generate!("fish_wcswidth")
generate!("wildcard_match")
generate!("wgettext_ptr")

View file

@ -1,8 +1,9 @@
//! Constants used in the programmatic representation of fish code.
use crate::ffi::{fish_wcswidth, fish_wcwidth, wcharz_t};
use crate::fallback::{fish_wcswidth, fish_wcwidth};
use crate::tokenizer::variable_assignment_equals_pos;
use crate::wchar::prelude::*;
use crate::wchar_ffi::wcharz_t;
use crate::wchar_ffi::{AsWstr, WCharFromFFI, WCharToFFI};
use bitflags::bitflags;
use cxx::{type_id, ExternType};
@ -475,7 +476,7 @@ impl ParseError {
// pretend it's a space. We only expect this to be at the end of the string.
caret_space_line += " ";
} else {
let width = fish_wcwidth(wc.into()).0;
let width = fish_wcwidth(wc);
if width > 0 {
caret_space_line += " ".repeat(width as usize).as_str();
}
@ -489,7 +490,7 @@ impl ParseError {
// We do it like this
// ^~~^
// With a "^" under the start and end, and squiggles in-between.
let width = fish_wcswidth(unsafe { src.as_ptr().add(start) }, len).0;
let width = fish_wcswidth(&src[start..start + len]);
if width >= 2 {
// Subtract one for each of the carets - this is important in case
// the starting char has a width of > 1.