Skip to content

Commit c054594

Browse files
authored
Merge branch 'main' into sort_sort.pl
2 parents dc2952d + 5fd3459 commit c054594

File tree

20 files changed

+411
-123
lines changed

20 files changed

+411
-123
lines changed

.github/workflows/CICD.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -878,10 +878,14 @@ jobs:
878878
shell: bash
879879
run: |
880880
## Package artifact(s)
881-
# binary
881+
# binaries
882882
cp 'target/${{ matrix.job.target }}/release/${{ env.PROJECT_NAME }}${{ steps.vars.outputs.EXE_suffix }}' '${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.PKG_BASENAME }}/'
883+
cp 'target/${{ matrix.job.target }}/release/uudoc${{ steps.vars.outputs.EXE_suffix }}' '${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.PKG_BASENAME }}/' || :
883884
# `strip` binary (if needed)
884-
if [ -n "${{ steps.vars.outputs.STRIP }}" ]; then "${{ steps.vars.outputs.STRIP }}" '${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.PKG_BASENAME }}/${{ env.PROJECT_NAME }}${{ steps.vars.outputs.EXE_suffix }}' ; fi
885+
if [ -n "${{ steps.vars.outputs.STRIP }}" ]; then
886+
"${{ steps.vars.outputs.STRIP }}" '${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.PKG_BASENAME }}/${{ env.PROJECT_NAME }}${{ steps.vars.outputs.EXE_suffix }}'
887+
"${{ steps.vars.outputs.STRIP }}" '${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.PKG_BASENAME }}/uudoc' || :
888+
fi
885889
# README and LICENSE
886890
# * spell-checker:ignore EADME ICENSE
887891
(shopt -s nullglob; for f in [R]"EADME"{,.*}; do cp $f '${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.PKG_BASENAME }}/' ; done)

.github/workflows/benchmarks.yml

Lines changed: 40 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -18,36 +18,38 @@ concurrency:
1818

1919
jobs:
2020
benchmarks:
21-
name: Run benchmarks (CodSpeed)
21+
name: Run ${{ matrix.type }} benchmarks for ${{ matrix.package }} (CodSpeed)
2222
runs-on: ubuntu-latest
2323
strategy:
2424
matrix:
25-
benchmark-target:
26-
- { package: uu_base64 }
27-
- { package: uu_cksum }
28-
- { package: uu_cp }
29-
- { package: uu_cut }
30-
- { package: uu_dd }
31-
- { package: uu_df }
32-
- { package: uu_du }
33-
- { package: uu_expand }
34-
- { package: uu_fold }
35-
- { package: uu_join }
36-
- { package: uu_ls }
37-
- { package: uu_mv }
38-
- { package: uu_nl }
39-
- { package: uu_numfmt }
40-
- { package: uu_rm }
41-
- { package: uu_seq }
42-
- { package: uu_shuf }
43-
- { package: uu_sort }
44-
- { package: uu_split }
45-
- { package: uu_tsort }
46-
- { package: uu_unexpand }
47-
- { package: uu_uniq }
48-
- { package: uu_wc }
49-
- { package: uu_factor }
50-
- { package: uu_date }
25+
type: [performance, memory]
26+
package: [
27+
uu_base64,
28+
uu_cksum,
29+
uu_cp,
30+
uu_cut,
31+
uu_dd,
32+
uu_df,
33+
uu_du,
34+
uu_expand,
35+
uu_fold,
36+
uu_join,
37+
uu_ls,
38+
uu_mv,
39+
uu_nl,
40+
uu_numfmt,
41+
uu_rm,
42+
uu_seq,
43+
uu_shuf,
44+
uu_sort,
45+
uu_split,
46+
uu_tsort,
47+
uu_unexpand,
48+
uu_uniq,
49+
uu_wc,
50+
uu_factor,
51+
uu_date
52+
]
5153
steps:
5254
- uses: actions/checkout@v6
5355
with:
@@ -64,19 +66,23 @@ jobs:
6466
shell: bash
6567
run: cargo install cargo-codspeed --locked
6668

