Skip to content

Commit 8868844

Browse files
authored
Merge branch 'main' into cp-mv-xattr-enotsup-tests
2 parents bb390e0 + 130f780 commit 8868844

File tree

12 files changed

+116
-82
lines changed

12 files changed

+116
-82
lines changed

.github/workflows/CICD.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,9 @@ jobs:
579579
- { os: ubuntu-latest , target: riscv64gc-unknown-linux-musl , features: feat_os_unix_musl , use-cross: use-cross , skip-tests: true }
580580
# - { os: ubuntu-latest , target: x86_64-unknown-linux-gnu , features: feat_selinux , use-cross: use-cross }
581581
- { os: ubuntu-latest , target: i686-unknown-linux-gnu , features: "feat_os_unix,test_risky_names", use-cross: use-cross }
582-
- { os: ubuntu-latest , target: i686-unknown-linux-musl , features: feat_os_unix_musl , use-cross: use-cross }
582+
# glibc 2.42 is important more than this platform
583+
# Wait https://github.com/rust-lang/libc/pull/4914
584+
#- { os: ubuntu-latest , target: i686-unknown-linux-musl , features: feat_os_unix_musl , use-cross: use-cross }
583585
- { os: ubuntu-latest , target: x86_64-unknown-linux-gnu , features: "feat_os_unix,test_risky_names", use-cross: use-cross, skip-publish: true }
584586
- { os: ubuntu-latest , target: x86_64-unknown-linux-gnu , features: "feat_os_unix,uudoc" , use-cross: no, workspace-tests: true }
585587
- { os: ubuntu-latest , target: x86_64-unknown-linux-musl , features: feat_os_unix_musl , use-cross: use-cross }

.github/workflows/FixPR.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
# Ensure updated '*/Cargo.lock'
4747
# * '*/Cargo.lock' is required to be in a format that `cargo` of MinSRV can interpret (eg, v1-format for MinSRV < v1.38)
4848
for dir in "." "fuzz"; do
49-
( cd "$dir" && (cargo fetch --locked --quiet || cargo +${{ steps.vars.outputs.RUST_MIN_SRV }} update) )
49+
( cd "$dir" && (cargo fetch --locked --quiet --target $(rustc --print host-tuple) || cargo +${{ steps.vars.outputs.RUST_MIN_SRV }} update) )
5050
done
5151
- name: Info
5252
shell: bash
@@ -65,7 +65,7 @@ jobs:
6565
cargo tree -V
6666
## dependencies
6767
echo "## dependency list"
68-
cargo fetch --locked --quiet
68+
cargo fetch --locked --quiet --target $(rustc --print host-tuple)
6969
## * using the 'stable' toolchain is necessary to avoid "unexpected '--filter-platform'" errors
7070
RUSTUP_TOOLCHAIN=stable cargo tree --locked --no-dedupe -e=no-dev --prefix=none --features ${{ matrix.job.features }} | grep -vE "$PWD" | sort --unique
7171
- name: Commit any changes (to '${{ env.BRANCH_TARGET }}')

.vscode/cspell.dictionaries/workspace.wordlist.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ LINESIZE
182182
NAMESIZE
183183
RTLD_NEXT
184184
RTLD
185+
SIGABRT
185186
SIGINT
186187
SIGKILL
187188
SIGSTOP

Cargo.lock

Lines changed: 15 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/uu/cksum/src/cksum.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77

88
use clap::builder::ValueParser;
99
use clap::{Arg, ArgAction, Command};
10-
use std::ffi::{OsStr, OsString};
11-
use std::iter;
10+
use std::ffi::OsString;
1211
use uucore::checksum::compute::{
1312
ChecksumComputeOptions, figure_out_output_format, perform_checksum_computation,
1413
};
@@ -121,12 +120,11 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
121120

122121
let length = maybe_sanitize_length(algo_cli, input_length)?;
123122

