Codebase list rust-stfu8 / 7cb2026
coreutils: fix the patches Sylvestre Ledru 3 years ago
5 changed file(s) with 75 addition(s) and 172 deletion(s). Raw diff Collapse all Expand all
5454 }
5555
5656 impl WrappedRng {
57 Index: coreutils/src/uu/more/src/more.rs
58 ===================================================================
59 --- coreutils.orig/src/uu/more/src/more.rs
60 +++ coreutils/src/uu/more/src/more.rs
61 @@ -18,6 +18,8 @@ extern crate nix;
62 #[cfg(all(unix, not(target_os = "fuchsia")))]
63 use nix::sys::termios::{self, LocalFlags, SetArg};
64
65 +use nix::sys::termios::LocalFlags;
66 +
67 #[cfg(target_os = "redox")]
68 extern crate redox_termios;
69 #[cfg(target_os = "redox")]
7057 Index: coreutils/src/uu/env/src/env.rs
7158 ===================================================================
7259 --- coreutils.orig/src/uu/env/src/env.rs
1010 rand = "0.7"
1111 regex = "1.0"
1212 sha1 = { version="0.6", features=["std"] }
13 Index: coreutils/src/uu/cat/Cargo.toml
14 ===================================================================
15 --- coreutils.orig/src/uu/cat/Cargo.toml
16 +++ coreutils/src/uu/cat/Cargo.toml
17 @@ -24,7 +24,7 @@ uucore_procs = { version=">=0.0.5", pack
18 unix_socket = "0.5.0"
19
20 [target.'cfg(any(target_os = "linux", target_os = "android"))'.dependencies]
21 -nix = "0.20"
22 +nix = "0.19"
23
24 [[bin]]
25 name = "cat"
2613 Index: coreutils/src/uu/wc/Cargo.toml
2714 ===================================================================
2815 --- coreutils.orig/src/uu/wc/Cargo.toml
0 commit faef7e9214e865e369c780bd6182ca306560b1aa
1 Author: Sylvestre Ledru <sylvestre@debian.org>
2 Date: Sat Mar 27 10:05:13 2021 +0100
3
4 fix(install): Unbreak the CI by bringing the old behavior for install of /dev/null
5
6 Index: coreutils/src/uu/install/src/install.rs
7 ===================================================================
8 --- coreutils.orig/src/uu/install/src/install.rs
9 +++ coreutils/src/uu/install/src/install.rs
10 @@ -494,10 +494,6 @@ fn copy_file_to_file(file: &PathBuf, tar
11 /// If the copy system call fails, we print a verbose error and return an empty error value.
12 ///
13 fn copy(from: &PathBuf, to: &PathBuf, b: &Behavior) -> Result<(), ()> {
14 - if b.compare && !need_copy(from, to, b) {
15 - return Ok(());
16 - }
17 -
18 if from.to_string_lossy() == "/dev/null" {
19 /* workaround a limitation of fs::copy
20 * https://github.com/rust-lang/rust/issues/79390
21 @@ -511,7 +507,13 @@ fn copy(from: &PathBuf, to: &PathBuf, b:
22 );
23 return Err(());
24 }
25 - } else if let Err(err) = fs::copy(from, to) {
26 + }
27 +
28 + if b.compare && !need_copy(from, to, b) {
29 + return Ok(());
30 + }
31 +
32 + if let Err(err) = fs::copy(from, to) {
33 show_error!(
34 "cannot install '{}' to '{}': {}",
35 from.display(),
99
1010 Co-authored-by: Ivan Rymarchyk <irymarchyk@arlo.com>
1111
12 diff --git b/src/uu/tee/Cargo.toml a/src/uu/tee/Cargo.toml
13 index 51bba2e4..99a6ec23 100644
14 --- b/src/uu/tee/Cargo.toml
15 +++ a/src/uu/tee/Cargo.toml
12 Index: coreutils/src/uu/tee/Cargo.toml
13 ===================================================================
14 --- coreutils.orig/src/uu/tee/Cargo.toml
15 +++ coreutils/src/uu/tee/Cargo.toml
1616 @@ -17,7 +17,6 @@ path = "src/tee.rs"
1717 [dependencies]
1818 clap = "2.33.3"
1919 libc = "0.2.42"
2020 -retain_mut = "0.1.2"
21 uucore = { version=">=0.0.7", package="uucore", path="../../uucore", features=["libc"] }
21 uucore = { version=">=0.0.8", package="uucore", path="../../uucore", features=["libc"] }
2222 uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" }
2323
24 diff --git b/src/uu/tee/src/tee.rs a/src/uu/tee/src/tee.rs
25 index 7c6a86b4..c54fa0d1 100644
26 --- b/src/uu/tee/src/tee.rs
27 +++ a/src/uu/tee/src/tee.rs
24 Index: coreutils/src/uu/tee/src/tee.rs
25 ===================================================================
26 --- coreutils.orig/src/uu/tee/src/tee.rs
27 +++ coreutils/src/uu/tee/src/tee.rs
2828 @@ -9,7 +9,6 @@
2929 extern crate uucore;
3030
8080 let inner: Box<dyn Write> = {
8181 let mut options = OpenOptions::new();
8282 let mode = if append {
83 @@ -140,68 +125,55 @@ fn open(name: String, append: bool) -> Box<dyn Write> {
83 @@ -140,68 +125,55 @@ fn open(name: String, append: bool) -> B
8484 Err(_) => Box::new(sink()),
8585 }
8686 };
1111 itertools = "0.9"
1212 semver = "0.9.0"
1313 uucore = { version=">=0.0.8", package="uucore", path="../../uucore", features=["fs"] }
14 Index: coreutils/src/uu/sort/src/sort.rs
15 ===================================================================
16 --- coreutils.orig/src/uu/sort/src/sort.rs
17 +++ coreutils/src/uu/sort/src/sort.rs
14 diff --git b/src/uu/sort/src/sort.rs a/src/uu/sort/src/sort.rs
15 index 6c29ad98..8e79ff94 100644
16 --- b/src/uu/sort/src/sort.rs
17 +++ a/src/uu/sort/src/sort.rs
1818 @@ -1,7 +1,6 @@
1919 // * This file is part of the uutils coreutils package.
2020 // *
4141 use uucore::fs::is_stdin_interactive; // for Iterator::dedup()
4242
4343 static NAME: &str = "sort";
44 @@ -39,18 +34,16 @@ static OPT_DICTIONARY_ORDER: &str = "dic
44 @@ -39,18 +34,16 @@ static OPT_DICTIONARY_ORDER: &str = "dictionary-order";
4545 static OPT_MERGE: &str = "merge";
4646 static OPT_CHECK: &str = "check";
4747 static OPT_IGNORE_CASE: &str = "ignore-case";
102102 With no FILE, or when FILE is -, read standard input.",
103103 NAME, VERSION
104104 )
105 @@ -237,12 +229,6 @@ pub fn uumain(args: impl uucore::Args) -
105 @@ -236,12 +228,6 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
106 .long(OPT_IGNORE_CASE)
106107 .help("fold lower case to upper case characters"),
107108 )
108 .arg(
109 - .arg(
109110 - Arg::with_name(OPT_IGNORE_BLANKS)
110111 - .short("b")
111112 - .long(OPT_IGNORE_BLANKS)
112113 - .help("ignore leading blanks when finding sort keys in each line"),
113114 - )
114 - .arg(
115 .arg(
115116 Arg::with_name(OPT_OUTPUT)
116117 .short("o")
117 .long(OPT_OUTPUT)
118 @@ -251,12 +237,6 @@ pub fn uumain(args: impl uucore::Args) -
118 @@ -250,12 +236,6 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
119 .takes_value(true)
119120 .value_name("FILENAME"),
120121 )
121 .arg(
122 - .arg(
122123 - Arg::with_name(OPT_RANDOM)
123124 - .short("R")
124125 - .long(OPT_RANDOM)
125126 - .help("shuffle in random order"),
126127 - )
127 - .arg(
128 .arg(
128129 Arg::with_name(OPT_REVERSE)
129130 .short("r")
130 .long(OPT_REVERSE)
131 @@ -305,20 +285,11 @@ pub fn uumain(args: impl uucore::Args) -
131 @@ -305,20 +285,11 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
132132 settings.transform_fns.push(|s| s.to_uppercase());
133133 }
134134
149149 //let mut files = matches.free;
150150 if files.is_empty() {
151151 /* if no file, default to stdin */
152 @@ -342,10 +313,10 @@ pub fn uumain(args: impl uucore::Args) -
152 @@ -342,10 +313,10 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
153153 }
154154 }
155155
162162 let mut lines = Vec::new();
163163 let mut file_merger = FileMerger::new(&settings);
164164
165 @@ -380,13 +351,6 @@ fn exec(files: Vec<String>, settings: &m
165 @@ -380,13 +351,6 @@ fn exec(files: Vec<String>, settings: &mut Settings) -> i32 {
166166 } else {
167167 print_sorted(file_merger, &settings.outfile)
168168 }
176176 } else if settings.unique {
177177 print_sorted(lines.iter().dedup(), &settings.outfile)
178178 } else {
179 @@ -455,11 +419,7 @@ fn compare_by(a: &str, b: &str, settings
179 @@ -455,11 +419,7 @@ fn compare_by(a: &str, b: &str, settings: &Settings) -> Ordering {
180180 };
181181
182182 for compare_fn in &settings.compare_fns {
189189 if cmp != Ordering::Equal {
190190 if settings.reverse {
191191 return cmp.reverse();
192 @@ -471,60 +431,36 @@ fn compare_by(a: &str, b: &str, settings
192 @@ -471,60 +431,36 @@ fn compare_by(a: &str, b: &str, settings: &Settings) -> Ordering {
193193 Ordering::Equal
194194 }
195195
236236 - Ok(a) if a.is_nan() => std::f64::NEG_INFINITY,
237237 - Ok(a) => a,
238238 - Err(_) => std::f64::NEG_INFINITY,
239 - }
240239 + match a.split_whitespace().next() {
241240 + None => std::f64::NEG_INFINITY,
242241 + Some(sa) => match sa.parse::<f64>() {
244243 + Ok(a) => a,
245244 + Err(_) => std::f64::NEG_INFINITY,
246245 + },
247 +}
248 +
246 }
247 }
248
249 -/// Compares two floats, with errors and non-numerics assumed to be -inf.
250 -/// Stops coercing at the first non-numeric char.
249251 +fn default_compare(a: &str, b: &str) -> Ordering {
250252 + a.cmp(b)
251 }
252
253 -/// Compares two floats, with errors and non-numerics assumed to be -inf.
254 -/// Stops coercing at the first non-numeric char.
253 +}
254 +
255255 +/// Compares two floating point numbers, with errors being assumed to be -inf.
256256 +/// Stops coercing at the first whitespace char, so 1e2 will parse as 100 but
257257 +/// 1,000 will parse as -inf.
258258 fn numeric_compare(a: &str, b: &str) -> Ordering {
259259 #![allow(clippy::comparison_chain)]
260
260 -
261261 - let sa = get_leading_number(a);
262262 - let sb = get_leading_number(b);
263263 -
272272 if fa > fb {
273273 Ordering::Greater
274274 } else if fa < fb {
275 @@ -535,10 +471,10 @@ fn numeric_compare(a: &str, b: &str) ->
275 @@ -535,10 +471,10 @@ fn numeric_compare(a: &str, b: &str) -> Ordering {
276276 }
277277
278278 fn human_numeric_convert(a: &str) -> f64 {
287287 'K' => 1000f64,
288288 'M' => 1E6,
289289 'G' => 1E9,
290 @@ -565,30 +501,6 @@ fn human_numeric_size_compare(a: &str, b
290 @@ -565,30 +501,6 @@ fn human_numeric_size_compare(a: &str, b: &str) -> Ordering {
291291 }
292292 }
293293
318318 #[derive(Eq, Ord, PartialEq, PartialOrd)]
319319 enum Month {
320320 Unknown,
321 @@ -694,65 +606,3 @@ fn open(path: &str) -> Option<(Box<dyn R
321 @@ -694,65 +606,3 @@ fn open(path: &str) -> Option<(Box<dyn Read>, bool)> {
322322 }
323323 }
324324 }
384384 - assert_eq!(Ordering::Equal, random_shuffle(a, b, c));
385385 - }
386386 -}
387 Index: coreutils/tests/by-util/test_sort.rs
388 ===================================================================
389 --- coreutils.orig/tests/by-util/test_sort.rs
390 +++ coreutils/tests/by-util/test_sort.rs
391 @@ -2,43 +2,22 @@ use crate::common::util::*;
392
393 #[test]
394 fn test_numeric_floats_and_ints() {
395 - for numeric_sort_param in vec!["-n", "--numeric-sort"] {
396 - let input = "1.444\n8.013\n1\n-8\n1.04\n-1";
397 - new_ucmd!()
398 - .arg(numeric_sort_param)
399 - .pipe_in(input)
400 - .succeeds()
401 - .stdout_only("-8\n-1\n1\n1.04\n1.444\n8.013\n");
402 - }
403 + test_helper("numeric_floats_and_ints", "-n");
404 }
405
406 #[test]
407 fn test_numeric_floats() {
408 - for numeric_sort_param in vec!["-n", "--numeric-sort"] {
409 - let input = "1.444\n8.013\n1.58590\n-8.90880\n1.040000000\n-.05";
410 - new_ucmd!()
411 - .arg(numeric_sort_param)
412 - .pipe_in(input)
413 - .succeeds()
414 - .stdout_only("-8.90880\n-.05\n1.040000000\n1.444\n1.58590\n8.013\n");
415 - }
416 + test_helper("numeric_floats", "-n");
417 }
418
419 #[test]
420 fn test_numeric_floats_with_nan() {
421 - for numeric_sort_param in vec!["-n", "--numeric-sort"] {
422 - let input = "1.444\n1.0/0.0\n1.58590\n-8.90880\n1.040000000\n-.05";
423 - new_ucmd!()
424 - .arg(numeric_sort_param)
425 - .pipe_in(input)
426 - .succeeds()
427 - .stdout_only("-8.90880\n-.05\n1.0/0.0\n1.040000000\n1.444\n1.58590\n");
428 - }
429 + test_helper("numeric_floats_with_nan", "-n");
430 }
431
432 #[test]
433 fn test_numeric_unfixed_floats() {
434 - test_helper("numeric_fixed_floats", "-n");
435 + test_helper("numeric_unfixed_floats", "-n");
436 }
437
438 #[test]
439 @@ -53,26 +32,12 @@ fn test_numeric_unsorted_ints() {
440
441 #[test]
442 fn test_human_block_sizes() {
443 - for human_numeric_sort_param in vec!["-h", "--human-numeric-sort"] {
444 - let input = "8981K\n909991M\n-8T\n21G\n0.8M";
445 - new_ucmd!()
446 - .arg(human_numeric_sort_param)
447 - .pipe_in(input)
448 - .succeeds()
449 - .stdout_only("-8T\n0.8M\n8981K\n21G\n909991M\n");
450 - }
451 + test_helper("human_block_sizes", "-h");
452 }
453
454 #[test]
455 fn test_month_default() {
456 - for month_sort_param in vec!["-M", "--month-sort"] {
457 - let input = "JAn\nMAY\n000may\nJun\nFeb";
458 - new_ucmd!()
459 - .arg(month_sort_param)
460 - .pipe_in(input)
461 - .succeeds()
462 - .stdout_only("000may\nJAn\nFeb\nMAY\nJun\n");
463 - }
464 + test_helper("month_default", "-M");
465 }
466
467 #[test]
468 @@ -82,23 +47,12 @@ fn test_month_stable() {
469
470 #[test]
471 fn test_default_unsorted_ints() {
472 - let input = "9\n1909888\n000\n1\n2";
473 - new_ucmd!()
474 - .pipe_in(input)
475 - .succeeds()
476 - .stdout_only("000\n1\n1909888\n2\n9\n");
477 + test_helper("default_unsorted_ints", "");
478 }
479
480 #[test]
481 fn test_numeric_unique_ints() {
482 - for numeric_unique_sort_param in vec!["-nu"] {
483 - let input = "9\n9\n8\n1\n";
484 - new_ucmd!()
485 - .arg(numeric_unique_sort_param)
486 - .pipe_in(input)
487 - .succeeds()
488 - .stdout_only("1\n8\n9\n");
489 - }
490 + test_helper("numeric_unsorted_ints_unique", "-nu");
491 }
492
493 #[test]