67-
- name: Build benchmarks for ${{ matrix.benchmark-target.package }}
69+
- name: Build benchmarks for ${{ matrix.package }} (${{ matrix.type }})
6870
shell: bash
6971
run: |
70-
echo "Building benchmarks for ${{ matrix.benchmark-target.package }}"
71-
cargo codspeed build -p ${{ matrix.benchmark-target.package }}
72+
echo "Building ${{ matrix.type }} benchmarks for ${{ matrix.package }}"
73+
if [ "${{ matrix.type }}" = "memory" ]; then
74+
cargo codspeed build -m analysis -p ${{ matrix.package }}
75+
else
76+
cargo codspeed build -p ${{ matrix.package }}
77+
fi
7278
73-
- name: Run benchmarks for ${{ matrix.benchmark-target.package }}
79+
- name: Run ${{ matrix.type }} benchmarks for ${{ matrix.package }}
7480
uses: CodSpeedHQ/action@v4
7581
env:
7682
CODSPEED_LOG: debug
7783
with:
78-
mode: simulation
84+
mode: ${{ matrix.type == 'memory' && 'memory' || 'simulation' }}
7985
run: |
80-
echo "Running benchmarks for ${{ matrix.benchmark-target.package }}"
81-
cargo codspeed run -p ${{ matrix.benchmark-target.package }} > /dev/null
86+
echo "Running ${{ matrix.type }} benchmarks for ${{ matrix.package }}"
87+
cargo codspeed run -p ${{ matrix.package }} > /dev/null
8288
token: ${{ secrets.CODSPEED_TOKEN }}

Cargo.lock

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

fuzz/Cargo.lock

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

src/uu/date/src/date.rs

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
mod locale;
99

1010
use clap::{Arg, ArgAction, Command};
11-
use jiff::fmt::strtime;
11+
use jiff::fmt::strtime::{self, BrokenDownTime, Config, PosixCustom};
1212
use jiff::tz::{TimeZone, TimeZoneDatabase};
1313
use jiff::{Timestamp, Zoned};
1414
use std::collections::HashMap;
@@ -431,21 +431,23 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
431431
let mut stdout = BufWriter::new(std::io::stdout().lock());
432432

