Commit graph

468 commits

Author SHA1 Message Date
Sylvestre Ledru
9712ecb4d5
Merge pull request #2340 from deantvv/more-unicode
more: fix unicode bug
2021-06-04 19:51:32 +02:00
Dean Li
acd290d11f
more: fix unicode bug for breakline
- Use `unicode_segmentation` and `unicode_width` to determine proper `break_line` position.
- Keep track of total_width as suggested by @tertsdiepraam.
- Add unittest for ZWJ unicode case

Related to #2319.
2021-06-04 22:06:27 +08:00
Michael Debertol
e5c4681e04 tests: add the ability to set resource limits 2021-06-02 19:21:12 +02:00
Mitchell Mebane
efe1850087 dircolors: replace getopts with clap
Port argument parsing from getopts to clap.

The only difference I have observed is that clap auto-generates -h and
-V short options for help and version, and there is no way (in clap 2.x)
to disable them.
2021-06-01 19:22:08 -05:00
Sylvestre Ledru
8618771f2e
Merge pull request #2322 from miDeb/seq/improvements
seq: improve compatibility
2021-05-31 23:09:13 +02:00
Michael Debertol
6ccc305513 seq: implement integer sequences
If we notice that we can represent all arguments as BigInts, take a
different code path. Just like GNU seq this means we can print an
infinite amount of numbers in this case.
2021-05-31 21:20:12 +02:00
Dean Li
9d8e7b9acb
Fix touch parse date error
Now it can parse `touch -d 2000-01-23 file` and add test for parse date
error.

Related to #2311
2021-05-31 22:04:03 +08:00
Terts Diepraam
7690dc018f Merge branch 'master' into pr 2021-05-31 15:23:06 +02:00
Terts Diepraam
77a0a077b8 pr: update dependencies 2021-05-31 14:48:12 +02:00
Sylvestre Ledru
8c5dcd0765
Merge branch 'master' into implement-more 2021-05-31 10:17:15 +02:00
Sylvestre Ledru
13b2a4afd3
Merge branch 'master' into blake2b_simd 2021-05-30 09:29:40 +02:00
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
Terts Diepraam
bc1870c0a7 Merge branch 'master' into pr 2021-05-29 19:21:31 +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
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
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
Gilad Naaman
6a9ffee548 Moved factor to use clap
Issue: https://github.com/uutils/coreutils/issues/2121
2021-05-28 19:48:28 +03:00
Sylvestre Ledru
222bd81190
Merge pull request #2291 from tertsdiepraam/remove-tempdir
Replace `tempdir` with `tempfile`
2021-05-28 10:45:19 +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
Syukron Rifail M
eda72b5208 du: replace getopts with clap 2021-05-26 11:23:05 +07:00
Sylvestre Ledru
66cfdb8644
Merge pull request #2143 from nbraud/factor/faster/table
factor::table: Implement a batched version w/ improved performance
2021-05-22 17:18:07 +02:00
Sylvestre Ledru
628684af4f refresh cargo.lock with recent updates 2021-05-22 12:20:13 +02:00
Arijit Dey
1596c65dfd
Downgrade crossterm version 2021-05-18 22:29:59 +05:30
nicoo
9afed1f25f Update Cargo.lock
Adding array-init v2.0.0
Updating cast v0.2.5 -> v0.2.6
  Adding pest v2.1.3
Updating rustc_version v0.2.3 -> v0.3.3
  Adding semver v0.11.0
  Adding semver-parser v0.10.2
