Skip to content

Commit e99e193

Browse files
committed
feat(df): add thousands separator support with leading quote
Implement thousands separator support for df using GNU coreutils-compatible leading single quote syntax (--block-size='1K). Includes: - extract_thousands_separator_flag() in parse_size.rs - format_with_thousands_separator() in human.rs with locale support - BlockSizeConfig struct in df/blocks.rs - 4 integration tests Also includes ParserBuilderError for better block size validation (restored from PR #9090).
1 parent bd58575 commit e99e193

492 files changed

Lines changed: 6598 additions & 10815 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.cargo/config.toml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,7 @@ linker = "x86_64-unknown-redox-gcc"
88
linker = "aarch64-linux-gnu-gcc"
99
[target.riscv64gc-unknown-linux-musl]
1010
rustflags = ["-C", "target-feature=+crt-static"]
11-
[target.'cfg(target_env = "msvc")']
12-
rustflags = ["-C", "target-feature=+crt-static"]
1311

1412
[env]
1513
# See feat_external_libstdbuf in src/uu/stdbuf/Cargo.toml
1614
LIBSTDBUF_DIR = "/usr/local/libexec/coreutils"
17-
18-
# remove me
19-
[build]
20-
rustflags = ["-A", "clippy::collapsible_if"]

.clippy.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
msrv = "1.85.0"
12
avoid-breaking-exported-api = false
23
check-private-items = true
34
cognitive-complexity-threshold = 24
45
missing-docs-in-crate-items = true
5-
allow-mixed-uninlined-format-args = false

.editorconfig

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,6 @@ switch_case_indent = true
5757
end_of_line = crlf
5858
insert_final_newline = false
5959

60-
[*.toml]
61-
indent_size = 2
62-
indent_style = space
63-
6460
[*.{yaml,yml,[Yy][Mm][Ll],[Yy][Aa][Mm][Ll]}]
6561
# YAML
6662
indent_size = 2

.github/workflows/CICD.yml

Lines changed: 36 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ name: CICD
55
# spell-checker:ignore (jargon) SHAs deps dequote softprops subshell toolchain fuzzers dedupe devel profdata
66
# spell-checker:ignore (people) Peltoche rivy dtolnay Anson dawidd
77
# spell-checker:ignore (shell/tools) binutils choco clippy dmake esac fakeroot fdesc fdescfs gmake grcov halium lcov libclang libfuse libssl limactl mkdir nextest nocross pacman popd printf pushd redoxer rsync rustc rustfmt rustup shopt sccache utmpdump xargs zstd
8-
# spell-checker:ignore (misc) aarch alnum armhf bindir busytest coreutils defconfig DESTDIR gecos getenforce gnueabihf issuecomment maint manpages msys multisize noconfirm nofeatures nullglob onexitbegin onexitend pell runtest Swatinem tempfile testsuite toybox uutils libsystemd codspeed wasip
8+
# spell-checker:ignore (misc) aarch alnum armhf bindir busytest coreutils defconfig DESTDIR gecos getenforce gnueabihf issuecomment maint manpages msys multisize noconfirm nofeatures nullglob onexitbegin onexitend pell runtest Swatinem tempfile testsuite toybox uutils libsystemd codspeed
99

1010
env:
1111
PROJECT_NAME: coreutils
1212
PROJECT_DESC: "Core universal (cross-platform) utilities"
1313
PROJECT_AUTH: "uutils"
14-
RUST_MIN_SRV: "1.88.0"
14+
RUST_MIN_SRV: "1.85.0"
1515
# * style job configuration
1616
STYLE_FAIL_ON_FAULT: true ## (bool) fail the build if a style job contains a fault (error or warning); may be overridden on a per-job basis
1717

@@ -221,8 +221,8 @@ jobs:
221221
# dependencies
222222
echo "## dependency list"
223223
## * using the 'stable' toolchain is necessary to avoid "unexpected '--filter-platform'" errors
224-
cargo +stable fetch --locked --quiet --target $(rustc --print host-tuple)
225-
cargo +stable tree --no-dedupe --locked -e=no-dev --prefix=none ${{ steps.vars.outputs.CARGO_FEATURES_OPTION }} | grep -vE "$PWD" | sort --unique
224+
RUSTUP_TOOLCHAIN=stable cargo fetch --locked --quiet --target $(rustc --print host-tuple)
225+
RUSTUP_TOOLCHAIN=stable cargo tree --no-dedupe --locked -e=no-dev --prefix=none ${{ steps.vars.outputs.CARGO_FEATURES_OPTION }} | grep -vE "$PWD" | sort --unique
226226
- name: Test
227227
run: cargo nextest run --hide-progress-bar --profile ci ${{ steps.vars.outputs.CARGO_FEATURES_OPTION }} -p uucore -p coreutils
228228
env:
@@ -322,13 +322,13 @@ jobs:
322322
disable_search: true
323323
flags: makefile,${{ matrix.job.os }}
324324
fail_ci_if_error: false
325-
- name: "`make install PROG_PREFIX=uu- PROFILE=release-small COMPLETIONS=n MANPAGES=n LOCALES=n`"
325+
- name: "`make install PROG_PREFIX=uu- PROFILE=release-fast COMPLETIONS=n MANPAGES=n LOCALES=n`"
326326
shell: bash
327327
run: |
328328
set -x
329-
DESTDIR=/tmp/ make install PROG_PREFIX=uu- PROFILE=release-small COMPLETIONS=n MANPAGES=n LOCALES=n
329+
DESTDIR=/tmp/ make install PROG_PREFIX=uu- PROFILE=release-fast COMPLETIONS=n MANPAGES=n LOCALES=n
330330
# Check that utils are built with given profile
331-
./target/release-small/true
331+
./target/release-fast/true
332332
# Check that the progs have prefix
333333
test -f /tmp/usr/local/bin/uu-tty
334334
test -f /tmp/usr/local/libexec/uu-coreutils/libstdbuf.*
@@ -501,10 +501,10 @@ jobs:
501501
- uses: Swatinem/rust-cache@v2
502502
- name: Run sccache-cache
503503
uses: mozilla-actions/sccache-action@v0.0.9
504-
- name: "`make install PROFILE=release`"
504+
- name: "`make install PROFILE=release-fast`"
505505
shell: bash
506506
run: |
507-
export CARGO_TARGET_DIR=cargo-target RUSTFLAGS="${RUSTFLAGS} -C strip=symbols" PROFILE=release MANPAGES=n COMPLETIONS=n LOCALES=n
507+
export CARGO_TARGET_DIR=cargo-target RUSTFLAGS="${RUSTFLAGS} -C strip=symbols" PROFILE=release-fast MANPAGES=n COMPLETIONS=n LOCALES=n
508508
mkdir -p "${CARGO_TARGET_DIR}" && sudo mount -t tmpfs -o noatime,size=16G tmpfs "${CARGO_TARGET_DIR}"
509509
make install DESTDIR=target/size-release/
510510
make install COMPLETIONS=n MULTICALL=y LN="ln -vf" DESTDIR=target/size-multi-release/
@@ -548,14 +548,14 @@ jobs:
548548
--arg multisize "$SIZE_MULTI" \
549549
'{($date): { sha: $sha, size: $size, multisize: $multisize, }}' > size-result.json
550550
- name: Download the previous individual size result
551-
uses: dawidd6/action-download-artifact@v14
551+
uses: dawidd6/action-download-artifact@v12
552552
with:
553553
workflow: CICD.yml
554554
name: individual-size-result
555555
repo: uutils/coreutils
556556
path: dl
557557
- name: Download the previous size result
558-
uses: dawidd6/action-download-artifact@v14
558+
uses: dawidd6/action-download-artifact@v12
559559
with:
560560
workflow: CICD.yml
561561
name: size-result
@@ -630,11 +630,11 @@ jobs:
630630
- { os: ubuntu-latest , target: x86_64-unknown-linux-gnu , features: "feat_os_unix,test_risky_names", use-cross: use-cross, skip-publish: true }
631631
- { os: ubuntu-latest , target: x86_64-unknown-linux-gnu , features: "feat_os_unix,uudoc" , use-cross: no, workspace-tests: true }
632632
- { os: ubuntu-latest , target: x86_64-unknown-linux-musl , features: feat_os_unix_musl , use-cross: use-cross }
633-
- { os: ubuntu-latest , target: x86_64-unknown-redox , features: feat_os_unix_redox , use-cross: redoxer , skip-tests: true , check-only: true }
634-
- { os: ubuntu-latest , target: wasm32-wasip1, default-features: false, features: "basenc,cksum", skip-tests: true }
633+
- { os: ubuntu-latest , target: x86_64-unknown-redox , features: feat_os_unix_redox , use-cross: redoxer , skip-tests: true }
634+
- { os: ubuntu-latest , target: wasm32-unknown-unknown , default-features: false, features: uucore/format, skip-tests: true, skip-package: true, skip-publish: true }
635635
- { os: macos-latest , target: aarch64-apple-darwin , features: feat_os_macos, workspace-tests: true } # M1 CPU
636-
# PR #7964: chcon should not break build without the feature. cargo check is enough to detect it.
637-
- { os: macos-latest , target: aarch64-apple-darwin , workspace-tests: true, check-only: true } # M1 CPU
636+
# PR #7964: Mac should still build even if the feature is not enabled. Do not publish this.
637+
- { os: macos-latest , target: aarch64-apple-darwin , workspace-tests: true, skip-publish: true } # M1 CPU
638638
- { os: macos-latest , target: x86_64-apple-darwin , features: feat_os_macos, workspace-tests: true }
639639
- { os: windows-latest , target: i686-pc-windows-msvc , features: feat_os_windows }
640640
- { os: windows-latest , target: x86_64-pc-windows-gnu , features: feat_os_windows }
@@ -671,6 +671,9 @@ jobs:
671671
# staging directory
672672
STAGING='_staging'
673673
outputs STAGING
674+
# determine EXE suffix
675+
EXE_suffix="" ; case '${{ matrix.job.target }}' in *-pc-windows-*) EXE_suffix=".exe" ;; esac;
676+
outputs EXE_suffix
674677
# parse commit reference info
675678
echo GITHUB_REF=${GITHUB_REF}
676679
echo GITHUB_SHA=${GITHUB_SHA}
@@ -698,11 +701,7 @@ jobs:
698701
outputs TARGET_ARCH TARGET_OS
699702
# package name
700703
PKG_suffix=".tar.gz" ; case '${{ matrix.job.target }}' in *-pc-windows-*) PKG_suffix=".zip" ;; esac;
701-
# Some 3rd party utils need version at file names
702-
# But we remove it from tag/latest-commit
703-
test ${REF_TAG} \
704-
&& PKG_BASENAME=${PROJECT_NAME}-${REF_TAG}-${{ matrix.job.target }} \
705-
|| PKG_BASENAME=${PROJECT_NAME}-${{ matrix.job.target }}
704+
PKG_BASENAME=${PROJECT_NAME}-${{ matrix.job.target }}
706705
PKG_NAME=${PKG_BASENAME}${PKG_suffix}
707706
outputs PKG_suffix PKG_BASENAME PKG_NAME
708707
# deployable tag? (ie, leading "vM" or "M"; M == version number)
@@ -842,16 +841,14 @@ jobs:
842841
echo "## dependency list"
843842
cargo fetch --locked --quiet --target $(rustc --print host-tuple)
844843
cargo tree --locked --target=${{ matrix.job.target }} ${{ matrix.job.cargo-options }} ${{ steps.vars.outputs.CARGO_FEATURES_OPTION }} ${{ steps.vars.outputs.CARGO_DEFAULT_FEATURES_OPTION }} --no-dedupe -e=no-dev --prefix=none | grep -vE "$PWD" | sort --unique
845-
- name: Check
844+
- name: Build
846845
shell: bash
847-
if: matrix.job.skip-publish != true && matrix.job.check-only == true
848846
run: |
849-
# expr breaks redox
850-
sed -i.b '/"expr",/d' Cargo.toml
851-
${{ steps.vars.outputs.CARGO_CMD }} ${{ steps.vars.outputs.CARGO_CMD_OPTIONS }} check \
847+
## Build
848+
${{ steps.vars.outputs.CARGO_CMD }} ${{ steps.vars.outputs.CARGO_CMD_OPTIONS }} build --release --config=profile.release.strip=true \
852849
--target=${{ matrix.job.target }} ${{ matrix.job.cargo-options }} ${{ steps.vars.outputs.CARGO_FEATURES_OPTION }} ${{ steps.vars.outputs.CARGO_DEFAULT_FEATURES_OPTION }}
853850
- name: Test
854-
if: matrix.job.skip-tests != true && matrix.job.check-only != true
851+
if: matrix.job.skip-tests != true
855852
shell: bash
856853
run: |
857854
## Test
@@ -860,29 +857,19 @@ jobs:
860857
${{ steps.dep_vars.outputs.CARGO_UTILITY_LIST_OPTIONS }} -p coreutils
861858
env:
862859
RUST_BACKTRACE: "1"
863-
- name: Build coreutils
864-
shell: bash
865-
if: matrix.job.skip-publish != true && matrix.job.check-only != true && matrix.job.target != 'x86_64-pc-windows-msvc'
866-
run: |
867-
## Build
868-
${{ steps.vars.outputs.CARGO_CMD }} ${{ steps.vars.outputs.CARGO_CMD_OPTIONS }} build --release --config=profile.release.strip=true \
869-
--target=${{ matrix.job.target }} ${{ matrix.job.cargo-options }} ${{ steps.vars.outputs.CARGO_FEATURES_OPTION }} ${{ steps.vars.outputs.CARGO_DEFAULT_FEATURES_OPTION }}
870-
# We don't want to have many duplicated long jobs at here
871-
# So we build individual binaries for few platforms until we deduplicate many release build for Linux
872-
- name: Build individual binaries
873-
if: matrix.job.skip-tests != true && matrix.job.target == 'x86_64-pc-windows-msvc'
874-
shell: bash
875-
run: |
876-
${{ steps.vars.outputs.CARGO_CMD }} ${{ steps.vars.outputs.CARGO_CMD_OPTIONS }} build --release --config=profile.release.strip=true \
877-
--target=${{ matrix.job.target }} ${{ steps.dep_vars.outputs.CARGO_UTILITY_LIST_OPTIONS }}
860+
- name: Archive executable artifacts
861+
uses: actions/upload-artifact@v6
862+
with:
863+
name: ${{ env.PROJECT_NAME }}-${{ matrix.job.target }}${{ steps.vars.outputs.ARTIFACTS_SUFFIX }}
864+
path: target/${{ matrix.job.target }}/release/${{ env.PROJECT_NAME }}${{ steps.vars.outputs.EXE_suffix }}
878865
- name: Package
879-
if: matrix.job.skip-publish != true && matrix.job.check-only != true
866+
if: matrix.job.skip-package != true
880867
shell: bash
881868
run: |
882869
## Package artifact(s)
883-
find target/${{ matrix.job.target }}/release -maxdepth 1 -type f \
884-
\( -name "*.wasm" -o -name "*.exe" -o -perm -u+x \) \
885-
-exec ln -v {} "${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.PKG_BASENAME }}/" \;
870+
# binaries
871+
cp 'target/${{ matrix.job.target }}/release/${{ env.PROJECT_NAME }}${{ steps.vars.outputs.EXE_suffix }}' '${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.PKG_BASENAME }}/'
872+
cp 'target/${{ matrix.job.target }}/release/uudoc${{ steps.vars.outputs.EXE_suffix }}' '${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.PKG_BASENAME }}/' || :
886873
# README and LICENSE
887874
# * spell-checker:ignore EADME ICENSE
888875
(shopt -s nullglob; for f in [R]"EADME"{,.*}; do cp $f '${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.PKG_BASENAME }}/' ; done)
@@ -910,7 +897,7 @@ jobs:
910897
tar --zstd -cf docs.tar.zst share
911898
- name: Publish
912899
uses: softprops/action-gh-release@v2
913-
if: steps.vars.outputs.DEPLOY && matrix.job.skip-publish != true && matrix.job.check-only != true
900+
if: steps.vars.outputs.DEPLOY && matrix.job.skip-publish != true
914901
with:
915902
draft: true
916903
files: |
@@ -920,11 +907,9 @@ jobs:
920907
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
921908
- name: Publish latest commit
922909
uses: softprops/action-gh-release@v2
923-
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && matrix.job.skip-publish != true && matrix.job.check-only != true
910+
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && matrix.job.skip-publish != true
924911
with:
925912
tag_name: latest-commit
926-
body: |
927-
commit: ${{ github.sha }}
928913
draft: false
929914
prerelease: true
930915
files: |
@@ -1240,8 +1225,7 @@ jobs:
12401225
fail_ci_if_error: false
12411226