124-
let files = matches.get_many::<OsString>(options::FILE).map_or_else(
125-
// No files given, read from stdin.
126-
|| Box::new(iter::once(OsStr::new("-"))) as Box<dyn Iterator<Item = &OsStr>>,
127-
// At least one file given, read from them.
128-
|files| Box::new(files.map(OsStr::new)) as Box<dyn Iterator<Item = &OsStr>>,
129-
);
123+
// clap provides the default value -. So we unwrap() safety.
124+
let files = matches
125+
.get_many::<OsString>(options::FILE)
126+
.unwrap()
127+
.map(|s| s.as_os_str());
130128

131129
if check {
132130
// cksum does not support '--check'ing legacy algorithms
@@ -200,6 +198,8 @@ pub fn uu_app() -> Command {
200198
.hide(true)
201199
.action(ArgAction::Append)
202200
.value_parser(ValueParser::os_string())
201+
.default_value("-")
202+
.hide_default_value(true)
203203
.value_hint(clap::ValueHint::FilePath),
204204
)
205205
.arg(

src/uu/cp/src/copydir.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ use uucore::fs::{
2222
FileInformation, MissingHandling, ResolveMode, canonicalize, path_ends_with_terminator,
2323
};
2424
use uucore::show;
25-
use uucore::show_error;
2625
use uucore::translate;
2726
use uucore::uio_error;
2827
use walkdir::{DirEntry, WalkDir};
@@ -513,7 +512,7 @@ pub(crate) fn copy_directory(
513512
}
514513

515514
// Print an error message, but continue traversing the directory.
516-
Err(e) => show_error!("{e}"),
515+
Err(e) => show!(CpError::WalkDirErr(e)),
517516
}
518517
}
519518

