mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-07 01:51:14 -03:00
wchar: extract logic into separate crate
Another reduction in size of the main crate. Also allows other crates to depend on the new wchar crate. The original `src/wchar.rs` file is kept around for now to keep the prelude imports working. Part of #12182
This commit is contained in:
committed by
Johannes Altmanninger
parent
5a35acf2e7
commit
2f37eda9d9
@@ -1,8 +1,8 @@
|
||||
use super::wopendir;
|
||||
use crate::common::{bytes2wcstring, wcs2zstring};
|
||||
use crate::wchar::{WString, wstr};
|
||||
use crate::wutil::DevInode;
|
||||
use cfg_if::cfg_if;
|
||||
use fish_wchar::{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,6 +329,7 @@ fn next(&mut self) -> Option<Self::Item> {
|
||||
mod tests {
|
||||
use super::{DirEntryType, DirIter};
|
||||
use crate::wchar::prelude::*;
|
||||
use fish_wchar::L;
|
||||
use nix::sys::stat::Mode;
|
||||
use std::fs::File;
|
||||
use std::path::PathBuf;
|
||||
@@ -336,14 +337,12 @@ mod tests {
|
||||
#[test]
|
||||
fn test_dir_iter_bad_path() {
|
||||
// Regression test: DirIter does not crash given a bad path.
|
||||
use crate::wchar::L;
|
||||
let dir = DirIter::new(L!("/a/bogus/path/which/does/notexist"));
|
||||
assert!(dir.is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_no_dots() {
|
||||
use crate::wchar::L;
|
||||
// DirIter does not return . or .. by default.
|
||||
let dir = DirIter::new(L!(".")).expect("Should be able to open CWD");
|
||||
for entry in dir {
|
||||
@@ -355,7 +354,6 @@ fn test_no_dots() {
|
||||
|
||||
#[test]
|
||||
fn test_dots() {
|
||||
use crate::wchar::L;
|
||||
// DirIter returns . or .. if you ask nicely.
|
||||
let dir = DirIter::new_with_dots(L!(".")).expect("Should be able to open CWD");
|
||||
let mut seen_dot = false;
|
||||
@@ -375,7 +373,6 @@ fn test_dots() {
|
||||
#[test]
|
||||
#[allow(clippy::if_same_then_else)]
|
||||
fn test_dir_iter() {
|
||||
use crate::wchar::L;
|
||||
use libc::{EACCES, ENOENT};
|
||||
|
||||
let baditer = DirIter::new(L!("/definitely/not/a/valid/directory/for/sure"));
|
||||
|
||||
@@ -11,11 +11,10 @@
|
||||
use crate::common::{
|
||||
bytes2wcstring, fish_reserved_codepoint, wcs2bytes, wcs2osstring, wcs2zstring,
|
||||
};
|
||||
use crate::wchar::{L, WString, wstr};
|
||||
use crate::wchar_ext::WExt;
|
||||
use crate::wcstringutil::{join_strings, wcs2bytes_callback};
|
||||
use crate::{fallback, flog};
|
||||
use errno::errno;
|
||||
use fish_wchar::{L, WExt, WString, wstr};
|
||||
pub use gettext::{
|
||||
LocalizableString, localizable_consts, localizable_string, wgettext, wgettext_fmt,
|
||||
};
|
||||
@@ -484,7 +483,7 @@ mod tests {
|
||||
|
||||
mod test_path_normalize_for_cd {
|
||||
use super::super::path_normalize_for_cd;
|
||||
use crate::wchar::L;
|
||||
use fish_wchar::L;
|
||||
|
||||
#[test]
|
||||
fn relative_path() {
|
||||
@@ -694,7 +693,7 @@ fn test_wwrite_to_fd() {
|
||||
|
||||
#[test]
|
||||
fn test_wstr_offset_in() {
|
||||
use crate::wchar::L;
|
||||
use fish_wchar::L;
|
||||
let base = L!("hello world");
|
||||
assert_eq!(wstr_offset_in(&base[6..], base), 6);
|
||||
assert_eq!(wstr_offset_in(&base[0..], base), 0);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use super::errors::Error;
|
||||
use super::hex_float;
|
||||
use crate::wchar::IntoCharIter;
|
||||
use fish_wchar::IntoCharIter;
|
||||
|
||||
// Parse a decimal float from a sequence of characters.
|
||||
// Return the parsed float, and (on success) the number of characters consumed.
|
||||
|
||||
Reference in New Issue
Block a user