12421227
test_separately:
1243-
# duplicated with other CI, but has better appearance
1244-
name: Separate Builds (individual and coreutils)
1228+
name: Separate Builds (individual and coreutils)# duplicated with other CI, but has better appearance
12451229
runs-on: ${{ matrix.job.os }}
12461230
strategy:
12471231
fail-fast: false
@@ -1326,9 +1310,8 @@ jobs:
13261310
run: |
13271311
test -f target/debug/chcon || test -f target/debug/chcon.exe
13281312
test -f target/debug/runcon || test -f target/debug/runcon.exe
1329-
# check is enough to detect workspace breakage by chcon
13301313
- name: Verify workspace builds with stubs
1331-
run: cargo check --features ${{ matrix.job.features }}
1314+
run: cargo build --features ${{ matrix.job.features }}
13321315

13331316
test_safe_traversal:
13341317
name: Safe Traversal Security Check

.github/workflows/FixPR.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ jobs:
6767
echo "## dependency list"
6868
cargo fetch --locked --quiet --target $(rustc --print host-tuple)
6969
## * using the 'stable' toolchain is necessary to avoid "unexpected '--filter-platform'" errors
70-
cargo +stable tree --locked --no-dedupe -e=no-dev --prefix=none --features ${{ matrix.job.features }} | grep -vE "$PWD" | sort --unique
70+
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 }}')
7272
uses: EndBug/add-and-commit@v9
7373
with:

