mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
Merge branch 'master' into implement-more
This commit is contained in:
@@ -84,7 +84,7 @@ jobs:
|
||||
- name: Install `rust` toolchain
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
toolchain: nightly
|
||||
default: true
|
||||
profile: minimal # minimal component installation (ie, no documentation)
|
||||
components: clippy
|
||||
@@ -94,7 +94,7 @@ jobs:
|
||||
run: |
|
||||
# `clippy` testing
|
||||
# * convert any warnings to GHA UI annotations; ref: <https://help.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-a-warning-message>
|
||||
S=$(cargo clippy ${{ matrix.job.cargo-options }} ${{ steps.vars.outputs.CARGO_FEATURES_OPTION }} -- -D warnings 2>&1) && printf "%s\n" "$S" || { printf "%s\n" "$S" ; printf "%s" "$S" | sed -E -n -e '/^error:/{' -e "N; s/^error:[[:space:]]+(.*)\\n[[:space:]]+-->[[:space:]]+(.*):([0-9]+):([0-9]+).*$/::warning file=\2,line=\3,col=\4::WARNING: \`cargo clippy\`: \1/p;" -e '}' ; }
|
||||
S=$(cargo +nightly clippy --all-targets ${{ matrix.job.cargo-options }} ${{ steps.vars.outputs.CARGO_FEATURES_OPTION }} -- -D warnings 2>&1) && printf "%s\n" "$S" || { printf "%s\n" "$S" ; printf "%s" "$S" | sed -E -n -e '/^error:/{' -e "N; s/^error:[[:space:]]+(.*)\\n[[:space:]]+-->[[:space:]]+(.*):([0-9]+):([0-9]+).*$/::warning file=\2,line=\3,col=\4::WARNING: \`cargo clippy\`: \1/p;" -e '}' ; }
|
||||
|
||||
min_version:
|
||||
name: MinRustV # Minimum supported rust version
|
||||
@@ -614,3 +614,20 @@ jobs:
|
||||
flags: ${{ steps.vars.outputs.CODECOV_FLAGS }}
|
||||
name: codecov-umbrella
|
||||
fail_ci_if_error: false
|
||||
spellcheck:
|
||||
name: Spell Check
|
||||
runs-on: ${{ matrix.job.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
job:
|
||||
- { os: ubuntu-latest }
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Install/setup prerequisites
|
||||
shell: bash
|
||||
run: |
|
||||
sudo apt-get -y update ; sudo apt-get -y install npm ; sudo npm install cspell -g;
|
||||
- name: Run `cspell`
|
||||
shell: bash
|
||||
run: |
|
||||
cspell --config .vscode/cSpell.json --no-summary --no-progress $( git ls-files | grep "\.\(rs\|md\)" ) | sed "s/\(.*\):\(.*\):\(.*\) - \(.*\)/::warning file=\1,line=\2,col=\3::cspell: \4/" || true
|
||||
|
||||
+15
-6
@@ -1,8 +1,17 @@
|
||||
# https://pre-commit.com
|
||||
repos:
|
||||
- repo: https://github.com/doublify/pre-commit-rust
|
||||
rev: v1.0
|
||||
- repo: local
|
||||
hooks:
|
||||
- id: cargo-check
|
||||
- id: clippy
|
||||
- id: fmt
|
||||
- id: rust-linting
|
||||
name: Rust linting
|
||||
description: Run cargo fmt on files included in the commit.
|
||||
entry: cargo +nightly fmt --
|
||||
pass_filenames: true
|
||||
types: [file, rust]
|
||||
language: system
|
||||
- id: rust-clippy
|
||||
name: Rust clippy
|
||||
description: Run cargo clippy on files included in the commit.
|
||||
entry: cargo +nightly clippy --all-targets --all-features --
|
||||
pass_filenames: false
|
||||
types: [file, rust]
|
||||
language: system
|
||||
|
||||
Generated
+18
-290
@@ -1,5 +1,7 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "Inflector"
|
||||
version = "0.11.4"
|
||||
@@ -43,12 +45,6 @@ dependencies = [
|
||||
"winapi 0.3.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "array-init"
|
||||
version = "2.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6945cc5422176fc5e602e590c2878d2c2acd9a4fe20a4baa7c28022521698ec6"
|
||||
|
||||
[[package]]
|
||||
name = "arrayvec"
|
||||
version = "0.4.12"
|
||||
@@ -134,15 +130,8 @@ dependencies = [
|
||||
"lazy_static",
|
||||
"memchr 2.4.0",
|
||||
"regex-automata",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bumpalo"
|
||||
version = "3.6.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "63396b8a4b9de3f4fdfb320ab6080762242f66a8ef174c49d8e19b674db4cdbe"
|
||||
|
||||
[[package]]
|
||||
name = "byte-tools"
|
||||
version = "0.2.0"
|
||||
@@ -155,15 +144,6 @@ version = "1.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610"
|
||||
|
||||
[[package]]
|
||||
name = "cast"
|
||||
version = "0.2.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "57cdfa5d50aad6cb4d44dcab6101a7f79925bd59d82ca42f38a9856a28865374"
|
||||
dependencies = [
|
||||
"rustc_version",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.0.67"
|
||||
@@ -285,7 +265,6 @@ dependencies = [
|
||||
"uu_expand",
|
||||
"uu_expr",
|
||||
"uu_factor",
|
||||
"uu_factor_benches",
|
||||
"uu_false",
|
||||
"uu_fmt",
|
||||
"uu_fold",
|
||||
@@ -464,42 +443,6 @@ dependencies = [
|
||||
"unicode-xid 0.0.4",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "criterion"
|
||||
version = "0.3.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ab327ed7354547cc2ef43cbe20ef68b988e70b4b593cbd66a2a61733123a3d23"
|
||||
dependencies = [
|
||||
"atty",
|
||||
"cast",
|
||||
"clap",
|
||||
"criterion-plot",
|
||||
"csv",
|
||||
"itertools 0.10.0",
|
||||
"lazy_static",
|
||||
"num-traits",
|
||||
"oorandom",
|
||||
"plotters",
|
||||
"rayon",
|
||||
"regex",
|
||||
"serde",
|
||||
"serde_cbor",
|
||||
"serde_derive",
|
||||
"serde_json",
|
||||
"tinytemplate",
|
||||
"walkdir",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "criterion-plot"
|
||||
version = "0.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e022feadec601fba1649cfa83586381a4ad31c6bf3a9ab7d408118b05dd9889d"
|
||||
dependencies = [
|
||||
"cast",
|
||||
"itertools 0.9.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-channel"
|
||||
version = "0.5.1"
|
||||
@@ -842,15 +785,6 @@ dependencies = [
|
||||
"either",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itertools"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "284f18f85651fe11e8a991b2adb42cb078325c996ed026d994719efcfca1d54b"
|
||||
dependencies = [
|
||||
"either",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itertools"
|
||||
version = "0.10.0"
|
||||
@@ -860,21 +794,6 @@ dependencies = [
|
||||
"either",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itoa"
|
||||
version = "0.4.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736"
|
||||
|
||||
[[package]]
|
||||
name = "js-sys"
|
||||
version = "0.3.51"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "83bdfbace3a0e81a4253f73b49e960b053e396a11012cbd49b9b74d6a2b67062"
|
||||
dependencies = [
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "kernel32-sys"
|
||||
version = "0.2.2"
|
||||
@@ -1035,6 +954,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3f6bb902e437b6d86e03cce10a7e2af662292c5dfef23b65899ea3ac9354ad44"
|
||||
dependencies = [
|
||||
"winapi 0.3.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-bigint"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4e0d047c1062aa51e256408c560894e5251f08925980e53cf1aa5bd00eec6512"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"num-integer",
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1106,12 +1036,6 @@ dependencies = [
|
||||
"pkg-config",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "oorandom"
|
||||
version = "11.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575"
|
||||
|
||||
[[package]]
|
||||
name = "ouroboros"
|
||||
version = "0.9.3"
|
||||
@@ -1188,15 +1112,6 @@ dependencies = [
|
||||
"proc-macro-hack",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pest"
|
||||
version = "2.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "10f4872ae94d7b90ae48754df22fd42ad52ce740b8f370b03da4835417403e53"
|
||||
dependencies = [
|
||||
"ucd-trie",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pkg-config"
|
||||
version = "0.3.19"
|
||||
@@ -1213,34 +1128,6 @@ dependencies = [
|
||||
"winapi 0.3.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "plotters"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "32a3fd9ec30b9749ce28cd91f255d569591cdf937fe280c312143e3c4bad6f2a"
|
||||
dependencies = [
|
||||
"num-traits",
|
||||
"plotters-backend",
|
||||
"plotters-svg",
|
||||
"wasm-bindgen",
|
||||
"web-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "plotters-backend"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b07fffcddc1cb3a1de753caa4e4df03b79922ba43cf882acc1bdd7e8df9f4590"
|
||||
|
||||
[[package]]
|
||||
name = "plotters-svg"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b38a02e23bd9604b842a812063aec4ef702b57989c37b655254bb61c471ad211"
|
||||
dependencies = [
|
||||
"plotters-backend",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ppv-lite86"
|
||||
version = "0.2.10"
|
||||
@@ -1546,21 +1433,6 @@ version = "0.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3e52c148ef37f8c375d49d5a73aa70713125b7f19095948a923f80afdeb22ec2"
|
||||
|
||||
[[package]]
|
||||
name = "rustc_version"
|
||||
version = "0.3.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f0dfe2087c51c460008730de8b57e6a320782fbfb312e1f4d520e6c6fae155ee"
|
||||
dependencies = [
|
||||
"semver 0.11.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ryu"
|
||||
version = "1.0.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e"
|
||||
|
||||
[[package]]
|
||||
name = "same-file"
|
||||
version = "1.0.6"
|
||||
@@ -1582,16 +1454,7 @@ version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
|
||||
dependencies = [
|
||||
"semver-parser 0.7.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "semver"
|
||||
version = "0.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6"
|
||||
dependencies = [
|
||||
"semver-parser 0.10.2",
|
||||
"semver-parser",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1600,53 +1463,6 @@ version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
|
||||
|
||||
[[package]]
|
||||
name = "semver-parser"
|
||||
version = "0.10.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7"
|
||||
dependencies = [
|
||||
"pest",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.126"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ec7505abeacaec74ae4778d9d9328fe5a5d04253220a85c4ee022239fc996d03"
|
||||
|
||||
[[package]]
|
||||
name = "serde_cbor"
|
||||
version = "0.11.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e18acfa2f90e8b735b2836ab8d538de304cbb6729a7360729ea5a895d15a622"
|
||||
dependencies = [
|
||||
"half",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.126"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "963a7dbc9895aeac7ac90e74f34a5d5261828f79df35cbed41e10189d3804d43"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote 1.0.9",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_json"
|
||||
version = "1.0.64"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "799e97dc9fdae36a5c8b8f2cae9ce2ee9fdce2058c57a93e6099d919fd982f79"
|
||||
dependencies = [
|
||||
"itoa",
|
||||
"ryu",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sha1"
|
||||
version = "0.6.0"
|
||||
@@ -1863,28 +1679,12 @@ dependencies = [
|
||||
"winapi 0.3.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tinytemplate"
|
||||
version = "1.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "be4d6b5f19ff7664e8c98d03e2139cb510db9b0a60b55f8e8709b689d939b6bc"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "typenum"
|
||||
version = "1.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "879f6906492a7cd215bfa4cf595b600146ccfac0c79bcbd1f3000162af5e8b06"
|
||||
|
||||
[[package]]
|
||||
name = "ucd-trie"
|
||||
version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-segmentation"
|
||||
version = "1.7.1"
|
||||
@@ -2171,6 +1971,8 @@ name = "uu_expr"
|
||||
version = "0.0.6"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"num-bigint",
|
||||
"num-traits",
|
||||
"onig",
|
||||
"uucore",
|
||||
"uucore_procs",
|
||||
@@ -2180,6 +1982,7 @@ dependencies = [
|
||||
name = "uu_factor"
|
||||
version = "0.0.6"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"coz",
|
||||
"num-traits",
|
||||
"paste",
|
||||
@@ -2190,17 +1993,6 @@ dependencies = [
|
||||
"uucore_procs",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "uu_factor_benches"
|
||||
version = "0.0.0"
|
||||
dependencies = [
|
||||
"array-init",
|
||||
"criterion",
|
||||
"rand 0.7.3",
|
||||
"rand_chacha 0.2.2",
|
||||
"uu_factor",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "uu_false"
|
||||
version = "0.0.6"
|
||||
@@ -2681,7 +2473,7 @@ dependencies = [
|
||||
"ouroboros",
|
||||
"rand 0.7.3",
|
||||
"rayon",
|
||||
"semver 0.9.0",
|
||||
"semver",
|
||||
"tempfile",
|
||||
"unicode-width",
|
||||
"uucore",
|
||||
@@ -3029,70 +2821,6 @@ version = "0.10.2+wasi-snapshot-preview1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6"
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen"
|
||||
version = "0.2.74"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d54ee1d4ed486f78874278e63e4069fc1ab9f6a18ca492076ffb90c5eb2997fd"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
"wasm-bindgen-macro",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-backend"
|
||||
version = "0.2.74"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3b33f6a0694ccfea53d94db8b2ed1c3a8a4c86dd936b13b9f0a15ec4a451b900"
|
||||
dependencies = [
|
||||
"bumpalo",
|
||||
"lazy_static",
|
||||
"log",
|
||||
"proc-macro2",
|
||||
"quote 1.0.9",
|
||||
"syn",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro"
|
||||
version = "0.2.74"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "088169ca61430fe1e58b8096c24975251700e7b1f6fd91cc9d59b04fb9b18bd4"
|
||||
dependencies = [
|
||||
"quote 1.0.9",
|
||||
"wasm-bindgen-macro-support",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro-support"
|
||||
version = "0.2.74"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "be2241542ff3d9f241f5e2cb6dd09b37efe786df8851c54957683a49f0987a97"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote 1.0.9",
|
||||
"syn",
|
||||
"wasm-bindgen-backend",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-shared"
|
||||
version = "0.2.74"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d7cff876b8f18eed75a66cf49b65e7f967cb354a7aa16003fb55dbfd25b44b4f"
|
||||
|
||||
[[package]]
|
||||
name = "web-sys"
|
||||
version = "0.3.51"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e828417b379f3df7111d3a2a9e5753706cae29c41f7c4029ee9fd77f3e09e582"
|
||||
dependencies = [
|
||||
"js-sys",
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wild"
|
||||
version = "2.0.4"
|
||||
|
||||
+2
-1
@@ -325,7 +325,8 @@ who = { optional=true, version="0.0.6", package="uu_who", path="src/uu/who"
|
||||
whoami = { optional=true, version="0.0.6", package="uu_whoami", path="src/uu/whoami" }
|
||||
yes = { optional=true, version="0.0.6", package="uu_yes", path="src/uu/yes" }
|
||||
|
||||
factor_benches = { optional = true, version = "0.0.0", package = "uu_factor_benches", path = "tests/benches/factor" }
|
||||
# this breaks clippy linting with: "tests/by-util/test_factor_benches.rs: No such file or directory (os error 2)"
|
||||
# factor_benches = { optional = true, version = "0.0.0", package = "uu_factor_benches", path = "tests/benches/factor" }
|
||||
|
||||
#
|
||||
# * pinned transitive dependencies
|
||||
|
||||
@@ -21,7 +21,7 @@ if changes are not reflected in the report then run `cargo clean` and run the a
|
||||
|
||||
### Using Stable Rust
|
||||
|
||||
If you are using stable version of Rust that doesn't enable code coverage instrumentation by default
|
||||
If you are using stable version of Rust that doesn't enable code coverage instrumentation by default
|
||||
then add `-Z-Zinstrument-coverage` flag to `RUSTFLAGS` env variable specified above.
|
||||
|
||||
|
||||
@@ -36,3 +36,7 @@ To use the provided hook:
|
||||
2. Run `pre-commit install` while in the repository directory
|
||||
|
||||
Your git commits will then automatically be checked. If a check fails, an error message will explain why, and your commit will be canceled. You can then make the suggested changes, and run `git commit ...` again.
|
||||
|
||||
### Using Clippy
|
||||
|
||||
The `msrv` key in the clippy configuration file `clippy.toml` is used to disable lints pertaining to newer features by specifying the minimum supported Rust version (MSRV). However, this key is only supported on `nightly`. To invoke clippy without errors, use `cargo +nightly clippy`. In order to also check tests and non-default crate features, use `cargo +nightly clippy --all-targets --all-features`.
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
msrv = "1.43.1"
|
||||
@@ -136,7 +136,8 @@ fn basename(fullname: &str, suffix: &str) -> String {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::manual_strip)] // can be replaced with strip_suffix once the minimum rust version is 1.45
|
||||
// can be replaced with strip_suffix once MSRV is 1.45
|
||||
#[allow(clippy::manual_strip)]
|
||||
fn strip_suffix(name: &str, suffix: &str) -> String {
|
||||
if name == suffix {
|
||||
return name.to_owned();
|
||||
|
||||
+4
-4
@@ -669,8 +669,8 @@ impl Options {
|
||||
}
|
||||
},
|
||||
backup: backup_mode,
|
||||
backup_suffix: backup_suffix,
|
||||
overwrite: overwrite,
|
||||
backup_suffix,
|
||||
overwrite,
|
||||
no_target_dir,
|
||||
preserve_attributes,
|
||||
recursive,
|
||||
@@ -1089,7 +1089,7 @@ fn copy_attribute(source: &Path, dest: &Path, attribute: &Attribute) -> CopyResu
|
||||
}
|
||||
|
||||
#[cfg(not(windows))]
|
||||
#[allow(clippy::unnecessary_wraps)] // needed for windows version
|
||||
#[allow(clippy::unnecessary_unwrap)] // needed for windows version
|
||||
fn symlink_file(source: &Path, dest: &Path, context: &str) -> CopyResult<()> {
|
||||
match std::os::unix::fs::symlink(source, dest).context(context) {
|
||||
Ok(_) => Ok(()),
|
||||
@@ -1108,7 +1108,7 @@ fn context_for(src: &Path, dest: &Path) -> String {
|
||||
|
||||
/// Implements a simple backup copy for the destination file.
|
||||
/// TODO: for the backup, should this function be replaced by `copy_file(...)`?
|
||||
fn backup_dest(dest: &Path, backup_path: &PathBuf) -> CopyResult<PathBuf> {
|
||||
fn backup_dest(dest: &Path, backup_path: &Path) -> CopyResult<PathBuf> {
|
||||
fs::copy(dest, &backup_path)?;
|
||||
Ok(backup_path.into())
|
||||
}
|
||||
|
||||
@@ -124,12 +124,7 @@ where
|
||||
// split the file based on patterns
|
||||
for pattern in patterns.into_iter() {
|
||||
let pattern_as_str = pattern.to_string();
|
||||
#[allow(clippy::match_like_matches_macro)]
|
||||
let is_skip = if let patterns::Pattern::SkipToMatch(_, _, _) = pattern {
|
||||
true
|
||||
} else {
|
||||
false
|
||||
};
|
||||
let is_skip = matches!(pattern, patterns::Pattern::SkipToMatch(_, _, _));
|
||||
match pattern {
|
||||
patterns::Pattern::UpToLine(n, ex) => {
|
||||
let mut up_to_line = n;
|
||||
@@ -488,10 +483,11 @@ where
|
||||
/// Shrink the buffer so that its length is equal to the set size, returning an iterator for
|
||||
/// the elements that were too much.
|
||||
fn shrink_buffer_to_size(&mut self) -> impl Iterator<Item = String> + '_ {
|
||||
let mut shrink_offset = 0;
|
||||
if self.buffer.len() > self.size {
|
||||
shrink_offset = self.buffer.len() - self.size;
|
||||
}
|
||||
let shrink_offset = if self.buffer.len() > self.size {
|
||||
self.buffer.len() - self.size
|
||||
} else {
|
||||
0
|
||||
};
|
||||
self.buffer
|
||||
.drain(..shrink_offset)
|
||||
.map(|(_, line)| line.unwrap())
|
||||
|
||||
@@ -16,6 +16,8 @@ path = "src/expr.rs"
|
||||
|
||||
[dependencies]
|
||||
libc = "0.2.42"
|
||||
num-bigint = "0.4.0"
|
||||
num-traits = "0.2.14"
|
||||
onig = "~4.3.2"
|
||||
uucore = { version=">=0.0.8", package="uucore", path="../../uucore" }
|
||||
uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" }
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
|
||||
// spell-checker:ignore (ToDO) binop binops ints paren prec
|
||||
|
||||
use num_bigint::BigInt;
|
||||
use num_traits::{One, Zero};
|
||||
use onig::{Regex, RegexOptions, Syntax};
|
||||
|
||||
use crate::tokens::Token;
|
||||
@@ -39,20 +41,17 @@ impl AstNode {
|
||||
for _ in 0..depth {
|
||||
print!("\t",);
|
||||
}
|
||||
match *self {
|
||||
AstNode::Leaf {
|
||||
ref token_idx,
|
||||
ref value,
|
||||
} => println!(
|
||||
match self {
|
||||
AstNode::Leaf { token_idx, value } => println!(
|
||||
"Leaf( {} ) at #{} ( evaluate -> {:?} )",
|
||||
value,
|
||||
token_idx,
|
||||
self.evaluate()
|
||||
),
|
||||
AstNode::Node {
|
||||
ref token_idx,
|
||||
ref op_type,
|
||||
ref operands,
|
||||
token_idx,
|
||||
op_type,
|
||||
operands,
|
||||
} => {
|
||||
println!(
|
||||
"Node( {} ) at #{} (evaluate -> {:?})",
|
||||
@@ -81,36 +80,33 @@ impl AstNode {
|
||||
})
|
||||
}
|
||||
pub fn evaluate(&self) -> Result<String, String> {
|
||||
match *self {
|
||||
AstNode::Leaf { ref value, .. } => Ok(value.clone()),
|
||||
AstNode::Node { ref op_type, .. } => match self.operand_values() {
|
||||
match self {
|
||||
AstNode::Leaf { value, .. } => Ok(value.clone()),
|
||||
AstNode::Node { op_type, .. } => match self.operand_values() {
|
||||
Err(reason) => Err(reason),
|
||||
Ok(operand_values) => match op_type.as_ref() {
|
||||
"+" => infix_operator_two_ints(
|
||||
|a: i64, b: i64| checked_binop(|| a.checked_add(b), "+"),
|
||||
&operand_values,
|
||||
),
|
||||
"-" => infix_operator_two_ints(
|
||||
|a: i64, b: i64| checked_binop(|| a.checked_sub(b), "-"),
|
||||
&operand_values,
|
||||
),
|
||||
"*" => infix_operator_two_ints(
|
||||
|a: i64, b: i64| checked_binop(|| a.checked_mul(b), "*"),
|
||||
&operand_values,
|
||||
),
|
||||
"+" => {
|
||||
infix_operator_two_ints(|a: BigInt, b: BigInt| Ok(a + b), &operand_values)
|
||||
}
|
||||
"-" => {
|
||||
infix_operator_two_ints(|a: BigInt, b: BigInt| Ok(a - b), &operand_values)
|
||||
}
|
||||
"*" => {
|
||||
infix_operator_two_ints(|a: BigInt, b: BigInt| Ok(a * b), &operand_values)
|
||||
}
|
||||
"/" => infix_operator_two_ints(
|
||||
|a: i64, b: i64| {
|
||||
if b == 0 {
|
||||
|a: BigInt, b: BigInt| {
|
||||
if b.is_zero() {
|
||||
Err("division by zero".to_owned())
|
||||
} else {
|
||||
checked_binop(|| a.checked_div(b), "/")
|
||||
Ok(a / b)
|
||||
}
|
||||
},
|
||||
&operand_values,
|
||||
),
|
||||
"%" => infix_operator_two_ints(
|
||||
|a: i64, b: i64| {
|
||||
if b == 0 {
|
||||
|a: BigInt, b: BigInt| {
|
||||
if b.is_zero() {
|
||||
Err("division by zero".to_owned())
|
||||
} else {
|
||||
Ok(a % b)
|
||||
@@ -119,32 +115,32 @@ impl AstNode {
|
||||
&operand_values,
|
||||
),
|
||||
"=" => infix_operator_two_ints_or_two_strings(
|
||||
|a: i64, b: i64| Ok(bool_as_int(a == b)),
|
||||
|a: BigInt, b: BigInt| Ok(bool_as_int(a == b)),
|
||||
|a: &String, b: &String| Ok(bool_as_string(a == b)),
|
||||
&operand_values,
|
||||
),
|
||||
"!=" => infix_operator_two_ints_or_two_strings(
|
||||
|a: i64, b: i64| Ok(bool_as_int(a != b)),
|
||||
|a: BigInt, b: BigInt| Ok(bool_as_int(a != b)),
|
||||
|a: &String, b: &String| Ok(bool_as_string(a != b)),
|
||||
&operand_values,
|
||||
),
|
||||
"<" => infix_operator_two_ints_or_two_strings(
|
||||
|a: i64, b: i64| Ok(bool_as_int(a < b)),
|
||||
|a: BigInt, b: BigInt| Ok(bool_as_int(a < b)),
|
||||
|a: &String, b: &String| Ok(bool_as_string(a < b)),
|
||||
&operand_values,
|
||||
),
|
||||
">" => infix_operator_two_ints_or_two_strings(
|
||||
|a: i64, b: i64| Ok(bool_as_int(a > b)),
|
||||
|a: BigInt, b: BigInt| Ok(bool_as_int(a > b)),
|
||||
|a: &String, b: &String| Ok(bool_as_string(a > b)),
|
||||
&operand_values,
|
||||
),
|
||||
"<=" => infix_operator_two_ints_or_two_strings(
|
||||
|a: i64, b: i64| Ok(bool_as_int(a <= b)),
|
||||
|a: BigInt, b: BigInt| Ok(bool_as_int(a <= b)),
|
||||
|a: &String, b: &String| Ok(bool_as_string(a <= b)),
|
||||
&operand_values,
|
||||
),
|
||||
">=" => infix_operator_two_ints_or_two_strings(
|
||||
|a: i64, b: i64| Ok(bool_as_int(a >= b)),
|
||||
|a: BigInt, b: BigInt| Ok(bool_as_int(a >= b)),
|
||||
|a: &String, b: &String| Ok(bool_as_string(a >= b)),
|
||||
&operand_values,
|
||||
),
|
||||
@@ -161,7 +157,7 @@ impl AstNode {
|
||||
}
|
||||
}
|
||||
pub fn operand_values(&self) -> Result<Vec<String>, String> {
|
||||
if let AstNode::Node { ref operands, .. } = *self {
|
||||
if let AstNode::Node { operands, .. } = self {
|
||||
let mut out = Vec::with_capacity(operands.len());
|
||||
for operand in operands {
|
||||
match operand.evaluate() {
|
||||
@@ -217,9 +213,9 @@ fn maybe_dump_ast(result: &Result<Box<AstNode>, String>) {
|
||||
if let Ok(debug_var) = env::var("EXPR_DEBUG_AST") {
|
||||
if debug_var == "1" {
|
||||
println!("EXPR_DEBUG_AST");
|
||||
match *result {
|
||||
Ok(ref ast) => ast.debug_dump(),
|
||||
Err(ref reason) => println!("\terr: {:?}", reason),
|
||||
match result {
|
||||
Ok(ast) => ast.debug_dump(),
|
||||
Err(reason) => println!("\terr: {:?}", reason),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -304,7 +300,7 @@ fn push_token_to_either_stack(
|
||||
out_stack: &mut TokenStack,
|
||||
op_stack: &mut TokenStack,
|
||||
) -> Result<(), String> {
|
||||
let result = match *token {
|
||||
let result = match token {
|
||||
Token::Value { .. } => {
|
||||
out_stack.push((token_idx, token.clone()));
|
||||
Ok(())
|
||||
@@ -420,24 +416,14 @@ fn move_till_match_paren(
|
||||
}
|
||||
}
|
||||
|
||||
fn checked_binop<F: Fn() -> Option<T>, T>(cb: F, op: &str) -> Result<T, String> {
|
||||
match cb() {
|
||||
Some(v) => Ok(v),
|
||||
None => Err(format!("{}: Numerical result out of range", op)),
|
||||
}
|
||||
}
|
||||
|
||||
fn infix_operator_two_ints<F>(f: F, values: &[String]) -> Result<String, String>
|
||||
where
|
||||
F: Fn(i64, i64) -> Result<i64, String>,
|
||||
F: Fn(BigInt, BigInt) -> Result<BigInt, String>,
|
||||
{
|
||||
assert!(values.len() == 2);
|
||||
if let Ok(left) = values[0].parse::<i64>() {
|
||||
if let Ok(right) = values[1].parse::<i64>() {
|
||||
return match f(left, right) {
|
||||
Ok(result) => Ok(result.to_string()),
|
||||
Err(reason) => Err(reason),
|
||||
};
|
||||
if let Ok(left) = values[0].parse::<BigInt>() {
|
||||
if let Ok(right) = values[1].parse::<BigInt>() {
|
||||
return f(left, right).map(|big_int| big_int.to_string());
|
||||
}
|
||||
}
|
||||
Err("Expected an integer operand".to_string())
|
||||
@@ -449,13 +435,14 @@ fn infix_operator_two_ints_or_two_strings<FI, FS>(
|
||||
values: &[String],
|
||||
) -> Result<String, String>
|
||||
where
|
||||
FI: Fn(i64, i64) -> Result<i64, String>,
|
||||
FI: Fn(BigInt, BigInt) -> Result<u8, String>,
|
||||
FS: Fn(&String, &String) -> Result<String, String>,
|
||||
{
|
||||
assert!(values.len() == 2);
|
||||
if let (Some(a_int), Some(b_int)) =
|
||||
(values[0].parse::<i64>().ok(), values[1].parse::<i64>().ok())
|
||||
{
|
||||
if let (Some(a_int), Some(b_int)) = (
|
||||
values[0].parse::<BigInt>().ok(),
|
||||
values[1].parse::<BigInt>().ok(),
|
||||
) {
|
||||
match fi(a_int, b_int) {
|
||||
Ok(result) => Ok(result.to_string()),
|
||||
Err(reason) => Err(reason),
|
||||
@@ -541,7 +528,7 @@ fn prefix_operator_substr(values: &[String]) -> String {
|
||||
subj.chars().skip(idx).take(len).collect()
|
||||
}
|
||||
|
||||
fn bool_as_int(b: bool) -> i64 {
|
||||
fn bool_as_int(b: bool) -> u8 {
|
||||
if b {
|
||||
1
|
||||
} else {
|
||||
@@ -559,8 +546,8 @@ fn value_as_bool(s: &str) -> bool {
|
||||
if s.is_empty() {
|
||||
return false;
|
||||
}
|
||||
match s.parse::<i64>() {
|
||||
Ok(n) => n != 0,
|
||||
match s.parse::<BigInt>() {
|
||||
Ok(n) => n.is_one(),
|
||||
Err(_) => true,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
|
||||
// spell-checker:ignore (ToDO) paren
|
||||
|
||||
use num_bigint::BigInt;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum Token {
|
||||
Value {
|
||||
@@ -51,24 +53,19 @@ impl Token {
|
||||
}
|
||||
|
||||
fn is_infix_plus(&self) -> bool {
|
||||
match *self {
|
||||
Token::InfixOp { ref value, .. } => value == "+",
|
||||
match self {
|
||||
Token::InfixOp { value, .. } => value == "+",
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
fn is_a_number(&self) -> bool {
|
||||
match *self {
|
||||
Token::Value { ref value, .. } => value.parse::<i64>().is_ok(),
|
||||
match self {
|
||||
Token::Value { value, .. } => value.parse::<BigInt>().is_ok(),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
fn is_a_close_paren(&self) -> bool {
|
||||
#[allow(clippy::match_like_matches_macro)]
|
||||
// `matches!(...)` macro not stabilized until rust v1.42
|
||||
match *self {
|
||||
Token::ParClose => true,
|
||||
_ => false,
|
||||
}
|
||||
matches!(*self, Token::ParClose)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,7 +144,7 @@ fn push_token_if_not_escaped(acc: &mut Vec<(usize, Token)>, tok_idx: usize, toke
|
||||
// Smells heuristics... :(
|
||||
let prev_is_plus = match acc.last() {
|
||||
None => false,
|
||||
Some(ref t) => t.1.is_infix_plus(),
|
||||
Some(t) => t.1.is_infix_plus(),
|
||||
};
|
||||
let should_use_as_escaped = if prev_is_plus && acc.len() >= 2 {
|
||||
let pre_prev = &acc[acc.len() - 2];
|
||||
|
||||
@@ -21,6 +21,7 @@ rand = { version = "0.7", features = ["small_rng"] }
|
||||
smallvec = { version = "0.6.14, < 1.0" }
|
||||
uucore = { version = ">=0.0.8", package = "uucore", path = "../../uucore" }
|
||||
uucore_procs = { version = ">=0.0.5", package = "uucore_procs", path = "../../uucore_procs" }
|
||||
clap = "2.33"
|
||||
|
||||
[dev-dependencies]
|
||||
paste = "0.1.18"
|
||||
|
||||
@@ -30,7 +30,7 @@ impl Iterator for Sieve {
|
||||
|
||||
#[inline]
|
||||
fn next(&mut self) -> Option<u64> {
|
||||
while let Some(n) = self.inner.next() {
|
||||
for n in &mut self.inner {
|
||||
let mut prime = true;
|
||||
while let Some((next, inc)) = self.filts.peek() {
|
||||
// need to keep checking the min element of the heap
|
||||
|
||||
+20
-16
@@ -13,18 +13,21 @@ use std::error::Error;
|
||||
use std::io::{self, stdin, stdout, BufRead, Write};
|
||||
|
||||
mod factor;
|
||||
use clap::{App, Arg};
|
||||
pub use factor::*;
|
||||
use uucore::InvalidEncodingHandling;
|
||||
|
||||
mod miller_rabin;
|
||||
pub mod numeric;
|
||||
mod rho;
|
||||
pub mod table;
|
||||
|
||||
static SYNTAX: &str = "[OPTION] [NUMBER]...";
|
||||
static SUMMARY: &str = "Print the prime factors of the given number(s).
|
||||
If none are specified, read from standard input.";
|
||||
static LONG_HELP: &str = "";
|
||||
static VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||
static SUMMARY: &str = "Print the prime factors of the given NUMBER(s).
|
||||
If none are specified, read from standard input.";
|
||||
|
||||
mod options {
|
||||
pub static NUMBER: &str = "NUMBER";
|
||||
}
|
||||
|
||||
fn print_factors_str(num_str: &str, w: &mut impl io::Write) -> Result<(), Box<dyn Error>> {
|
||||
num_str
|
||||
@@ -34,14 +37,21 @@ fn print_factors_str(num_str: &str, w: &mut impl io::Write) -> Result<(), Box<dy
|
||||
}
|
||||
|
||||
pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||
let matches = app!(SYNTAX, SUMMARY, LONG_HELP).parse(
|
||||
args.collect_str(InvalidEncodingHandling::Ignore)
|
||||
.accept_any(),
|
||||
);
|
||||
let matches = App::new(executable!())
|
||||
.version(VERSION)
|
||||
.about(SUMMARY)
|
||||
.arg(Arg::with_name(options::NUMBER).multiple(true))
|
||||
.get_matches_from(args);
|
||||
let stdout = stdout();
|
||||
let mut w = io::BufWriter::new(stdout.lock());
|
||||
|
||||
if matches.free.is_empty() {
|
||||
if let Some(values) = matches.values_of(options::NUMBER) {
|
||||
for number in values {
|
||||
if let Err(e) = print_factors_str(number, &mut w) {
|
||||
show_warning!("{}: {}", number, e);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
let stdin = stdin();
|
||||
|
||||
for line in stdin.lock().lines() {
|
||||
@@ -51,12 +61,6 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for number in &matches.free {
|
||||
if let Err(e) = print_factors_str(number, &mut w) {
|
||||
show_warning!("{}: {}", number, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if let Err(e) = w.flush() {
|
||||
|
||||
@@ -264,12 +264,9 @@ impl<'a> ParagraphStream<'a> {
|
||||
return false;
|
||||
}
|
||||
|
||||
#[allow(clippy::match_like_matches_macro)]
|
||||
// `matches!(...)` macro not stabilized until rust v1.42
|
||||
l_slice[..colon_posn].chars().all(|x| match x as usize {
|
||||
y if !(33..=126).contains(&y) => false,
|
||||
_ => true,
|
||||
})
|
||||
l_slice[..colon_posn]
|
||||
.chars()
|
||||
.all(|x| !matches!(x as usize, y if !(33..=126).contains(&y)))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -541,12 +538,7 @@ impl<'a> WordSplit<'a> {
|
||||
}
|
||||
|
||||
fn is_punctuation(c: char) -> bool {
|
||||
#[allow(clippy::match_like_matches_macro)]
|
||||
// `matches!(...)` macro not stabilized until rust v1.42
|
||||
match c {
|
||||
'!' | '.' | '?' => true,
|
||||
_ => false,
|
||||
}
|
||||
matches!(c, '!' | '.' | '?')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -51,14 +51,23 @@ struct Options {
|
||||
}
|
||||
|
||||
fn is_custom_binary(program: &str) -> bool {
|
||||
#[allow(clippy::match_like_matches_macro)]
|
||||
// `matches!(...)` macro not stabilized until rust v1.42
|
||||
match program {
|
||||
"md5sum" | "sha1sum" | "sha224sum" | "sha256sum" | "sha384sum" | "sha512sum"
|
||||
| "sha3sum" | "sha3-224sum" | "sha3-256sum" | "sha3-384sum" | "sha3-512sum"
|
||||
| "shake128sum" | "shake256sum" | "b2sum" => true,
|
||||
_ => false,
|
||||
}
|
||||
matches!(
|
||||
program,
|
||||
"md5sum"
|
||||
| "sha1sum"
|
||||
| "sha224sum"
|
||||
| "sha256sum"
|
||||
| "sha384sum"
|
||||
| "sha512sum"
|
||||
| "sha3sum"
|
||||
| "sha3-224sum"
|
||||
| "sha3-256sum"
|
||||
| "sha3-384sum"
|
||||
| "sha3-512sum"
|
||||
| "shake128sum"
|
||||
| "shake256sum"
|
||||
| "b2sum"
|
||||
)
|
||||
}
|
||||
|
||||
#[allow(clippy::cognitive_complexity)]
|
||||
|
||||
@@ -14,7 +14,7 @@ pub fn parse_obsolete(src: &str) -> Option<Result<impl Iterator<Item = OsString>
|
||||
let mut num_end = 0usize;
|
||||
let mut has_num = false;
|
||||
let mut last_char = 0 as char;
|
||||
while let Some((n, c)) = chars.next() {
|
||||
for (n, c) in &mut chars {
|
||||
if c.is_numeric() {
|
||||
has_num = true;
|
||||
num_end = n;
|
||||
@@ -109,7 +109,7 @@ pub fn parse_num(src: &str) -> Result<(usize, bool), ParseError> {
|
||||
let mut num_end = 0usize;
|
||||
let mut last_char = 0 as char;
|
||||
let mut num_count = 0usize;
|
||||
while let Some((n, c)) = chars.next() {
|
||||
for (n, c) in &mut chars {
|
||||
if c.is_numeric() {
|
||||
num_end = n;
|
||||
num_count += 1;
|
||||
|
||||
@@ -520,6 +520,7 @@ fn copy_file_to_file(file: &Path, target: &Path, b: &Behavior) -> i32 {
|
||||
///
|
||||
/// If the copy system call fails, we print a verbose error and return an empty error value.
|
||||
///
|
||||
#[allow(clippy::cognitive_complexity)]
|
||||
fn copy(from: &Path, to: &Path, b: &Behavior) -> Result<(), ()> {
|
||||
if b.compare && !need_copy(from, to, b) {
|
||||
return Ok(());
|
||||
|
||||
+3
-3
@@ -218,6 +218,7 @@ struct LongFormat {
|
||||
}
|
||||
|
||||
impl Config {
|
||||
#[allow(clippy::cognitive_complexity)]
|
||||
fn from(options: clap::ArgMatches) -> Config {
|
||||
let (mut format, opt) = if let Some(format_) = options.value_of(options::FORMAT) {
|
||||
(
|
||||
@@ -1222,7 +1223,7 @@ fn list(locs: Vec<String>, config: Config) -> i32 {
|
||||
|
||||
sort_entries(&mut dirs, &config);
|
||||
for dir in dirs {
|
||||
if locs.len() > 1 {
|
||||
if locs.len() > 1 || config.recursive {
|
||||
let _ = writeln!(out, "\n{}:", dir.p_buf.display());
|
||||
}
|
||||
enter_directory(&dir, &config, &mut out);
|
||||
@@ -1614,7 +1615,7 @@ fn display_date(metadata: &Metadata, config: &Config) -> String {
|
||||
Some(time) => {
|
||||
//Date is recent if from past 6 months
|
||||
//According to GNU a Gregorian year has 365.2425 * 24 * 60 * 60 == 31556952 seconds on the average.
|
||||
let recent = time + chrono::Duration::seconds(31556952 / 2) > chrono::Local::now();
|
||||
let recent = time + chrono::Duration::seconds(31_556_952 / 2) > chrono::Local::now();
|
||||
|
||||
match config.time_style {
|
||||
TimeStyle::FullIso => time.format("%Y-%m-%d %H:%M:%S.%f %z"),
|
||||
@@ -1696,7 +1697,6 @@ fn file_is_executable(md: &Metadata) -> bool {
|
||||
md.mode() & ((S_IXUSR | S_IXGRP | S_IXOTH) as u32) != 0
|
||||
}
|
||||
|
||||
#[allow(clippy::clippy::collapsible_else_if)]
|
||||
fn classify_file(path: &PathData) -> Option<char> {
|
||||
let file_type = path.file_type()?;
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user