Updating serde v1.0.125 -> v1.0.126
Updating serde_derive v1.0.125 -> v1.0.126
  Adding ucd-trie v0.1.3
  Adding uu_factor_benches v0.0.0 (#tests/benches/factor)
2021-05-17 19:45:02 +02:00
Michael Debertol
fcd48813e0 sort: read files as chunks, off-thread
Instead of using a BufReader and reading each line separately,
allocating a String for each one, we read to a chunk. Lines are
references to this chunk. This makes the allocator's job much easier
and yields performance improvements.

Chunks are read on a separate thread to further improve performance.
2021-05-16 21:13:37 +02:00
Arijit Dey
22ba21d8ab
Fix bug with terminal getting weird 2021-05-16 22:26:54 +05:30
Jan Scheer
a4fc2b5106 who: fix --lookup
This closes #2181.

`who --lookup` is failing with a runtime panic (double free).
Since `crate::dns-lookup` already includes a safe wrapper for `getaddrinfo`
I used this crate instead of further debugging the existing code in
utmpx::canon_host().

* It was neccessary to remove the version constraint for libc in uucore.
2021-05-13 22:16:15 +02:00
Sylvestre Ledru
019f1b1a88
Merge pull request #2203 from sylvestre/travis
Remove travis CI
2021-05-11 20:01:59 +02:00
Sylvestre Ledru
b9d44facb9 refresh cargo.lock with recent updates 2021-05-11 10:27:13 +02:00
Sylvestre Ledru
881bbf512e refresh cargo.lock with recent updates 2021-05-10 08:59:45 +02:00
Gilad Naaman
8747800697 Switched 'arch' to use clap instead of getopts 2021-05-09 21:53:03 +03:00
Michael Debertol
c38373946a sort: optimize the Line struct 2021-05-07 21:51:25 +02:00
Sylvestre Ledru
704c6865b1 refresh cargo.lock with recent updates 2021-05-07 10:35:50 +02:00
Idan Attias
b24b9d501b logname: replace getopts with clap 2021-05-06 14:19:47 +02:00
Sylvestre Ledru
9f9735694d refresh cargo.lock with recent updates 2021-05-06 08:22:23 +02:00
Anup Mahindre
7d2b051866
Implement Total size feature (#2170)
* ls: Implement total size feature

- Implement total size reporting that was missing
- Fix minor formatting / readability nits

* tests: Add tests for ls total sizes feature

* ls: Fix MSRV build errors due to unsupported attributes for if blocks

* ls: Add windows support for total sizes feature

- Add windows support (defaults to file size as block sizes related
infromation is not avialable on windows)
- Renamed some functions
2021-05-05 23:03:25 +02:00
rethab
231bb7be93
Migrate mknod to clap, closes #2051 (#2056)
* mknod: add tests for fifo

* mknod: add test for character device
2021-05-05 22:59:40 +02:00
Sylvestre Ledru
f83316f36e
Merge pull request #2156 from miDeb/sort-no-json-extsort
sort: don't rely on serde-json for extsort
2021-05-05 22:33:18 +02:00
Sylvestre Ledru
482e340e11
Merge branch 'master' into implement-more 2021-05-04 13:35:38 +02:00
Sylvestre Ledru
6dff9f00a3 refresh cargo.lock with recent updates 2021-05-04 10:02:40 +02:00
Sylvestre Ledru
6c04d0d21e
Merge pull request #2155 from nthery/kill_clap
kill: migrate to clap
2021-05-02 18:45:29 +02:00
Michael Debertol
e99f157e6a Merge branch 'master' of https://github.com/uutils/coreutils into sort-no-json-extsort 2021-05-02 18:08:15 +02:00
Nicolas Thery
1dccbfd21e kill: migrate to clap
Fixes #2122.
2021-05-02 12:31:41 +02:00
Sylvestre Ledru
d0512618d5 refresh cargo.lock with recent updates 2021-05-02 09:43:32 +02:00
Sylvestre Ledru
2d0f4daf5b
Merge pull request #2152 from deantvv/link-clap
link: replace getopts with clap
2021-05-02 09:33:11 +02:00
Dean Li
f5c7d9bd80 link: replace getopts with clap 2021-05-02 10:40:48 +08:00
Ricardo Iglesias
f307de22d0 base64: Refactor argument parsing
Moved most of the argument parsing logic to `base32/base_common.rs` to
allow for significant code reuse.
2021-05-01 11:36:46 -07:00
Ricardo Iglesias
05b20c32a9 base64: Moved argument parsing to clap.
Moved argument parsing to clap and added tests to cover using "-" as
stdin, passing in too many file arguments, and updated the "wrap" error
message in the tests.
2021-05-01 11:36:46 -07:00
Sylvestre Ledru
5567f32f58 refresh cargo.lock with recent updates 2021-05-01 17:49:45 +02:00
Michael Debertol
be0c924c95 Merge branch 'master' of https://github.com/uutils/coreutils into sort-no-json-extsort 2021-05-01 17:29:03 +02:00
Michael Debertol
01d178cf17 sort: don't rely on serde-json for extsort
It is much faster to just write the lines to disk, separated by \n
(or \0 if zero-terminated is enabled), instead of serializing to json.

external_sort now knows of the Line struct instead of interacting with
it using the ExternallySortable trait. Similarly, it now uses the
crash_if_err! macro to handle errors, instead of bubbling them up.

Some functions were changed from taking &[Line] as the input to taking
an Iterator<Item = Line>. This removes the need to collect to a Vec
when not necessary.
2021-05-01 17:20:56 +02:00
Sylvestre Ledru
6693018631 refresh cargo.lock with recent updates 2021-05-01 13:12:00 +02:00
Arijit Dey
2593b3f2e1
Rewrite the cli usage function
Add crossterm as dependency

Complete the paging portion

Fixed tests

cp: extract linux COW logic into function

cp: add --reflink support for macOS

Fixes #1773

Fix error in Cargo.lock

Quit automatically if not much output is left

Remove unnecessary redox and windows specific code

Handle line wrapping

Put everything according to uutils coding standards

Add support for multiple files

Fix failing test

Use the args argument to get cli arguments

Fix bug where text is repeated multiple times during printing

Add a little prompt

Add a top file prompt for multiple files

Change println in loops to stdout.write and setup terminal only once

Fix bug where all lines were printed in a single row

Remove useless file and fix failing test

Fix another test
2021-04-29 20:23:35 +05:30
nicoo
b89978a4c9
factor: Add annotations for coz, the causal profiler (#2142)
* factor: Add annotations for coz, the causal profiler

* Update Cargo.lock

Generated with `nix-shell -p rustup --run 'cargo +1.40.0 update'`
2021-04-29 15:56:56 +02:00
Sylvestre Ledru
1ca6edb560 fix the min rust version 2021-04-28 20:55:08 +02:00
Rein F
a60fd07bc3
ls: improvements on time handling (#1986)
* ls: added creation time

* ls: Added most time features

Missing support for posix-,Format+, translating via locales. Also required more tests

* ls: rustfmt

* ls: Additional changes and fixes

Fixed the argument order, fixed a wrong iso format.

* ls: additional tests for styles

* ls: perfected arg parsing on time styles

* fix birthime test

* ls: Use 'stdout_str' in new tests

* ls: Disabled birthtime test for windows

* ls: removed indoc as a dependency

* ls: birthime test, sync first created file

* ls: birthime test, add comment explaining sync

* Removed ruby testfile birth_test.rb

This accidentally got commited in a merge
2021-04-28 20:54:27 +02:00
Sylvestre Ledru
167520067c
Merge pull request #2111 from cbjadwani/cut_optimizations
cut: optimizations
2021-04-28 20:40:28 +02:00
Sylvestre Ledru
a37e3181a2
Merge pull request #2130 from electricboogie/master
sort: implement --buffer-size and --temporary-directory (external sort)
2021-04-28 09:21:14 +02:00
Sylvestre Ledru
30cf6ec235
Merge pull request #2131 from ricardoaiglesias/base32-clap
Base32 clap
2021-04-27 09:20:45 +02:00
Terts Diepraam
c69b72c840 ls: forgot to commit Cargo.{toml, lock} 2021-04-26 15:04:55 +02:00
Ricardo Iglesias
5578ba6eed base32: move from getopts to clap
Note, I needed to change the error messages in one of the tests because
getopt and clap have different error messages when not providing a
default value
2021-04-25 22:24:55 -07:00
electricboogie
094d9a9e47 Fix bug in human_numeric convert 2021-04-25 12:27:11 -05:00
electricboogie
cb0c667da5 Ran Rustfmt 2021-04-25 10:12:03 -05:00
electricboogie
4c395146dd Merge branch 'master' of https://github.com/uutils/coreutils 2021-04-25 10:11:27 -05:00
electricboogie
2b8a6e98ee Working ExtSort 2021-04-25 00:20:56 -05:00
Chirag Jadwani
2c1459cbfc cut: optimizations
* Use buffered stdout to reduce write sys calls.

This simple change yielded the biggest performace gain.

* Use `for_byte_record_with_terminator` from the `bstr` crate.

This is to minimize the per line copying needed by
`BufReader::read_until`. The `cut_fields` and `cut_fields_delimiter`
functions used `read_until` to iterate over lines. That required copying
each input line to the line buffer. With
`for_byte_record_with_terminator` copying is minimized as it calls our
closure with a reference to BufReader's buffer most of the time.  It
needs to copy (internally) only to process any incomplete lines at the
end of the buffer.

* Re-write `Searcher` to use `memchr`.

Switch from the naive implementation to one that uses `memchr`.

* Rewrite `cut_bytes` almost entirely.

This was already well optimized. The performance gain in this case is
not from avoiding copying. In fact, it needed zero copying whereas new
implementation introduces some copying similar to `cut_fields` described
above. But the occassional copying cost is more than offset by the use
of the very fast `memchr` inside `for_byte_record_with_terminator`.
This change also simplifies the code significantly. Removed the `buffer`
module.
2021-04-24 22:29:48 +05:30
Sylvestre Ledru
2f17bfc14c
Merge pull request #2106 from miDeb/sort-debug
sort: implement --debug
2021-04-24 18:46:58 +02:00
Sylvestre Ledru
883dec9d00
Merge pull request #2108 from miDeb/tests-pretty-diffs
tests: show pretty diffs for assertion failures
2021-04-24 18:14:47 +02:00
Sylvestre Ledru
c9b0378ca3
Merge pull request #2104 from tertsdiepraam/ls/skip_metadata
`ls`: skip reading metadata
2021-04-24 18:13:53 +02:00
Michael Debertol
2084c3ddf3 tests: show pretty diffs for assertion failures
- All assert_eq in tests/common/util.rs now print a pretty diff on test
failures.
- {stdout, stderr}_is_fixture now compare the expected output and the
fixture as Strings, which leads to more usable diffs.
2021-04-24 16:43:13 +02:00
Sylvestre Ledru
99840b9099 refresh cargo.lock with recent updates 2021-04-24 13:15:59 +02:00
Terts Diepraam
ce8c58b93e Merge branch 'master' into ls/skip_metadata 2021-04-24 10:45:43 +02:00
Michael Debertol
e6f6b109a5 sort: implement --debug
This adds a --debug flag, which, when activated, will draw lines below
the characters that are actually used for comparisons.

This is not a complete implementation of --debug. It should, quoting the man page
for GNU sort: "annotate the part of the line used to sort, and warn
about questionable usage to stderr". Warning about "questionable usage"
is not part of this patch.

This change required some adjustments to be able to get the range that
is actually used for comparisons. Most notably, general numeric comparisons
were rewritten, fixing some bugs along the lines.

Testing is mostly done by adding fixtures for the expected debug output of
existing tests.
2021-04-23 22:36:15 +02:00
Terts Diepraam
72bf7afe5b ls: also update Cargo.lock 2021-04-23 00:49:05 +02:00
Terts Diepraam
b9f4964a96 ls: bring up to date with recent changes 2021-04-22 11:39:08 +02:00
Terts Diepraam
3fc8d2e422 ls: make compatible with Rust 1.40 again 2021-04-21 18:05:10 +02:00
electricboogie
42da444f40 Remove unused deps 2021-04-18 13:49:11 -05:00
electricboogie
d7b7ce52bc Vendored ext_sorter, removed unstable, created a byte buffer sized vector instead of a numbered capacity vector 2021-04-18 11:54:18 -05:00
electricboogie
acfe0681d4 Merge branch 'master' of https://github.com/uutils/coreutils 2021-04-17 11:54:45 -05:00
electricboogie
a76d452f75
Sort: More small fixes (#2065)
* Various fixes and performance improvements

* fix a typo

Co-authored-by: Michael Debertol <michael.debertol@gmail.com>

* Fix month parse for months with leading whitespace

* Implement test for months whitespace fix

* Confirm human numeric works as expected with whitespace with a test

* Correct arg help value name for --parallel

* Fix SemVer non version lines/empty line sorting with a test

Co-authored-by: Sylvestre Ledru <sledru@mozilla.com>
Co-authored-by: Michael Debertol <michael.debertol@gmail.com>
2021-04-17 10:06:19 +02:00
electricboogie
e6c195a675 ExtSort 2021-04-12 14:24:22 -05:00
Árni Dagur
eb4971e6f4
cat: Unrevert splice patch (#2020)
* cat: Unrevert splice patch

* cat: Add fifo test

* cat: Add tests for error cases

* cat: Add tests for character devices

* wc: Make sure we handle short splice writes

* cat: Fix tests for 1.40.0 compiler

* cat: Run rustfmt on test_cat.rs

* Run 'cargo +1.40.0 update'
2021-04-10 22:19:53 +02:00
electricboogie
77411f3fb5 Implement test for months whitespace fix 2021-04-10 13:36:57 -05:00
Michael Debertol
69f4410a8a
sort: dedup using compare_by (#2064)
compare_by is the function used for sorting, we should use it for dedup
as well.
2021-04-10 19:49:10 +02:00
Michael Debertol
49c9d8c901
sort: implement -k and -t support (#1996)
* sort: implement basic -k and -t support

This allows to specify keys after the -k flag and a custom field
separator using -t.

Support for options for specific keys is still missing, and the -b flag
is not passed down correctly.

* sort: implement support for key options

* remove unstable feature use

* don't pipe in input when we expect a failure

* only tokenize when needed, remove a clone()

* improve comments

* fix clippy lints

* re-add test

* buffer writes to stdout

* fix ignore_non_printing

and make the test fail in case it is broken :)

* move attribute to the right position

* add more tests

* add my name to the copyright section

* disallow dead code

* move a comment

* re-add a loc

* use smallvec for a perf improvement in the common case

* add BENCHMARKING.md

* add ignore_case to benchmarks
2021-04-10 14:54:58 +02:00
Sylvestre Ledru
e1221ef3f8
Merge pull request #2036 from joppich/issue1930
stdbuf: move from getopts to clap
2021-04-10 11:58:01 +02:00
Nicolas Thery
698924a20a
unlink: move from getopts to clap (#2052) (#2058) 2021-04-10 11:50:21 +02:00
joppich
c54b5f2d82 stdbuf: move from getopts to clap 2021-04-10 00:39:12 +02:00
Sylvestre Ledru
844e318a67
Merge branch 'master' into pr 2021-04-09 22:02:25 +02:00
electricboogie
8474249e5f
Sort: Implement stable sort, ignore non-printing, month sort dedup, auto parallel sort through rayon, zero terminated sort, check silent (#2008) 2021-04-08 22:07:09 +02:00
Sylvestre Ledru
717b875b5d
Merge pull request #2046 from ricardoaiglesias/timeout-clap
timeout: Moved argument parsing to clap
2021-04-07 23:19:36 +02:00
paulotten
52706372aa
Replace outdated time 0.1 dependancy with latest version of chrono (#2044)
* Replace outdated time 0.1 dependancy with latest version of chrono

I also noticed that times are being miscalculated on linux, so I fixed that.

* Add time test for issue #2042

* Cleanup use declarations

* Tie time test to `touch` feature
- if we compile with the right OS feature flag then we should have it,
  even on Windows
2021-04-07 08:41:04 +02:00
Ricardo Iglesias
ea0ead6a2e Ran cargo lock update command. 2021-04-06 22:16:52 -07:00
Yagiz Degirmenci
c965effe07
fold: move to clap, add tests (#2015) 2021-04-06 22:51:27 +02:00
Sylvestre Ledru
f57eb0fdfa
Merge pull request #1993 from cbjadwani/master
uniq: Implement --group option
2021-04-05 22:33:04 +02:00