widestring: rename wchar -> widestring

This is a more descriptive name for the crate.

https://github.com/fish-shell/fish-shell/pull/12311#discussion_r2681191208

Closes #12313
This commit is contained in:
Daniel Rainer
2026-01-12 17:27:40 +01:00
committed by Johannes Altmanninger
parent 36db3b7f3f
commit 253f6726c0
46 changed files with 62 additions and 62 deletions

16
Cargo.lock generated
View File

@@ -167,8 +167,8 @@ dependencies = [
"fish-gettext-mo-file-parser",
"fish-printf",
"fish-tempfile",
"fish-wchar",
"fish-widecharwidth",
"fish-widestring",
"libc",
"lru",
"macro_rules_attribute",
@@ -207,7 +207,7 @@ name = "fish-common"
version = "0.0.0"
dependencies = [
"bitflags",
"fish-wchar",
"fish-widestring",
"libc",
"nix",
]
@@ -218,8 +218,8 @@ version = "0.0.0"
dependencies = [
"fish-build-helper",
"fish-common",
"fish-wchar",
"fish-widecharwidth",
"fish-widestring",
"libc",
"rsconf",
"widestring",
@@ -276,16 +276,16 @@ dependencies = [
]
[[package]]
name = "fish-wchar"
name = "fish-widecharwidth"
version = "0.0.0"
[[package]]
name = "fish-widestring"
version = "0.0.0"
dependencies = [
"widestring",
]
[[package]]
name = "fish-widecharwidth"
version = "0.0.0"
[[package]]
name = "fnv"
version = "1.0.7"

View File

@@ -25,8 +25,8 @@ fish-gettext-maps = { path = "crates/gettext-maps" }
fish-gettext-mo-file-parser = { path = "crates/gettext-mo-file-parser" }
fish-printf = { path = "crates/printf", features = ["widestring"] }
fish-tempfile = { path = "crates/tempfile" }
fish-wchar = { path = "crates/wchar" }
fish-widecharwidth = { path = "crates/widecharwidth" }
fish-widestring = { path = "crates/widestring" }
libc = "0.2.177"
# lru pulls in hashbrown by default, which uses a faster (though less DoS resistant) hashing algo.
# disabling default features uses the stdlib instead, but it doubles the time to rewrite the history
@@ -99,8 +99,8 @@ fish-gettext = { workspace = true, optional = true }
fish-gettext-extraction = { workspace = true, optional = true }
fish-printf.workspace = true
fish-tempfile.workspace = true
fish-wchar.workspace = true
fish-widecharwidth.workspace = true
fish-widestring.workspace = true
libc.workspace = true
lru.workspace = true
macro_rules_attribute = "0.2.2"

View File

@@ -8,7 +8,7 @@ license.workspace = true
[dependencies]
bitflags.workspace = true
fish-wchar.workspace = true
fish-widestring.workspace = true
libc.workspace = true
nix.workspace = true

View File

@@ -1,5 +1,5 @@
use bitflags::bitflags;
use fish_wchar::{L, char_offset, wstr};
use fish_widestring::{L, char_offset, wstr};
use libc::{SIG_IGN, SIGTTOU, STDIN_FILENO};
use std::cell::{Cell, RefCell};
use std::io::Read;
@@ -541,7 +541,7 @@ pub const fn assert_sync<T: Sync>() {}
/// # Examples
///
/// ```
/// use fish_wchar::{L, wstr};
/// use fish_widestring::{L, wstr};
/// use fish_common::assert_sorted_by_name;
///
/// const COLORS: &[(&wstr, u32)] = &[
@@ -557,7 +557,7 @@ pub const fn assert_sync<T: Sync>() {}
/// While this example would fail to compile:
///
/// ```compile_fail
/// use fish_wchar::{L, wstr};
/// use fish_widestring::{L, wstr};
/// use fish_common::assert_sorted_by_name;
///
/// const COLORS: &[(&wstr, u32)] = &[

View File

@@ -8,8 +8,8 @@ license.workspace = true
[dependencies]
fish-common.workspace = true
fish-wchar.workspace = true
fish-widecharwidth.workspace = true
fish-widestring.workspace = true
libc.workspace = true
widestring.workspace = true

View File

@@ -3,8 +3,8 @@
//!
//! Many of these functions are more or less broken and incomplete.
use fish_wchar::prelude::*;
use fish_widecharwidth::{WcLookupTable, WcWidth};
use fish_widestring::prelude::*;
use std::cmp;
use std::sync::{
LazyLock,
@@ -185,7 +185,7 @@ pub fn new(mut chars: Chars, to_lowercase: fn(char) -> ToLowercase) -> Self {
#[cfg(test)]
mod tests {
use super::wcscasecmp;
use fish_wchar::prelude::*;
use fish_widestring::prelude::*;
use std::cmp::Ordering;
#[test]

View File

@@ -1,5 +1,5 @@
[package]
name = "fish-wchar"
name = "fish-widestring"
edition.workspace = true
rust-version.workspace = true
version = "0.0.0"

View File

@@ -7,7 +7,7 @@
use crate::io::IoChain;
use crate::parser::Parser;
use crate::wutil::{FileId, INVALID_FILE_ID, file_id_for_path};
use fish_wchar::{L, WExt, WString, wstr};
use fish_widestring::{L, WExt, WString, wstr};
use lru::LruCache;
use rust_embed::RustEmbed;
use std::collections::{HashMap, HashSet};

View File

@@ -5,7 +5,7 @@
use crate::parser::Parser;
use crate::proc::{Job, add_disowned_job};
use crate::{builtins::shared::HelpOnlyCmdOpts, localization::wgettext_fmt};
use fish_wchar::wstr;
use fish_widestring::wstr;
use libc::SIGCONT;
/// Helper for builtin_disown.

View File

@@ -1,7 +1,7 @@
//! Implementation of the echo builtin.
use super::prelude::*;
use fish_wchar::encode_byte_to_char;
use fish_widestring::encode_byte_to_char;
#[derive(Debug, Clone, Copy)]
struct Options {

View File

@@ -9,7 +9,7 @@
use crate::proc::{Job, clock_ticks_to_seconds, have_proc_stat, proc_get_jiffies};
use crate::wgetopt::{ArgType, WGetopter, WOption, wopt};
use crate::wutil::fish_wcstoi;
use fish_wchar::{L, WExt, WString, wstr};
use fish_widestring::{L, WExt, WString, wstr};
use std::num::NonZeroU32;
/// Print modes for the jobs builtin.

View File

@@ -1,4 +1,4 @@
use fish_wchar::L;
use fish_widestring::L;
use num_traits::pow;
use super::prelude::*;

View File

@@ -57,7 +57,7 @@
wstr_offset_in,
};
use fish_printf::{ToArg, sprintf_locale};
use fish_wchar::{decode_byte_from_char, encode_byte_to_char};
use fish_widestring::{decode_byte_from_char, encode_byte_to_char};
/// Return true if `c` is an octal digit.
fn is_octal_digit(c: char) -> bool {

View File

@@ -9,7 +9,7 @@
use crate::{builtins::*, wutil};
use errno::errno;
use fish_common::assert_sorted_by_name;
use fish_wchar::L;
use fish_widestring::L;
use std::io::{BufRead, BufReader, Read};
pub type BuiltinCmd = fn(&Parser, &mut IoStreams, &mut [&wstr]) -> BuiltinResult;

View File

@@ -16,7 +16,7 @@
use crate::wildcard::{ANY_CHAR, ANY_STRING, ANY_STRING_RECURSIVE};
use crate::wutil::fish_iswalnum;
use fish_fallback::fish_wcwidth;
use fish_wchar::{
use fish_widestring::{
ENCODE_DIRECT_END, decode_byte_from_char, encode_byte_to_char, subslice_position,
};
use std::env;
@@ -1383,7 +1383,7 @@ mod tests {
bytes2wcstring, escape_string, unescape_string, wcs2bytes,
};
use crate::util::get_seeded_rng;
use fish_wchar::{ENCODE_DIRECT_BASE, L, WString, wstr};
use fish_widestring::{ENCODE_DIRECT_BASE, L, WString, wstr};
use rand::{Rng, RngCore};
#[test]

View File

@@ -54,7 +54,7 @@
wcstringutil::{string_suffixes_string_case_insensitive, strip_executable_suffix},
};
use bitflags::bitflags;
use fish_wchar::WExt;
use fish_widestring::WExt;
// Completion description strings, mostly for different types of files, such as sockets, block
// devices, etc.

2
src/env/var.rs vendored
View File

@@ -2,7 +2,7 @@
use crate::wcstringutil::join_strings;
use bitflags::bitflags;
use fish_common::assert_sorted_by_name;
use fish_wchar::{L, WString, wstr};
use fish_widestring::{L, WString, wstr};
use libc::c_int;
use std::collections::HashMap;
use std::sync::Arc;

View File

@@ -8,7 +8,7 @@
use crate::prelude::*;
use crate::wcstringutil::{LineIterator, join_strings};
use crate::wutil::{FileId, INVALID_FILE_ID, file_id_for_file, file_id_for_path_narrow, wrealpath};
use fish_wchar::decode_byte_from_char;
use fish_widestring::decode_byte_from_char;
use std::collections::HashSet;
use std::collections::hash_map::Entry;
use std::ffi::CString;
@@ -808,7 +808,7 @@ fn skip_spaces(mut s: &wstr) -> &wstr {
#[cfg(test)]
mod tests {
use fish_tempfile::TempDir;
use fish_wchar::{ENCODE_DIRECT_BASE, char_offset};
use fish_widestring::{ENCODE_DIRECT_BASE, char_offset};
use crate::common::bytes2wcstring;
use crate::common::wcs2osstring;

View File

@@ -47,7 +47,7 @@
use crate::tty_handoff::TtyHandoff;
use crate::wutil::{fish_wcstol, perror};
use errno::{errno, set_errno};
use fish_wchar::ToWString;
use fish_widestring::ToWString;
use libc::{
EACCES, ENOENT, ENOEXEC, ENOTDIR, EPIPE, EXIT_FAILURE, EXIT_SUCCESS, STDERR_FILENO,
STDIN_FILENO, STDOUT_FILENO,

View File

@@ -31,7 +31,7 @@
use crate::wutil::{Options, normalize_path, wcstoi_partial};
use bitflags::bitflags;
use fish_common::{EXPAND_RESERVED_BASE, EXPAND_RESERVED_END};
use fish_wchar::char_offset;
use fish_widestring::char_offset;
use std::mem::MaybeUninit;
bitflags! {

View File

@@ -19,7 +19,7 @@
use crate::wutil::{
dir_iter::DirIter, fish_wcstoi, normalize_path, waccess, wbasename, wdirname, wstat,
};
use fish_wchar::{L, WExt, WString, wstr};
use fish_widestring::{L, WExt, WString, wstr};
use libc::PATH_MAX;
use std::collections::{HashMap, HashSet};
use std::os::fd::RawFd;

View File

@@ -31,7 +31,7 @@
use crate::tokenizer::{PipeOrRedir, variable_assignment_equals_pos};
use crate::wcstringutil::string_prefixes_string;
use fish_common::{ASCII_MAX, EXPAND_RESERVED_BASE, EXPAND_RESERVED_END};
use fish_wchar::{L, WExt, WString, wstr};
use fish_widestring::{L, WExt, WString, wstr};
use std::collections::HashMap;
use std::collections::hash_map::Entry;

View File

@@ -5,7 +5,7 @@
time::{Duration, SystemTime, UNIX_EPOCH},
};
use fish_wchar::subslice_position;
use fish_widestring::subslice_position;
use super::{HistoryItem, PersistenceMode};
use crate::{common::bytes2wcstring, flog::flog};

View File

@@ -18,7 +18,7 @@
};
use crate::universal_notifier::default_notifier;
use crate::wutil::{fish_is_pua, fish_wcstol};
use fish_wchar::encode_byte_to_char;
use fish_widestring::encode_byte_to_char;
use std::cell::{RefCell, RefMut};
use std::collections::VecDeque;
use std::mem::MaybeUninit;

View File

@@ -9,7 +9,7 @@
wutil::fish_wcstoul,
};
use fish_fallback::fish_wcwidth;
use fish_wchar::decode_byte_from_char;
use fish_widestring::decode_byte_from_char;
pub(crate) const Backspace: char = '\u{F500}'; // below ENCODE_DIRECT_BASE
pub(crate) const Delete: char = '\u{F501}';

View File

@@ -1,4 +1,4 @@
use fish_wchar::{L, WString, wstr};
use fish_widestring::{L, WString, wstr};
use std::sync::{LazyLock, Mutex};
/// Use this function to localize a message.
@@ -119,7 +119,7 @@ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
#[cfg(feature = "gettext-extract")]
macro_rules! localizable_string {
($string:literal) => {
$crate::localization::LocalizableString::Static(fish_wchar::L!(
$crate::localization::LocalizableString::Static(fish_widestring::L!(
fish_gettext_extraction::gettext_extract!($string)
))
};
@@ -128,7 +128,7 @@ macro_rules! localizable_string {
#[cfg(not(feature = "gettext-extract"))]
macro_rules! localizable_string {
($string:literal) => {
$crate::localization::LocalizableString::Static(fish_wchar::L!($string))
$crate::localization::LocalizableString::Static(fish_widestring::L!($string))
};
}
pub use localizable_string;

View File

@@ -15,7 +15,7 @@
/// available. Without this, early error messages cannot be localized.
pub fn initialize_localization() {
use crate::env::EnvStack;
use fish_wchar::L;
use fish_widestring::L;
let env = EnvStack::new();
env_stack_set_from_env!(env, "LANGUAGE");

View File

@@ -1,6 +1,6 @@
use super::{localizable_consts, localizable_string, wgettext, wgettext_fmt};
use crate::env::{EnvStack, Environment};
use fish_wchar::{L, WString, wstr};
use fish_widestring::{L, WString, wstr};
use std::collections::{HashMap, HashSet};
use std::sync::{LazyLock, Mutex};

View File

@@ -53,7 +53,7 @@
use crate::trace::{trace_if_enabled, trace_if_enabled_with_args};
use crate::wildcard::wildcard_match;
use fish_common::help_section;
use fish_wchar::WExt;
use fish_widestring::WExt;
use libc::{ENOTDIR, EXIT_SUCCESS, STDERR_FILENO, STDOUT_FILENO, c_int};
use std::io::ErrorKind;
use std::rc::Rc;

View File

@@ -36,7 +36,7 @@
use crate::wait_handle::WaitHandleStore;
use crate::wutil::perror;
use crate::{flog, flogf, function};
use fish_wchar::WExt;
use fish_widestring::WExt;
use libc::c_int;
use std::cell::{Ref, RefCell, RefMut};
use std::ffi::OsStr;

View File

@@ -2,4 +2,4 @@
LocalizableString, localizable_consts, localizable_string, wgettext, wgettext_fmt,
};
pub use crate::wutil::{eprintf, sprintf};
pub use fish_wchar::prelude::*;
pub use fish_widestring::prelude::*;

View File

@@ -23,7 +23,7 @@
use crate::wait_handle::{InternalJobId, WaitHandle, WaitHandleRef, WaitHandleStore};
use crate::wutil::{wbasename, wperror};
use cfg_if::cfg_if;
use fish_wchar::ToWString;
use fish_widestring::ToWString;
use libc::{
_SC_CLK_TCK, EXIT_SUCCESS, SIG_DFL, SIG_IGN, SIGABRT, SIGBUS, SIGCONT, SIGFPE, SIGHUP, SIGILL,
SIGINT, SIGKILL, SIGPIPE, SIGQUIT, SIGSEGV, SIGSYS, SIGTTOU, STDOUT_FILENO, WCONTINUED,

View File

@@ -373,7 +373,7 @@ pub fn current_data() -> Option<&'static mut ReaderData> {
.map(|data| unsafe { Pin::get_unchecked_mut(Pin::as_mut(data)) })
}
pub use current_data as reader_current_data;
use fish_wchar::word_char::is_blank;
use fish_widestring::word_char::is_blank;
/// Add a new reader to the reader stack.
/// If `history_name` is empty, then save history in-memory only; do not write it to disk.

View File

@@ -3,7 +3,7 @@
use crate::prelude::*;
use crate::reader::is_backslashed;
use crate::tokenizer::tok_is_string_character;
use fish_wchar::word_char::{WordCharClass, is_blank};
use fish_widestring::word_char::{WordCharClass, is_blank};
#[derive(Clone, Copy, PartialEq, Eq)]
pub enum MoveWordStyle {

View File

@@ -24,7 +24,7 @@
use crate::fds::{self, AutoClosePipes, make_fd_nonblocking};
use crate::flog::{FloggableDebug, flog};
use crate::wutil::perror;
use fish_wchar::WString;
use fish_widestring::WString;
use nix::errno::Errno;
use nix::unistd;
use std::cell::Cell;

View File

@@ -18,7 +18,7 @@
use crate::terminal::{Output, Outputter};
use crate::threads::assert_is_main_thread;
use crate::wutil::{perror, wcstoi};
use fish_wchar::ToWString;
use fish_widestring::ToWString;
use libc::{EINVAL, ENOTTY, EPERM, STDIN_FILENO, WNOHANG};
use std::mem::MaybeUninit;
use std::sync::{

View File

@@ -69,7 +69,7 @@ fn notification_fd_became_readable(&self, fd: RawFd) -> bool {
mod tests {
use super::InotifyNotifier;
use crate::universal_notifier::{UniversalNotifier, test_helpers::test_notifiers};
use fish_wchar::WString;
use fish_widestring::WString;
#[test]
fn test_inotify_notifiers() {

View File

@@ -182,7 +182,7 @@ fn notification_fd_became_readable(&self, fd: RawFd) -> bool {
mod tests {
use super::KqueueNotifier;
use crate::universal_notifier::{UniversalNotifier, test_helpers::test_notifiers};
use fish_wchar::WString;
use fish_widestring::WString;
#[test]
fn test_kqueue_notifiers() {

View File

@@ -3,7 +3,7 @@
use crate::common::{get_ellipsis_char, get_ellipsis_str};
use crate::prelude::*;
use fish_fallback::{fish_wcwidth, lowercase, lowercase_rev, wcscasecmp, wcscasecmp_fuzzy};
use fish_wchar::decode_byte_from_char;
use fish_widestring::decode_byte_from_char;
/// Return the number of newlines in a string.
pub fn count_newlines(s: &wstr) -> usize {

View File

@@ -1,7 +1,7 @@
// Enumeration of all wildcard types.
use fish_common::WILDCARD_RESERVED_BASE;
use fish_wchar::char_offset;
use fish_widestring::char_offset;
use libc::X_OK;
use std::cmp::Ordering;
use std::collections::HashSet;

View File

@@ -2,7 +2,7 @@
use crate::common::{bytes2wcstring, wcs2zstring};
use crate::wutil::DevInode;
use cfg_if::cfg_if;
use fish_wchar::{WString, wstr};
use fish_widestring::{WString, wstr};
use libc::{
DT_BLK, DT_CHR, DT_DIR, DT_FIFO, DT_LNK, DT_REG, DT_SOCK, EACCES, EIO, ELOOP, ENAMETOOLONG,
ENODEV, ENOENT, ENOTDIR, S_IFBLK, S_IFCHR, S_IFDIR, S_IFIFO, S_IFLNK, S_IFMT, S_IFREG,
@@ -329,7 +329,7 @@ fn next(&mut self) -> Option<Self::Item> {
mod tests {
use super::{DirEntryType, DirIter};
use crate::prelude::*;
use fish_wchar::L;
use fish_widestring::L;
use nix::sys::stat::Mode;
use std::fs::File;
use std::path::PathBuf;

View File

@@ -14,7 +14,7 @@
use crate::flog;
use crate::wcstringutil::{join_strings, str2bytes_callback};
use errno::errno;
use fish_wchar::{IntoCharIter, L, WExt, WString, wstr};
use fish_widestring::{IntoCharIter, L, WExt, WString, wstr};
use std::ffi::{CStr, OsStr};
use std::fs::{self, canonicalize};
use std::io::{self, Write};
@@ -481,7 +481,7 @@ mod tests {
mod test_path_normalize_for_cd {
use super::super::path_normalize_for_cd;
use fish_wchar::L;
use fish_widestring::L;
#[test]
fn relative_path() {
@@ -692,7 +692,7 @@ fn test_wwrite_to_fd() {
#[test]
fn test_wstr_offset_in() {
use fish_wchar::L;
use fish_widestring::L;
let base = L!("hello world");
assert_eq!(wstr_offset_in(&base[6..], base), 6);
assert_eq!(wstr_offset_in(&base[0..], base), 0);

View File

@@ -4,7 +4,7 @@ macro_rules! sprintf {
// Allow a `&str` or `&Utf32Str` as a format, and return a `Utf32String`.
($fmt:expr $(, $arg:expr)* $(,)?) => {
{
let mut target = fish_wchar::WString::new();
let mut target = fish_widestring::WString::new();
$crate::sprintf!(=> &mut target, $fmt, $($arg),*);
target
}

View File

@@ -1,6 +1,6 @@
use super::errors::Error;
use super::hex_float;
use fish_wchar::IntoCharIter;
use fish_widestring::IntoCharIter;
// Parse a decimal float from a sequence of characters.
// Return the parsed float, and (on success) the number of characters consumed.