Commit graph

514 commits

Author SHA1 Message Date
kimono-koans
fd64e01d92
ls: Reduce binary size of ls by removing regex crate (#2781) 2021-12-22 18:31:45 +01:00
Sylvestre Ledru
a3041843c9 bump the platform-info dep 2021-12-18 00:04:03 +01:00
Roy Ivy III
7834d9ffaf update Cargo.lock 2021-11-19 17:55:03 -06:00
Sylvestre Ledru
ca1156458e
Merge pull request #2714 from blyxxyz/os_display-crate
Move display::Quotable into its own crate
2021-11-12 21:17:59 +01:00
nicoo
32b0178a72 factor: Update to current versions of smallvec
smallvec 1.0 and later wasn't compatible with Rust 1.33 but the
minimum supported Rust version for coreutils moved on.
2021-11-10 15:12:37 +01:00
Jan Verbeek
77e1570ea0 Move display::Quotable into its own crate
The standalone version has a number of bugfixes compared to the old
version.
2021-11-08 23:07:40 +01:00
jfinkels
2e12316ae1
seq: use BigDecimal to represent floats (#2698)
* seq: use BigDecimal to represent floats

Use `BigDecimal` to represent arbitrary precision floats in order to
prevent numerical precision issues when iterating over a sequence of
numbers. This commit makes several changes at once to accomplish this
goal.

First, it creates a new struct, `PreciseNumber`, that is responsible for
storing not only the number itself but also the number of digits (both
integer and decimal) needed to display it. This information is collected
at the time of parsing the number, which lives in the new
`numberparse.rs` module.

Second, it uses the `BigDecimal` struct to store arbitrary precision
floating point numbers instead of the previous `f64` primitive
type. This protects against issues of numerical precision when
repeatedly accumulating a very small increment.

Third, since neither the `BigDecimal` nor `BigInt` types have a
representation of infinity, minus infinity, minus zero, or NaN, we add
the `ExtendedBigDecimal` and `ExtendedBigInt` enumerations which extend
the basic types with these concepts.

* fixup! seq: use BigDecimal to represent floats

* fixup! seq: use BigDecimal to represent floats

* fixup! seq: use BigDecimal to represent floats

* fixup! seq: use BigDecimal to represent floats

* fixup! seq: use BigDecimal to represent floats
2021-11-06 15:44:42 +01:00
Sylvestre Ledru
59e9870c56 Prepare version 0.0.8 2021-10-23 19:21:50 +02:00
Jeffrey Finkelstein
858b0a9e9f head: use std::io::copy() with TakeLines reader
Replace the custom `split::walk_lines()` function with a call to
`std::io::copy()`, using a new `TakeLines` reader as the source and
`stdout` as the destination. The `TakeLines` reader is an adaptor that
scans the bytes being read for line ending characters and stops the
reading after a given number of lines has been read (similar to the
`std::io::Take` adaptor).

This change

* makes the `read_n_lines()` function more concise,
* allows it to mirror the implementation of `read_n_bytes()`,
* increases the speed of `head -n NUM`.
2021-10-20 20:59:44 -04:00
Adam Reichold
c526df57b8 tac: opportunistically use memory maps
Since tac must read its input files completely to start processing them
from the end, it is particularly suited to use memory maps to benefit
from the page cache maintained by the operating systems to bring the
necessary data into memory as required.

This does also include situations where the input is stdin, but not via
a pipe but for example a file descriptor set up by the user's shell
through an input redirection.
2021-10-10 13:20:31 +02:00
Sylvestre Ledru
b2fa51ddd9
Merge pull request #2656 from jhscheer/ls_selinux
`ls`: add support for showing SELinux context (--context/-Z)
2021-10-02 12:56:09 +02:00
Raphaël Thériault
6931dd11f1 Use non-yanked version of digest crate in hashsum 2021-09-19 12:38:56 -07:00
Jan Scheer
79d838b1c3
Merge branch 'master' into ls_selinux 2021-09-17 14:14:47 +02:00
Jan Verbeek
4555c85564 whoami: Cleanup
- Use modern conventions
- Restrict the scope of unsafe
- Do not use deprecated `std::mem::unitialized()`
- Do not bake unicode into design
2021-09-13 22:54:45 +02:00
Sylvestre Ledru
e9d63519dd
Merge pull request #2668 from sylvestre/unused-deps
Remove plenty of unused deps
2021-09-13 21:45:39 +02:00
Sylvestre Ledru
a74e4bf095 shred: remove the unused dep on filetime 2021-09-13 18:15:51 +02:00
Sylvestre Ledru
a6c235bcd1 csplit: remove the unused dep on glob 2021-09-13 18:15:51 +02:00
Sylvestre Ledru
826c948234 ls: remove the unused dep on locale 2021-09-13 18:15:51 +02:00
Michael Debertol
5faa4c41db
Merge pull request #2607 from jfinkels/tac-regex
tac: add support for --regex option to tac
2021-09-13 18:12:57 +02:00
Sylvestre Ledru
87b6aa89e3
pr: remove unused "time" dep (#2667) 2021-09-13 18:08:51 +02:00
Sylvestre Ledru
68df4de1a2
nice: update to use the same version of nix as other programs (#2666) 2021-09-13 18:08:41 +02:00
Sylvestre Ledru
ebe897e4d4
shred: remove unused "time" dep (#2665) 2021-09-13 18:05:06 +02:00
Jan Scheer
4dc6536bb9
Merge branch 'master' into ls_selinux 2021-09-13 13:42:51 +02:00
Sylvestre Ledru
447d6f2b61
Merge pull request #2654 from blyxxyz/dedup-splice
Move common pipe and splice functions into uucore
2021-09-12 09:23:05 +02:00
Jeffrey Finkelstein
664c7a6ec5 tac: add support for --regex option to tac
Add support for `tac --regex`, where the line separator is interpreted
as a regular expression.
2021-09-11 22:54:55 -04:00
Jan Verbeek
b7d697753c unlink: Simplify, remove unsafe, move to core
This makes it no longer possible to pass multiple filenames, but every
other implementation I tried (GNU, busybox, FreeBSD, sbase) also
forbids that so I think it's for the best.
2021-09-10 21:50:38 +02:00
Jan Scheer
fe3645d4d5
ls: add support for showing SELinux context (--context/-Z) 2021-09-10 21:33:34 +02:00
Jan Verbeek
c1079e0b1c Move common pipe and splice functions into uucore
This cuts down on repetitive unsafe code and repetitive code in
general.
2021-09-10 21:24:34 +02:00
Jan Verbeek
60df3c6b7c uucore: Cache args_os(), util_name(), execution_phrase()
And remove args() because there's no valid use for it, invalid unicode
handling is specified in a different way.
2021-09-07 18:51:25 +02:00
Sylvestre Ledru
6226a03214
Merge pull request #2624 from miDeb/cp/acl
cp: correctly copy mode, ownership, acl and context
2021-09-03 20:18:13 +02:00
Jan Verbeek
3f6ca4723e Update num-bigint to 0.4.2 to fix CI 2021-09-03 19:24:02 +02:00
Michael Debertol
8b74562820 cp: correctly copy mode, ownership, acl and context
Fix a mix-up between ownership and mode. The latter (mode / file permissions)
can also be set on windows (which however only affects the read-only flag),
while there doesn't seem to be a straight-forward way to change file ownership
on windows.

Copy the acl as well when copying the mode. This is a non-default feature and can be
enabled with --features feat_acl, because it doesn't seem to work on CI.
It is only available for unix so far.

Copy the SELinux context if possible.
2021-09-01 00:16:22 +02:00
Jan Verbeek
afb460f4ca rmdir: match GNU
- Implement all of GNU's fiddly little details
- Don't assume Linux for error codes
- Accept badly-encoded filenames
- Report errors after the fact instead of checking ahead of time
- General cleanup

rmdir now passes GNU's tests.
2021-08-28 02:26:01 +02:00
Jan Verbeek
657a04f706 wc: Stricter simpler error handling
Errors are now always shown with the corresponding filename.

Errors are no longer converted into warnings. Previously `wc < .`
would cause a loop.

Checking whether something is a directory is no longer done in
advance. This removes race conditions and the edge case where stdin is
a directory.

The custom error type is removed because io::Error is now enough.
2021-08-26 01:38:16 +02:00
Jan Verbeek
6f7d740592 wc: Do a chunked read with proper UTF-8 handling
This brings the results mostly in line with GNU wc and solves nasty
behavior with long lines.
2021-08-26 01:38:16 +02:00
Jan Verbeek
48437fc49d wc: Optimize, improve correctness
- Reuse allocations for read lines
- Increase splice size
- Check if /dev/null was opened correctly
- Do not discard read bytes after I/O error
- Add fast line counting with bytecount
2021-08-26 01:38:16 +02:00
Jeffrey Finkelstein
52cfd4c6cb hashsum: don't copy input buffer on Windows
Remove a copy operation of the input buffer being read for digest when
reading in text mode on Windows. Previously, the code was copying the
buffer to a completely new `Vec`, replacing "\r\n" with "\n". Instead,
the code now scans for the indices at which each "\r\n" occurs in the
input buffer and inputs into the digest only the characters before the
"\r" and after it.
2021-08-25 13:50:19 +02:00
Jan Verbeek
e5d6c6970b yes: Cleanup
Report errors properly instead of panicking.

Replace zero_copy by a simpler specialized private module.

Do not assume splices move all data at once.

Use the modern uutils machinery.

Remove the "latency" feature. The time it takes to prepare the buffer
is drowned out by the startup time anyway.

yes: Add tests

yes: Fix long input test on Windows
2021-08-25 13:45:44 +02:00
Michael Debertol
4e251706be refactor: move shared chown logic to uucore 2021-08-24 15:22:05 +02:00
Michael Debertol
7153a595c6 chgrp: forward to chown
chgrp does mostly the same as chown.
By making chown a bit more configurable we can reuse its code for chgrp.
2021-08-24 15:22:05 +02:00
Jeffrey Finkelstein
0e689e78aa tac: support multi-char separator with overlap
Fix a bug in `tac` where multi-character line separators would cause
incorrect behavior when there was overlap between candidate matches in
the input string. This commit adds a dependency on `memchr` in order to
use the `memchr::memmem::rfind_iter()` function to scan for
non-overlapping instances of the specified line separator characters,
scanning from right to left.

Fixes #2580.
2021-08-23 20:16:38 -04:00
Koutheir Attouchi
7010dfd939 runcon: added implementation and tests. 2021-08-22 21:59:41 +02:00
Sylvestre Ledru
5089214832 bump a few crates to simplify Debian packaging (second) 2021-08-22 00:42:03 +02:00
Sylvestre Ledru
8337aeb4d6 bump a few crates to simplify Debian packaging 2021-08-21 23:34:45 +02:00
Koutheir Attouchi
83a515e4c3 chcon: reduce the number of unsafe blocks. 2021-08-10 13:50:51 -04:00
Michael Debertol
03ceb6750e cat: check if the input file is also the output file 2021-08-08 01:32:22 +02:00
Jeremy Soller
0474a2eadd
more, tail, test: Update redox_syscall to 0.2 2021-08-06 13:56:20 -06:00
Sylvestre Ledru
32d281bbcc
Merge pull request #2544 from miDeb/sort/delete-tmps
sort: delete temporary files when sort is terminated
2021-08-06 11:52:06 +02:00
Michael Debertol
0ae9e10ed3 sort: delete the temporary directory when sort is terminated
When hitting Ctrl+C sort now deletes any temporary files. To make this easier I
created a new struct `TmpDirWrapper` that handles the creation of new temporary
files and the registration of the signal handler.
2021-08-06 11:29:24 +02:00
Sylvestre Ledru
50b9d9f9a3
Merge branch 'master' into master 2021-08-06 09:26:39 +02:00