mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
wc: replace nix by rustix
This commit is contained in:
Generated
+1
-1
@@ -4433,7 +4433,7 @@ dependencies = [
|
||||
"codspeed-divan-compat",
|
||||
"fluent",
|
||||
"libc",
|
||||
"nix",
|
||||
"rustix",
|
||||
"tempfile",
|
||||
"thiserror 2.0.18",
|
||||
"unicode-width 0.2.2",
|
||||
|
||||
Generated
+1
-1
@@ -2102,7 +2102,7 @@ dependencies = [
|
||||
"clap",
|
||||
"fluent",
|
||||
"libc",
|
||||
"nix",
|
||||
"rustix",
|
||||
"thiserror",
|
||||
"unicode-width",
|
||||
"uucore",
|
||||
|
||||
@@ -33,7 +33,7 @@ unicode-width = { workspace = true }
|
||||
|
||||
[target.'cfg(unix)'.dependencies]
|
||||
libc = { workspace = true }
|
||||
nix = { workspace = true }
|
||||
rustix = { workspace = true, features = ["fs"] }
|
||||
|
||||
[dev-dependencies]
|
||||
divan = { workspace = true }
|
||||
|
||||
@@ -16,8 +16,6 @@ use std::io::{self, ErrorKind, Read};
|
||||
#[cfg(unix)]
|
||||
use libc::{_SC_PAGESIZE, S_IFREG, sysconf};
|
||||
#[cfg(unix)]
|
||||
use nix::sys::stat;
|
||||
#[cfg(unix)]
|
||||
use std::io::{Seek, SeekFrom};
|
||||
#[cfg(unix)]
|
||||
use std::os::fd::{AsFd, AsRawFd};
|
||||
@@ -49,7 +47,9 @@ fn count_bytes_using_splice(fd: &impl AsFd) -> Result<usize, usize> {
|
||||
.write(true)
|
||||
.open("/dev/null")
|
||||
.map_err(|_| 0_usize)?;
|
||||
let null_rdev = stat::fstat(null_file.as_fd()).map_err(|_| 0_usize)?.st_rdev as libc::dev_t;
|
||||
let null_rdev = rustix::fs::fstat(null_file.as_fd())
|
||||
.map_err(|_| 0_usize)?
|
||||
.st_rdev as libc::dev_t;
|
||||
if (libc::major(null_rdev), libc::minor(null_rdev)) != (1, 3) {
|
||||
// This is not a proper /dev/null, writing to it is probably bad
|
||||
// Bit of an edge case, but it has been known to happen
|
||||
@@ -92,7 +92,7 @@ pub(crate) fn count_bytes_fast<T: WordCountable>(handle: &mut T) -> (usize, Opti
|
||||
#[cfg(unix)]
|
||||
{
|
||||
let fd = handle.as_fd();
|
||||
if let Ok(stat) = stat::fstat(fd) {
|
||||
if let Ok(stat) = rustix::fs::fstat(fd) {
|
||||
// If the file is regular, then the `st_size` should hold
|
||||
// the file's size in bytes.
|
||||
// If stat.st_size = 0 then
|
||||
|
||||
+1
-2
@@ -297,11 +297,10 @@ impl<'a> Input<'a> {
|
||||
|
||||
#[cfg(unix)]
|
||||
fn is_stdin_small_file() -> bool {
|
||||
use nix::sys::stat;
|
||||
use std::os::fd::AsFd;
|
||||
|
||||
matches!(
|
||||
stat::fstat(io::stdin().as_fd()),
|
||||
rustix::fs::fstat(io::stdin().as_fd()),
|
||||
Ok(meta) if meta.st_mode as libc::mode_t & libc::S_IFMT == libc::S_IFREG && meta.st_size <= (10 << 20)
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user