.github/workflows/GnuComment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,4 @@ jobs:
5959
issue_number: issue_number,
6060
body: 'GNU testsuite comparison:\n```\n' + content + '```'
6161
});
62-
}
62+
}

.github/workflows/GnuTests.yml

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
name: Run GNU tests (native)
3939
runs-on: ubuntu-24.04
4040
steps:
41-
#### Get the code
41+
#### Get the code, setup cache
4242
- name: Checkout code (uutils)
4343
uses: actions/checkout@v6
4444
with:
@@ -49,6 +49,15 @@ jobs:
4949
workspaces: "./uutils -> target"
5050
- name: Checkout code (GNU coreutils)
5151
run: (mkdir -p gnu && cd gnu && bash ../uutils/util/fetch-gnu.sh)
52+
- name: Restore files for faster configure and skipping make
53+
uses: actions/cache@v5
54+
id: cache-config-gnu
55+
with:
56+
path: |
57+
gnu/config.cache
58+
gnu/src/getlimits
59+
key: ${{ runner.os }}-gnu-config-${{ hashFiles('gnu/NEWS') }}-${{ hashFiles('uutils/util/build-gnu.sh') }} # use build-gnu.sh for extremely safe caching
60+
5261
#### Build environment setup
5362
- name: Install dependencies
5463
shell: bash
@@ -93,6 +102,15 @@ jobs:
93102
cd 'uutils'
94103
env PROFILE=release-small bash util/build-gnu.sh
95104
105+
- name: Save files for faster configure and skipping make
106+
uses: actions/cache/save@v5
107+
if: always() && steps.cache-config-gnu.outputs.cache-hit != 'true'
108+
with:
109+
path: |
110+
gnu/config.cache
111+
gnu/src/getlimits
112+
key: ${{ runner.os }}-gnu-config-${{ hashFiles('gnu/NEWS') }}-${{ hashFiles('uutils/util/build-gnu.sh') }}
113+
96114
### Run tests as user
97115
- name: Run GNU tests
98116
shell: bash
@@ -180,7 +198,7 @@ jobs:
180198
name: Run GNU tests (SELinux)
181199
runs-on: ubuntu-24.04
182200
steps:
183-
#### Get the code
201+
#### Get the code, setup cache
184202
- name: Checkout code (uutils)
185203
uses: actions/checkout@v6
186204
with:
@@ -354,7 +372,7 @@ jobs:
354372
path: 'uutils'
355373
persist-credentials: false
356374
- name: Retrieve reference artifacts
357-
uses: dawidd6/action-download-artifact@v14
375+
uses: dawidd6/action-download-artifact@v12
358376
# ref: <https://github.com/dawidd6/action-download-artifact>
359377
continue-on-error: true ## don't break the build for missing reference artifacts (may be expired or just not generated yet)
360378
with:

.github/workflows/audit.yml

Lines changed: 0 additions & 15 deletions
This file was deleted.

.github/workflows/benchmarks.yml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
name: Benchmarks
22

3-
# spell-checker:ignore (people) dtolnay Swatinem taiki-e
4-
# spell-checker:ignore (misc) codspeed sccache
3+
# spell-checker:ignore codspeed dtolnay Swatinem sccache
54

65
on:
76
pull_request:
@@ -27,7 +26,7 @@ jobs:
2726
SCCACHE_GHA_ENABLED: "true"
2827
strategy:
2928
matrix:
30-
type: [simulation, memory]
29+
type: [simulation] # , memory] # memory profile disabled due to variance
3130
package: [
3231
uu_base64,
3332
uu_cksum,
@@ -53,8 +52,7 @@ jobs:
5352
uu_uniq,
5453
uu_wc,
5554
uu_factor,
56-
uu_date,
57-
uu_csplit
55+
uu_date
5856
]
5957
steps:
6058
- uses: actions/checkout@v6
@@ -71,13 +69,14 @@ jobs:
7169
- name: Install locales
7270
shell: bash
7371
run: |
72+
sudo apt-get update
73+
sudo apt-get install -y locales
7474
sudo locale-gen fr_FR.UTF-8
7575
sudo update-locale
7676
77-
- name: Install tools
78-
uses: taiki-e/install-action@v2
79-
with:
80-
tool: cargo-codspeed
77+
- name: Install cargo-codspeed
78+
shell: bash
79+
run: cargo install cargo-codspeed --locked
8180

8281
- name: Build benchmarks for ${{ matrix.package }} (${{ matrix.type }})
8382
shell: bash

.github/workflows/code-quality.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ jobs:
3535
- uses: actions/checkout@v6
3636
with:
3737
persist-credentials: false
38+
- uses: dtolnay/rust-toolchain@master
39+
with:
40+
toolchain: stable
41+
components: rustfmt
42+
- uses: Swatinem/rust-cache@v2
3843
- name: Initialize workflow variables
3944
id: vars
4045
shell: bash

0 commit comments

Comments
 (0)