mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-02-22 13:45:24 +08:00
common.rs: add fwprintf and fwputs for convenience
We should get rid of them but this helps with porting. Not sure if they are fully correct.
This commit is contained in:
parent
f53aa6f2e3
commit
c6b8b7548f
@ -15,7 +15,7 @@ use crate::wchar_ffi::WCharToFFI;
|
|||||||
use crate::wcstringutil::wcs2string_callback;
|
use crate::wcstringutil::wcs2string_callback;
|
||||||
use crate::wildcard::{ANY_CHAR, ANY_STRING, ANY_STRING_RECURSIVE};
|
use crate::wildcard::{ANY_CHAR, ANY_STRING, ANY_STRING_RECURSIVE};
|
||||||
use crate::wutil::encoding::{mbrtowc, wcrtomb, zero_mbstate, AT_LEAST_MB_LEN_MAX};
|
use crate::wutil::encoding::{mbrtowc, wcrtomb, zero_mbstate, AT_LEAST_MB_LEN_MAX};
|
||||||
use crate::wutil::{fish_iswalnum, sprintf, wgettext};
|
use crate::wutil::{fish_iswalnum, sprintf, wgettext, wwrite_to_fd};
|
||||||
use bitflags::bitflags;
|
use bitflags::bitflags;
|
||||||
use core::slice;
|
use core::slice;
|
||||||
use cxx::{CxxWString, UniquePtr};
|
use cxx::{CxxWString, UniquePtr};
|
||||||
@ -27,7 +27,7 @@ use std::env;
|
|||||||
use std::ffi::{CString, OsString};
|
use std::ffi::{CString, OsString};
|
||||||
use std::mem::{self, ManuallyDrop};
|
use std::mem::{self, ManuallyDrop};
|
||||||
use std::ops::{Deref, DerefMut};
|
use std::ops::{Deref, DerefMut};
|
||||||
use std::os::fd::AsRawFd;
|
use std::os::fd::{AsRawFd, RawFd};
|
||||||
use std::os::unix::prelude::OsStringExt;
|
use std::os::unix::prelude::OsStringExt;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
@ -1971,6 +1971,20 @@ macro_rules! assert_sorted_by_name {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(unused_macros)]
|
||||||
|
macro_rules! fwprintf {
|
||||||
|
($fd:expr, $format:literal $(, $arg:expr)*) => {
|
||||||
|
{
|
||||||
|
let wide = crate::wutil::sprintf!($format $(, $arg )*);
|
||||||
|
crate::wutil::wwrite_to_fd(&wide, $fd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn fputws(s: &wstr, fd: RawFd) {
|
||||||
|
wwrite_to_fd(s, fd);
|
||||||
|
}
|
||||||
|
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::common::{
|
use crate::common::{
|
||||||
escape_string, str2wcstring, wcs2string, EscapeStringStyle, ENCODE_DIRECT_BASE,
|
escape_string, str2wcstring, wcs2string, EscapeStringStyle, ENCODE_DIRECT_BASE,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user