Skip to content

Commit 33f1634

Browse files
authored
Merge branch 'main' into issue_7184
2 parents 27b6f09 + 5b05670 commit 33f1634

File tree

4 files changed

+23
-6
lines changed

4 files changed

+23
-6
lines changed

src/uu/sort/BENCHMARKING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ rand = "0.8.3"
4848
```rust
4949
use rand::prelude::*;
5050
fn main() {
51-
let suffixes = ['k', 'K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y'];
51+
let suffixes = ['k', 'K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y', 'R', 'Q'];
5252
let mut rng = thread_rng();
5353
for _ in 0..100000 {
5454
println!(

src/uu/sort/src/numeric_str_cmp.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,10 @@ impl NumInfo {
8282
if Self::is_invalid_char(char, &mut had_decimal_pt, parse_settings) {
8383
return if let Some(start) = start {
8484
let has_si_unit = parse_settings.accept_si_units
85-
&& matches!(char, 'K' | 'k' | 'M' | 'G' | 'T' | 'P' | 'E' | 'Z' | 'Y');
85+
&& matches!(
86+
char,
87+
'K' | 'k' | 'M' | 'G' | 'T' | 'P' | 'E' | 'Z' | 'Y' | 'R' | 'Q'
88+
);
8689
(
8790
Self { exponent, sign },
8891
start..if has_si_unit { idx + 1 } else { idx },
@@ -176,6 +179,8 @@ fn get_unit(unit: Option<char>) -> u8 {
176179
'E' => 6,
177180
'Z' => 7,
178181
'Y' => 8,
182+
'R' => 9,
183+
'Q' => 10,
179184
_ => 0,
180185
}
181186
} else {

src/uu/sort/src/sort.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ impl GlobalSettings {
289289
// GNU sort (8.32) invalid: b, B, 1B, p, e, z, y
290290
let size = Parser::default()
291291
.with_allow_list(&[
292-
"b", "k", "K", "m", "M", "g", "G", "t", "T", "P", "E", "Z", "Y",
292+
"b", "k", "K", "m", "M", "g", "G", "t", "T", "P", "E", "Z", "Y", "R", "Q",
293293
])
294294
.with_default_unit("K")
295295
.with_b_byte_count(true)
@@ -535,8 +535,9 @@ impl<'a> Line<'a> {
535535
} else {
536536
// include a trailing si unit
537537
if selector.settings.mode == SortMode::HumanNumeric
538-
&& self.line[selection.end..initial_selection.end]
539-
.starts_with(&['k', 'K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y'][..])
538+
&& self.line[selection.end..initial_selection.end].starts_with(
539+
&['k', 'K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y', 'R', 'Q'][..],
540+
)
540541
{
541542
selection.end += 1;
542543
}

tests/by-util/test_sort.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1314,7 +1314,18 @@ fn test_k_overflow() {
13141314
.stdout_is(output);
13151315
}
13161316

1317+
#[test]
1318+
fn test_human_blocks_r_and_q() {
1319+
let input = "1Q\n1R\n";
1320+
let output = "1R\n1Q\n";
1321+
new_ucmd!()
1322+
.args(&["-h"])
1323+
.pipe_in(input)
1324+
.succeeds()
1325+
.stdout_is(output);
1326+
}
1327+
13171328
#[test]
13181329
fn test_args_check_conflict() {
13191330
new_ucmd!().arg("-c").arg("-C").fails();
1320-
}
1331+
}

0 commit comments

Comments
 (0)