Commit graph

5305 commits

Author SHA1 Message Date
nicoo
12efaa6add factor: Add BENCHMARKING.md 2021-05-17 19:43:38 +02:00
nicoo
7c287542c7 factor::table: Fixup microbenchmark
Previous version would perform an amount of work proportional to `CHUNK_SIZE`,
so this wasn't a valid way to benchmark at multiple values of that constant.

The `TryInto` implementation for `&mut [T]` to `&mut [T; N]` relies on `const`
generics, and is available in (stable) Rust v1.51 and later.
2021-05-17 19:43:38 +02:00
nicoo
1fd5f9da25 factor::table::factor_chunk: Turn loop inside-out
This keeps the traversal of `P_INVS_U64` (a large table) to a single pass
in-order, rather than `CHUNK_SIZE` passes.
2021-05-17 19:43:38 +02:00
nicoo
cd047425aa factor::table: Add chunked implementation and microbenchmarks
The factor_chunk implementation is a strawman, but getting it in place allows us
to set up the microbenchmarking etc.
2021-05-17 19:43:38 +02:00
nicoo
c68c83c6dd factor::table: Take mutable refs
This will be easier to adapt to working with multiple numbers to process at once.
2021-05-17 19:43:38 +02:00
Jeffrey Finkelstein
eeef8290df head: display errors for each input file
Change the behavior of `head` to display an error for each problematic
file, instead of displaying an error message for the first problematic
file and terminating immediately at that point. This change now matches
the behavior of GNU `head`.

Before this commit, the first error caused the program to terminate
immediately:

    $ head a b c
    head: error: head: cannot open 'a' for reading: No such file or directory

After this commit:

    $ head a b c
    head: cannot open 'a' for reading: No such file or directory
    head: cannot open 'b' for reading: No such file or directory
    head: cannot open 'c' for reading: No such file or directory
2021-05-17 08:19:47 -04:00
Sylvestre Ledru
6c830e2f25
Merge pull request #2220 from chadbrewbaker/fix-ls-test-regex
fixing regex to take negative time offsets
2021-05-17 08:17:19 +02:00
Chad Brewbaker
2f84f59573 fixing regex to take negative time offsets 2021-05-16 19:43:53 -05: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
c930509095
Fix clippy warning 2021-05-16 22:30:46 +05:30
Arijit Dey
22ba21d8ab
Fix bug with terminal getting weird 2021-05-16 22:26:54 +05:30
Sylvestre Ledru
9e2c82d8e7
Merge pull request #2217 from jfinkels/head-multiple-files
head: print headings when reading multiple files
2021-05-16 18:28:31 +02:00
Jeffrey Finkelstein
659bf58a4c head: print headings when reading multiple files
Fix a bug in which `head` failed to print headings for `stdin` inputs
when reading from multiple files, and fix another bug in which `head`
failed to print a blank line between the contents of a file and the
heading for the next file when reading multiple files. The output now
matches that of GNU `head`.
2021-05-16 12:03:10 -04:00
Sylvestre Ledru
7d2b6409e2
Merge pull request #2216 from jfinkels/head-refactor-rbuf-n-bytes
head: simplify rbuf_n_bytes() in head.rs
2021-05-16 12:25:53 +02:00
Jeffrey Finkelstein
733d347fa8 head: simplify rbuf_n_bytes() in head.rs
Simplify the code in `rbuf_n_bytes()` to use existing abstractions
provided by the standard library.
2021-05-15 23:04:01 -04:00
Jeffrey Finkelstein
97a49c7c95 wc: compute min width to format counts up front
Fix two issues with the string formatting width for counts displayed
by `wc`.

First, the output was previously not using the default minimum width
(seven characters) when reading from `stdin`. This commit corrects
this behavior to match GNU `wc`. For example,

    $ cat alice_in_wonderland.txt | wc
          5      57     302

Second, if at least 10^7 bytes were read from `stdin` *after* reading
from a smaller regular file, then every output row would have width
8. This disagrees with GNU `wc`, in which only the `stdin` row and the
total row would have width 8. This commit corrects this behavior to
match GNU `wc`. For example,

    $ printf "%.0s0" {1..10000000} | wc emptyfile.txt -
	  0       0       0 emptyfile.txt
	  0       1 10000000
	  0       1 10000000 total

Fixes #2186.
2021-05-15 21:41:47 -04:00
Sylvestre Ledru
620a5a5df6
Merge pull request #2210 from jhscheer/dns_lookup
who: fix `--lookup`
2021-05-15 21:18:12 +02:00
Sylvestre Ledru
46cf61b5b7
Merge pull request #2212 from jfinkels/2211-wc-error-messages
wc: correct some error messages for invalid inputs
2021-05-15 21:14:15 +02:00
Jeffrey Finkelstein
e8d911d9d5 wc: correct some error messages for invalid inputs
Change the error messages that get printed to `stderr` for compatibility
with GNU `wc` when an input is a directory and when an input does not
exist.

