Commit graph

5036 commits

Author SHA1 Message Date
Michael Debertol
d821719c67
expr: support arbitrary precision integers (#2271)
* expr: support arbitrary precision integers

Instead of i64s we now use BigInts for integer operations. This means
that no result or input can be out of range.
The representation of integer flags was changed from i64 to u8 to make
their intention clearer.

* expr: allow big numbers as arguments as well

Also adds some tests

* expr: use num-traits to check bigints for 0 and 1

* expr: remove obsolete refs

match ergonomics made these avoidable.

* formatting

Co-authored-by: Sylvestre Ledru <sylvestre@debian.org>
2021-05-29 23:25:23 +02:00
Sylvestre Ledru
6e1a68ce9a
Merge pull request #2298 from jhscheer/fix_clippy
Major clippy overhaul.
2021-05-29 23:23:26 +02:00
Sylvestre Ledru
61e8b4fe94
Merge pull request #2303 from miDeb/maint-spell-ci
maint: add spell checker to CICD
2021-05-29 22:57:33 +02:00
Michael Debertol
4058caa3e6 maint: add spell checker to CICD 2021-05-29 22:30:02 +02:00
Terts Diepraam
b0bf3e7e0f pr: rustfmt test_pr.rs and utils.rs 2021-05-29 19:34:17 +02:00
Terts Diepraam
bc1870c0a7 Merge branch 'master' into pr 2021-05-29 19:21:31 +02:00
Terts Diepraam
4744b35796 pr: explicit none in match expressions 2021-05-29 19:09:50 +02:00
Terts Diepraam
2e1035b350 pr: static to const 2021-05-29 19:02:42 +02:00
Terts Diepraam
0913a77667 pr: let type inference do its works 2021-05-29 19:01:39 +02:00
Terts Diepraam
12287fcc9c pr: fix clippy lints 2021-05-29 18:44:12 +02:00
Jeffrey Finkelstein
0999b00ff9 truncate: re-organize into one func for each mode
Reorganize the code in `truncate.rs` into three distinct functions
representing the three modes of operation of the `truncate` program. The
three modes are

- `truncate -r RFILE FILE`, which sets the length of `FILE` to match the
  length of `RFILE`,
- `truncate -r RFILE -s NUM FILE`, which sets the length of `FILE`
  relative to the given `RFILE`,
- `truncate -s NUM FILE`, which sets the length of `FILE` either
  absolutely or relative to its curent length.

This organization of the code makes it more concise and easier to
follow.
2021-05-29 15:11:27 +02:00
Jeffrey Finkelstein
5129114ddc truncate: create TruncateMode::to_size() method
Create a method that computes the final target size in bytes for the
file to truncate, given the reference file size and the parameter to the
`TruncateMode`.
2021-05-29 15:11:27 +02:00
Jeffrey Finkelstein
005bc259da truncate: add parse_mode_and_size() helper func
Add a helper function to contain the code for parsing the size and the
modifier symbol, if any. This commit also changes the `TruncateMode`
enum so that the parameter for each "mode" is stored along with the
enumeration value. This is because the parameter has a different meaning
in each mode.
2021-05-29 15:11:27 +02:00
Jeffrey Finkelstein
b898e54d7a truncate: remove read permissions from OpenOptions
Remove "read" permissions from the `OpenOptions` when opening a new file
just to truncate it. We will never read from the file, only write to
it. (Specifically, we will only call `File::set_len()`.)
2021-05-29 15:11:27 +02:00
Jeffrey Finkelstein
4e73b919e9 truncate: add test for -r and -s options together
Add a test for when the reference file is not found and both `-r` and
`-s` options are given on the command-line.
2021-05-29 15:11:27 +02:00
Gilad Naaman
17b0939dee Moved factor to use clap
Issue: https://github.com/uutils/coreutils/issues/2121
2021-05-29 15:11:27 +02:00
Jan Scheer
e4aa8ee159 users: fix long_help text and clippy warning 2021-05-29 15:11:27 +02:00
Jan Scheer
3aeccfd802 fix a lot of clippy warnings 2021-05-29 15:11:22 +02:00
Terts Diepraam
d94ee87d15 pr: move options into mod 2021-05-29 14:42:24 +02:00
Terts Diepraam
0487360507 pr: make tests compile again 2021-05-29 14:30:30 +02:00
Jan Scheer
fb812ff9d0 Cargo.toml: remove factor_benches in order to be able to run clippy
linting for all targets
2021-05-29 14:29:46 +02:00
Jan Scheer
52ea9c4a48 CI: set MSRV and "--target" for clippy
* add "clippy.toml" in order to set MSRV for clippy linting
    this works only if clippy is invoked with "+nightly"
* add "--target" to clippy in order to also lint tests
2021-05-29 14:21:32 +02:00
Terts Diepraam
762da0bd37 more: comment out unimplemented arguments 2021-05-29 12:51:47 +02:00
Terts Diepraam
9d17c1fddf more: add todo for unicode width 2021-05-29 12:45:12 +02:00
Terts Diepraam
40ee9023e8 more: simplify main loop 2021-05-29 12:42:46 +02:00
Terts Diepraam
101e55702c more: simplify and fix logic for multiple files 2021-05-29 12:35:03 +02:00
Sylvestre Ledru
3d42d41a72
Merge pull request #2247 from jfinkels/truncate-split-three-functions
truncate: re-organize truncate() into one function for each mode of operation
2021-05-29 10:31:02 +02:00
Sylvestre Ledru
0746b3e1e6
Merge pull request #2292 from Gilnaa/2121-factor-clap
Moved factor to use clap
2021-05-29 10:30:06 +02:00
Sylvestre Ledru
c2544a6f37
Merge pull request #2299 from jhscheer/users
users: fix long_help text and clippy warning
2021-05-29 09:26:04 +02:00
Jan Scheer
714661774b users: fix long_help text and clippy warning 2021-05-29 02:34:43 +02:00
Jan Scheer
a2947f6897 fix clippy warning 2021-05-29 00:46:25 +02:00
Michael Debertol
bb268d1500
sort: crash when failing to open an input file (#2265)
* sort: crash when failing to open an input file

Instead of ignoring files we fail to open, crash.
The error message does not exactly match gnu, but that would require
more effort.

* use split_whitespace instead of a manual implementation

* fix expected error on windows

* sort: update expected error message
2021-05-28 22:39:33 +02:00
Michael Debertol
e9656a6c32
sort: make GNU test sort-debug-keys pass (#2269)
* sort: disable support for thousand separators

In order to be compatible with GNU, we have to disable thousands
separators. GNU does not enable them for the C locale, either.

Once we add support for locales we can add this feature back.

* sort: delete unused fixtures

* sort: compare -0 and 0 equal

I must have misunderstood this when implementing, but GNU considers
-0, 0, and invalid numbers to be equal.

* sort: strip blanks before applying the char index

* sort: don't crash when key start is after key end

* sort: add "no match" for months at the first non-whitespace char

We should put the "^ no match for key" indicator at the first
non-whitespace character of a field.

* sort: improve support for e notation

* sort: use maches! macros
2021-05-28 22:38:29 +02:00
Sylvestre Ledru
9442f26fdb
Merge pull request #2283 from Mikadore/master
Closing #1916 - Concluding the test refactor
2021-05-28 22:36:47 +02:00
Sylvestre Ledru
a2143dcfbf
Merge pull request #2293 from miDeb/maint-minrustv
maint: adapt code to new MinRustV
2021-05-28 21:48:51 +02:00
Terts Diepraam
1c2540a613 Add atty to dev-deps for more tests 2021-05-28 21:07:38 +02:00
Jack O'Connor
80b9bfdd18 switch from blake2-rfc to blake2b_simd 2021-05-28 14:08:46 -04:00
Sylvestre Ledru
fe42808e9b
Merge branch 'master' into implement-more 2021-05-28 19:49:48 +02:00
Terts Diepraam
0a2f74fd8e
More: update crossterm dependency 2021-05-28 19:43:03 +02:00
Michael Debertol
b5cbd506bc maint: remove trailing commas from matches
Trailing commas are only supported starting from 1.48.
2021-05-28 18:58:06 +02:00
Gilad Naaman
6a9ffee548 Moved factor to use clap
Issue: https://github.com/uutils/coreutils/issues/2121
2021-05-28 19:48:28 +03:00
Terts Diepraam
c7930a63f7
Merge pull request #2285 from blesson3/cp-backup-arg-fix
cp: fix regressed issue with `--backup` and `-b`
2021-05-28 18:44:09 +02:00
Michael Debertol
a9e0208ee2 maint: remove obsolete attributes 2021-05-28 18:03:47 +02:00
Michael Debertol
59a42f1254 maint: format recent changes 2021-05-28 18:03:47 +02:00
Michael Debertol
263b122540 maint: use the matches! macro when possible 2021-05-28 18:03:37 +02:00
Sylvestre Ledru
222bd81190
Merge pull request #2291 from tertsdiepraam/remove-tempdir
Replace `tempdir` with `tempfile`
2021-05-28 10:45:19 +02:00
Sylvestre Ledru
80e972c168
Merge pull request #2290 from tertsdiepraam/msrv-1.43
Bump MSRV to 1.43.1
2021-05-28 10:39:46 +02:00
Terts Diepraam
835a17d79f mktemp: use tempfile instead of custom tempdir 2021-05-27 22:48:10 +02:00
Terts Diepraam
ebe6341ae3 chore: replace tempdir with tempfile 2021-05-27 22:47:03 +02:00
Terts Diepraam
825476f573 Update tempfile 2021-05-27 20:25:24 +02:00