433433
// Format all the dates
434+
let config = Config::new().custom(PosixCustom::new()).lenient(true);
434435
for date in dates {
435436
match date {
436-
// TODO: Switch to lenient formatting.
437-
Ok(date) => match strtime::format(format_string, &date) {
438-
Ok(s) => writeln!(stdout, "{s}").map_err(|e| {
439-
USimpleError::new(1, translate!("date-error-write", "error" => e))
440-
})?,
441-
Err(e) => {
442-
let _ = stdout.flush();
443-
return Err(USimpleError::new(
444-
1,
445-
translate!("date-error-invalid-format", "format" => format_string, "error" => e),
446-
));
437+
Ok(date) => {
438+
match BrokenDownTime::from(&date).to_string_with_config(&config, format_string) {
439+
Ok(s) => writeln!(stdout, "{s}").map_err(|e| {
440+
USimpleError::new(1, translate!("date-error-write", "error" => e))
441+
})?,
442+
Err(e) => {
443+
let _ = stdout.flush();
444+
return Err(USimpleError::new(
445+
1,
446+
translate!("date-error-invalid-format", "format" => format_string, "error" => e),
447+
));
448+
}
447449
}
448-
},
450+
}
449451
Err((input, _err)) => {
450452
let _ = stdout.flush();
451453
show!(USimpleError::new(

src/uu/ls/src/colors.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -527,18 +527,16 @@ pub(crate) fn color_name(
527527
#[cfg(all(unix, not(any(target_os = "android", target_os = "macos"))))]
528528
{
529529
// Skip checking capabilities if LS_COLORS=ca=:
530-
let capabilities = style_manager
530+
let has_capabilities = style_manager
531531
.colors
532-
.style_for_indicator(Indicator::Capabilities);
533-
534-
let has_capabilities = if capabilities.is_none() {
535-
false
536-
} else {
537-
uucore::fsxattr::has_acl(path.p_buf.as_path())
538-
};
532+
.has_explicit_style_for(Indicator::Capabilities)
533+
&& uucore::fsxattr::has_security_cap_acl(path.p_buf.as_path());
539534

540535
// If the file has capabilities, use a specific style for `ca` (capabilities)
541536
if has_capabilities {
537+
let capabilities = style_manager
538+
.colors
539+
.style_for_indicator(Indicator::Capabilities);
542540
return style_manager.apply_style(capabilities, Some(path), name, wrap);
543541
}
544542
}

src/uu/ls/src/ls.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2968,8 +2968,10 @@ fn display_item_long(
29682968
output_display.extend(b".");
29692969
} else if is_acl_set {
29702970
output_display.extend(b"+");
2971+
} else {
2972+
output_display.extend(b" ");
29712973
}
2972-
output_display.extend(b" ");
2974+
29732975
output_display.extend_pad_left(&display_symlink_count(md), padding.link_count);
29742976

29752977
if config.long.owner {
@@ -3626,6 +3628,19 @@ fn calculate_padding_collection(
36263628
if config.context {
36273629
padding_collections.context = context_len.max(padding_collections.context);
36283630
}
3631+
3632+
// correctly align columns when some files have capabilities/ACLs and others do not
3633+
{
3634+
#[cfg(any(not(unix), target_os = "android", target_os = "macos"))]
3635+
// TODO: See how Mac should work here
3636+
let is_acl_set = false;
3637+
#[cfg(all(unix, not(any(target_os = "android", target_os = "macos"))))]
3638+
let is_acl_set = has_acl(item.display_name());
3639+
if context_len > 1 || is_acl_set {
3640+
padding_collections.link_count += 1;
3641+
}
3642+
}
3643+
36293644
if items.len() == 1usize {
36303645
padding_collections.size = 0usize;
36313646
padding_collections.major = 0usize;

src/uu/mktemp/src/mktemp.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,22 @@ struct Params {
193193
/// assert_eq!(find_last_contiguous_block_of_xs("aXbXcX"), None);
194194
/// ```
195195
fn find_last_contiguous_block_of_xs(s: &str) -> Option<(usize, usize)> {
196-
let j = s.rfind("XXX")? + 3;
197-
let i = s[..j].rfind(|c| c != 'X').map_or(0, |i| i + 1);
198-
Some((i, j))
196+
let bytes = s.as_bytes();
197+
198+
// Find the index of the last 'X'.
199+
let end = bytes.iter().rposition(|&b| b == b'X')?;
200+
201+
// Walk left to find the start of the run of Xs that ends at `end`.
202+
let mut start = end;
203+
while start > 0 && bytes[start - 1] == b'X' {
204+
start -= 1;
205+
}
206+
207+
if end + 1 - start >= 3 {
208+
Some((start, end + 1))
209+
} else {
210+
None
211+
}
199212
}
200213

201214
impl Params {

src/uu/sort/Cargo.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,12 @@ self_cell = { workspace = true }
3434
tempfile = { workspace = true }
3535
thiserror = { workspace = true }
3636
unicode-width = { workspace = true }
37-
uucore = { workspace = true, features = ["fs", "parser-size", "version-cmp"] }
37+
uucore = { workspace = true, features = [
38+
"fs",
39+
"parser-size",
40+
"version-cmp",
41+
"i18n-decimal",
42+
] }
3843
fluent = { workspace = true }
3944

4045
[target.'cfg(unix)'.dependencies]

0 commit comments

Comments
 (0)