Fixes #2211.
2021-05-15 10:35:21 -04:00
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
204b051711
Merge pull request #2206 from jfinkels/tail-reverse-block-iterator
tail: refactor code into ReverseChunks iterator
2021-05-13 09:07:02 +02:00
Jeffrey Finkelstein
2e621759b2 tail: refactor code into ReverseChunks iterator
Refactor code from the `backwards_thru_file()` function into a new
`ReverseChunks` iterator, and use that iterator to simplify the
implementation of the `backwards_thru_file()` function. The
`ReverseChunks` iterator yields `Vec<u8>` objects, each of which
references bytes of a given file.
2021-05-12 18:43:58 -04:00
Jeffrey Finkelstein
3114fd77be tail: use &mut File instead of mut file: &File 2021-05-12 18:43:35 -04:00
Sylvestre Ledru
190a936a23
Merge pull request #2208 from sylvestre/update-cargo-lock2
refresh cargo.lock with recent updates
2021-05-12 23:32:15 +02:00
Sylvestre Ledru
0669c89ef3 refresh cargo.lock with recent updates 2021-05-12 14:47:45 +02:00
Sylvestre Ledru
2178edf628
Merge pull request #2207 from jhscheer/issue_2204
date: fix format literal for nanoseconds
2021-05-12 13:14:23 +02:00
Jan Scheer
12a43d6eb3 date: fix format literal for nanoseconds 2021-05-12 10:21:24 +02:00
Sylvestre Ledru
a5f8ca60b5
Merge pull request #2199 from jhscheer/refactor_fsext
df/stat: refactor - reduce duplicate code
2021-05-12 08:41:16 +02:00
Sylvestre Ledru
6635301f32
Merge pull request #2194 from miDeb/sort-stable-merge
sort: make merging stable
2021-05-12 08:38:48 +02:00
Sylvestre Ledru
57ae202037
Merge pull request #2195 from nthery/wc_dash
wc: emit '-' in ouput when set on command-line
2021-05-12 08:37:55 +02:00
Sylvestre Ledru
8f24ec9414
Merge pull request #2198 from jfinkels/tail-refactor
tail: simplify unbounded_tail() function
2021-05-12 08:35:45 +02:00
Sylvestre Ledru
68a3488cdc
Merge pull request #2202 from drocco007/test-negated-boolean
test: improve handling of inverted Boolean expressions
2021-05-12 08:34:41 +02:00
Sylvestre Ledru
e16df57206
Merge pull request #2205 from jhscheer/issue_2204
date: fix format for nanoseconds
2021-05-11 23:44:29 +02:00
Jan Scheer
8200d399e8 date: fix format for nanoseconds 2021-05-11 23:03:59 +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
6aee792a93 Remove travis CI
* it is redundant with github action
* less integrated
* fails someone for some unexpected reasons
* it is blocking code coverage results ?!
2021-05-11 09:30:46 +02:00
Daniel Rocco
2ec4bee350 test: improve handling of inverted Boolean expressions
- add `==` as undocumented alias of `=`

- handle negated comparison of `=` as literal

- negation generally applies to only the first expression of a Boolean chain,
  except when combining evaluation of two literal strings
2021-05-10 22:48:40 -04:00
Jan Scheer
381f8dafc6 df/uucore: refactor - move duplicate code to uucore/fsext.rs 2021-05-10 23:37:01 +02:00
Sylvestre Ledru
ed42652803
Merge pull request #2200 from jhscheer/fix_clippy
fix clippy warnings
2021-05-10 16:13:27 +02:00
Jan Scheer
4ac75898c3 fix clippy warnings 2021-05-10 15:48:32 +02:00
Sylvestre Ledru
adf12ee927
Merge pull request #2197 from Gilnaa/2125-arch-clap
Switched 'arch' to use clap instead of getopts
2021-05-10 15:06:46 +02:00
Jan Scheer
203ee463c7 stat/uucore: refactor - move fsext.rs to uucore 2021-05-10 10:46:00 +02:00
Sylvestre Ledru
f7ad47d7e4
Merge pull request #2196 from uutils/sylvestre-patch-6
Ignore test_domain_socket  as it fails too often
2021-05-10 09:00:19 +02:00
Sylvestre Ledru
881bbf512e refresh cargo.lock with recent updates 2021-05-10 08:59:45 +02:00
Jeffrey Finkelstein
0cc779c733 tail: simplify unbounded_tail() function
Refactor common code out of two branches of the `unbounded_tail()`
function into a new `unbounded_tail_collect()` helper function, that
collects from an iterator into a `VecDeque` and keeps either the last
`n` elements or all but the first `n` elements.

This commit also adds a new struct, `RingBuffer`, in a new module,
`ringbuffer.rs`, to be responsible for keeping the last `n` elements
of an iterator.
2021-05-09 23:47:13 -04:00
Gilad Naaman
8747800697 Switched 'arch' to use clap instead of getopts 2021-05-09 21:53:03 +03:00
Sylvestre Ledru
33206e1adc
Ignore test_domain_socket as it fails too often 2021-05-09 18:42:16 +02:00
Sylvestre Ledru
7c51fb4946
Merge pull request #2165 from miDeb/sort-optimize-line
sort: optimize the line struct
2021-05-09 18:41:39 +02:00
Nicolas Thery
112b042769 wc: emit '-' in ouput when set on command-line
When stdin is explicitly specified on the command-line with '-', emit it
in the output stats to match GNU wc output.

Fixes #2188.
2021-05-09 15:47:05 +02:00