src/uu/hashsum/src/hashsum.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -163,12 +163,11 @@ pub fn uumain(mut args: impl uucore::Args) -> UResult<()> {
163163
let strict = matches.get_flag("strict");
164164
let status = matches.get_flag("status");
165165

166-
let files = matches.get_many::<OsString>(options::FILE).map_or_else(
167-
// No files given, read from stdin.
168-
|| Box::new(iter::once(OsStr::new("-"))) as Box<dyn Iterator<Item = &OsStr>>,
169-
// At least one file given, read from them.
170-
|files| Box::new(files.map(OsStr::new)) as Box<dyn Iterator<Item = &OsStr>>,
171-
);
166+
// clap provides the default value -. So we unwrap() safety.
167+
let files = matches
168+
.get_many::<OsString>(options::FILE)
169+
.unwrap()
170+
.map(|s| s.as_os_str());
172171

173172
if check {
174173
// on Windows, allow --binary/--text to be used with --check
@@ -340,6 +339,8 @@ pub fn uu_app_common() -> Command {
340339
.index(1)
341340
.action(ArgAction::Append)
342341
.value_name(options::FILE)
342+
.default_value("-")
343+
.hide_default_value(true)
343344
.value_hint(clap::ValueHint::FilePath)
344345
.value_parser(ValueParser::os_string()),
345346
)

src/uu/uniq/src/uniq.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,15 @@ impl Uniq {
9595

9696
self.build_meta(&next_buf, &mut next_meta);
9797

98-
if self.keys_differ(&current_buf, &current_meta, &next_buf, &next_meta) {
98+
if self.keys_are_equal(&current_buf, &current_meta, &next_buf, &next_meta) {
99+
if self.all_repeated {
100+
self.print_line(writer, &current_buf, group_count, first_line_printed)?;
101+
first_line_printed = true;
102+
std::mem::swap(&mut current_buf, &mut next_buf);
103+
std::mem::swap(&mut current_meta, &mut next_meta);
104+
}
105+
group_count += 1;
106+
} else {
99107
if (group_count == 1 && !self.repeats_only)
100108
|| (group_count > 1 && !self.uniques_only)
101109
{
@@ -105,14 +113,6 @@ impl Uniq {
105113
std::mem::swap(&mut current_buf, &mut next_buf);
106114
std::mem::swap(&mut current_meta, &mut next_meta);
107115
group_count = 1;
108-
} else {
109-
if self.all_repeated {
110-
self.print_line(writer, &current_buf, group_count, first_line_printed)?;
111-
first_line_printed = true;
112-
std::mem::swap(&mut current_buf, &mut next_buf);
113-
std::mem::swap(&mut current_meta, &mut next_meta);
114-
}
115-
group_count += 1;
116116
}
117117
next_buf.clear();
118118
}
@@ -136,7 +136,7 @@ impl Uniq {
136136
if self.zero_terminated { 0 } else { b'\n' }
137137
}
138138

139-
fn keys_differ(
139+
fn keys_are_equal(
140140
&self,
141141
first_line: &[u8],
142142
first_meta: &LineMeta,
@@ -146,11 +146,11 @@ impl Uniq {
146146
let first_slice = &first_line[first_meta.key_start..first_meta.key_end];
147147
let second_slice = &second_line[second_meta.key_start..second_meta.key_end];
148148

149-
if !self.ignore_case {
150-
return first_slice != second_slice;
149+
if self.ignore_case {
150+
first_slice.eq_ignore_ascii_case(second_slice)
151+
} else {
152+
first_slice == second_slice
151153
}
152-
153-
!first_slice.eq_ignore_ascii_case(second_slice)
154154
}
155155

156156
fn key_bounds(&self, line: &[u8]) -> (usize, usize) {

src/uucore/src/lib/features/fsext.rs

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -420,37 +420,6 @@ fn mount_dev_id(mount_dir: &OsStr) -> String {
420420
}
421421
}
422422

423-
#[cfg(any(
424-
target_os = "freebsd",
425-
target_vendor = "apple",
426-
target_os = "netbsd",
427-
target_os = "openbsd"
428-
))]
429-
use libc::c_int;
430-
#[cfg(any(
431-
target_os = "freebsd",
432-
target_vendor = "apple",
433-
target_os = "netbsd",
434-
target_os = "openbsd"
435-
))]
436-
unsafe extern "C" {
437-
#[cfg(all(target_vendor = "apple", target_arch = "x86_64"))]
438-
#[link_name = "getmntinfo$INODE64"]
439-
fn get_mount_info(mount_buffer_p: *mut *mut StatFs, flags: c_int) -> c_int;
440-
441-
#[cfg(any(
442-
target_os = "netbsd",
443-
target_os = "openbsd",
444-
all(target_vendor = "apple", target_arch = "aarch64")
445-
))]
446-
#[link_name = "getmntinfo"]
447-
fn get_mount_info(mount_buffer_p: *mut *mut StatFs, flags: c_int) -> c_int;
448-
449-
#[cfg(target_os = "freebsd")]
450-
#[link_name = "getmntinfo"]
451-
fn get_mount_info(mount_buffer_p: *mut *mut StatFs, flags: c_int) -> c_int;
452-
}
453-
454423
use crate::error::UResult;
455424
#[cfg(any(
456425
target_os = "freebsd",
@@ -505,9 +474,9 @@ pub fn read_fs_list() -> UResult<Vec<MountInfo>> {
505474
))]
506475
{
507476
let mut mount_buffer_ptr: *mut StatFs = ptr::null_mut();
508-
let len = unsafe { get_mount_info(&raw mut mount_buffer_ptr, 1_i32) };
477+
let len = unsafe { libc::getmntinfo(&raw mut mount_buffer_ptr, 1_i32) };
509478
if len < 0 {
510-
return Err(USimpleError::new(1, "get_mount_info() failed"));
479+
return Err(USimpleError::new(1, "getmntinfo() failed"));
511480
}
512481
let mounts = unsafe { slice::from_raw_parts(mount_buffer_ptr, len as usize) };
513482
Ok(mounts

src/uucore/src/lib/mods/error.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,9 @@ impl Error for ClapErrorWrapper {}
748748
// This is abuse of the Display trait
749749
impl Display for ClapErrorWrapper {
750750
fn fmt(&self, _f: &mut Formatter<'_>) -> Result<(), std::fmt::Error> {
751-
self.error.print().unwrap();
751+
// Intentionally ignore the result - error.print() writes directly to stderr
752+
// and we always return Ok(()) to satisfy Display's contract
753+
let _ = self.error.print();
752754
Ok(())
753755
}
754756
}

0 commit comments

Comments
 (0)