From 99ddee046949a9d49b67ca76d89a675713ad5b65 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 23 Mar 2024 23:24:58 +0000 Subject: [PATCH 1/5] chore(deps): update rust crate uucore to 0.0.25 --- Cargo.lock | 19 +++++++++++++------ Cargo.toml | 2 +- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5920c062..12965fcf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -83,6 +83,12 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "cfg_aliases" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" + [[package]] name = "clap" version = "4.4.18" @@ -233,9 +239,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.152" +version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7" +checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" [[package]] name = "linux-raw-sys" @@ -257,12 +263,13 @@ checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" [[package]] name = "nix" -version = "0.27.1" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053" +checksum = "ab2156c4fce2f8df6c499cc1c763e4394b7482525bf2a9701c9d79d215f519e4" dependencies = [ "bitflags 2.4.2", "cfg-if", + "cfg_aliases", "libc", ] @@ -739,9 +746,9 @@ dependencies = [ [[package]] name = "uucore" -version = "0.0.24" +version = "0.0.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5de2eba1364f6274f35f121eb8671b98ac5fa8fe1271694721e17034e85e8bc" +checksum = "23994a722acb43dbc56877e271c9723f167ae42c4c089f909b2d7dd106c3a9b4" dependencies = [ "clap", "dns-lookup", diff --git a/Cargo.toml b/Cargo.toml index 19c5b57b..f4d34d9a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,7 +33,7 @@ feat_common_core = [ ] [workspace.dependencies] -uucore = "0.0.24" +uucore = "0.0.25" clap = { version = "4.4", features = ["wrap_help", "cargo"] } clap_complete = "4.4" clap_mangen = "0.2" From 542ef0ee297d740ac3bc4dba616bc74160070b13 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Fri, 29 Mar 2024 16:53:29 +0100 Subject: [PATCH 2/5] Cargo.toml: add uudoc as feature --- Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Cargo.toml b/Cargo.toml index 0a68a7db..b8c57c17 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,6 +23,7 @@ build = "build.rs" [features] default = ["feat_common_core"] +uudoc = [] feat_common_core = [ "pwdx", From 9da9fc707437ba83f4ade6bc75c60e28a88aa316 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Sat, 30 Mar 2024 16:06:05 +0100 Subject: [PATCH 3/5] w: disable utmpx on Windows --- src/uu/w/src/w.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/uu/w/src/w.rs b/src/uu/w/src/w.rs index c19df490..1b143d0a 100644 --- a/src/uu/w/src/w.rs +++ b/src/uu/w/src/w.rs @@ -6,6 +6,7 @@ use clap::crate_version; use clap::{Arg, ArgAction, Command}; use std::process; +#[cfg(not(windows))] use uucore::utmpx::Utmpx; use uucore::{error::UResult, format_usage, help_about, help_usage}; @@ -22,6 +23,7 @@ struct UserInfo { command: String, } +#[cfg(not(windows))] fn fetch_user_info() -> Result, std::io::Error> { let mut user_info_list = Vec::new(); for entry in Utmpx::iter_all_records() { @@ -41,6 +43,12 @@ fn fetch_user_info() -> Result, std::io::Error> { Ok(user_info_list) } + +#[cfg(windows)] +fn fetch_user_info() -> Result, std::io::Error> { + Ok(Vec::new()) +} + #[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let matches = uu_app().try_get_matches_from(args)?; From d256e76b028473290847b7449d6e38fbaabe4fab Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Sat, 30 Mar 2024 16:21:16 +0100 Subject: [PATCH 4/5] free: remove redundant import on macOS --- src/uu/free/src/free.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/uu/free/src/free.rs b/src/uu/free/src/free.rs index 0c1b7e0c..f49aef15 100644 --- a/src/uu/free/src/free.rs +++ b/src/uu/free/src/free.rs @@ -25,8 +25,6 @@ use std::fs; #[cfg(target_os = "linux")] use std::io::Error; use std::process; -#[cfg(target_os = "macos")] -use sysinfo; use uucore::{error::UResult, format_usage, help_about, help_usage}; const ABOUT: &str = help_about!("free.md"); From 00e719022ca32f04a5842c99d56f905ec0e52e9e Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Sun, 31 Mar 2024 13:58:03 +0200 Subject: [PATCH 5/5] free: derive Default for MemInfo --- src/uu/free/src/free.rs | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/uu/free/src/free.rs b/src/uu/free/src/free.rs index 0c1b7e0c..d234209a 100644 --- a/src/uu/free/src/free.rs +++ b/src/uu/free/src/free.rs @@ -33,6 +33,7 @@ const ABOUT: &str = help_about!("free.md"); const USAGE: &str = help_usage!("free.md"); /// The unit of number is [UnitMultiplier::Bytes] +#[derive(Default)] struct MemInfo { total: u64, free: u64, @@ -49,18 +50,7 @@ struct MemInfo { #[cfg(target_os = "linux")] fn parse_meminfo() -> Result { let contents = fs::read_to_string("/proc/meminfo")?; - let mut mem_info = MemInfo { - total: 0, - free: 0, - available: 0, - shared: 0, - buffers: 0, - cached: 0, - swap_total: 0, - swap_free: 0, - swap_used: 0, - reclaimable: 0, - }; + let mut mem_info = MemInfo::default(); for line in contents.lines() { if let Some((key, value)) = line.split_once(':') { @@ -107,6 +97,12 @@ fn parse_meminfo() -> Result> { Ok(mem_info) } +// TODO: implement function +#[cfg(target_os = "windows")] +fn parse_meminfo() -> Result> { + Ok(MemInfo::default()) +} + #[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let matches = uu_app().try_get_matches_from(args)?;