Commit graph

6004 commits

Author SHA1 Message Date
Michael Debertol
d7ff2ce5ad
doc: Add instructions to run GNU tests 2021-08-26 11:49:45 +02:00
Jan Verbeek
94e33c97f3 wc: Add benchmarking documentation 2021-08-26 01:38:16 +02:00
Jan Verbeek
1358aeecdd wc: Avoid unnecessary work in general loop
This gives a big speedup if e.g. only characters are being counted.
2021-08-26 01:38:16 +02:00
Jan Verbeek
f50b004860 wc: Adjust expected report for directories for Windows 2021-08-26 01:38:16 +02:00
Jan Verbeek
4943517327 wc: Adjust expected error messages for Windows 2021-08-26 01:38:16 +02:00
Jan Verbeek
0f1e79fe29 wc: Fix linters 2021-08-26 01:38:16 +02:00
Jan Verbeek
9972cd1327 wc: Report counts and failures correctly
If reading fails midway through then a count should be reported for
what could be read.

If opening a file fails then no count should be reported.

The exit code shouldn't report the number of failures, that's fragile
in case of many failures.
2021-08-26 01:38:16 +02:00
Jan Verbeek
c16e492cd0 wc: Make output width more consistent with GNU 2021-08-26 01:38:16 +02:00
Jan Verbeek
d0c0564947 wc: Swap order of characters and bytes in output
This way it matches GNU and busybox.
2021-08-26 01:38:16 +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
35793fc260 wc: Accept badly-encoded filenames 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
353fc443
d4697d9883
env: added UResult 2021-08-25 22:02:35 +05:30
Andreas Hartmann
c756878b20 backup_control: Use C-locale quotes in outputs 2021-08-25 16:33:50 +02:00
Andreas Hartmann
8ecef029f6 mv: Adapt to modified backup_control interface 2021-08-25 16:33:50 +02:00
Andreas Hartmann
2a1a923acc ln: Adapt to modified backup_control interface 2021-08-25 16:33:50 +02:00
Andreas Hartmann
ce0d9bce28 install: Adapt to modified backup_control interface 2021-08-25 16:33:50 +02:00
Andreas Hartmann
f2311f87f4 cp: Adapt to modified backup_control interface 2021-08-25 16:33:50 +02:00
Andreas Hartmann
6c86957a24 backup_control: Fix internal tests
Adapt the tests to work with the changed function interfaces. Added a
convenience function to construct a `clap` application that's used to test the
functions from a "user"-perspective.
2021-08-25 16:33:50 +02:00
Andreas Hartmann
6f4e43e7c6 backup_control: Update docs
Add documentation to the module itself and update existing documentations for
functions whose interfaces changed. Add more doctests.
2021-08-25 16:33:50 +02:00
Andreas Hartmann
e132fd49d9 backup_control: Rework function interfaces
Change all relevant functions to return `UResult`s from `BackupError` instead
of error strings. Make `determine_backup_mode/suffix` accept `clap::ArgMatches`
as input argument to parse for the arguments themselves, using the arguments
with are defined in the `arguments` submodule.

This way the user only needs to include the pre-defined arguments from the
`arguments` module and passes a reference to the applications `ArgMatches` into
the respective functions here. The functions then take care of handling the
arguments. It is recommended to use the arguments provided in the `arguments`
module over custom-defined ones.
2021-08-25 16:33:50 +02:00
Andreas Hartmann
54086ef4c5 backup_control: Implement custom error type
Implements an error type based on `UError` that replaces the previously used
error strings. The errors are currently returned when determining the backup
mode, but extensions for future uses are already in place as comments.
2021-08-25 16:33:50 +02:00
Andreas Hartmann
2c6410f4d8 backup_control: Add arguments module
Contains functions that create the CLI arguments associated with the backup
functionality.
2021-08-25 16:33:50 +02:00
Sylvestre Ledru
baebefcb6a
Merge pull request #2442 from sylvestre/doc
Document the source documentation + document some modules
2021-08-25 14:09:01 +02:00
Andreas Hartmann
4fbb741314 macros: Remove obsolete macros
Removes the `return_if_err!` and `safe_unwrap!` macros, which have now
been replaces by `crash_if_err!` throughout the whole code and thus
aren't used any longer.
2021-08-25 13:59:39 +02:00
Andreas Hartmann
1755195251 uu: Replace return_if_err with crash_if_err
Unify the usage of macros `return_if_err` and `crash_if_err`. As
`return_if_err` is used only in `uumain` routines of utilities, it
achieves the same thing as `crash_if_err`, which calls the `crash!`
macro to terminate function execution immediately.
2021-08-25 13:59:39 +02:00
Andreas Hartmann
229948ae45 uu: Replace safe_unwrap with crash_if_err
Unify the usage of macros `safe_unwrap` and `crash_if_err` that are
identical to each other except for the assumption of a default error
code. Use the more generic `crash_if_err` so that `safe_unwrap` is now
obsolete and can be removed.
2021-08-25 13:59:39 +02:00
Michael Debertol
5ab05a9219 chmod: remove redundant cfg
redox is unix.
2021-08-25 13:52:09 +02:00
Michael Debertol
5121e2eec1 chmod: add check for quiet 2021-08-25 13:52:09 +02:00
Michael Debertol
38afdd6ab4 uucore/mode: add cast for some platforms 2021-08-25 13:52:09 +02:00
Michael Debertol
5825889931 chmod: correctly handle modes after -- 2021-08-25 13:52:09 +02:00
Michael Debertol
b841a11421 chmod: fail if the operand list is empty 2021-08-25 13:52:09 +02:00
Michael Debertol
945e57ea22 chmod: show an error if a permission wasn't removed due to umask 2021-08-25 13:52:09 +02:00
Michael Debertol
15b40f6aa2 chmod: implement special handling of directory setuid/setgid 2021-08-25 13:52:09 +02:00
Michael Debertol
9697c89d17 uucore/mode: handle mode 0
Trimming all '0' characters results in an invalid string if the string
contained only '0's.
2021-08-25 13:52:09 +02:00
Michael Debertol
74958794c6 chmod: print change message to stdout, not stderr 2021-08-25 13:52:09 +02:00
Michael Debertol
080998b6ef chmod: pad all file modes to 4 digits 2021-08-25 13:52:09 +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
Jan Verbeek
ea16cc72c7
Make clippy workspace selection more finegrained (#2598)
* Make clippy workspace selection more finegrained

* fixup! Make clippy workspace selection more finegrained

* fixup! Make clippy workspace selection more finegrained

* fixup! Make clippy workspace selection more finegrained

* fixup! Make clippy workspace selection more finegrained

* fixup! Make clippy workspace selection more finegrained
2021-08-25 01:41:25 +02:00
Sylvestre Ledru
eb6ab9f883 Document some modules 2021-08-24 23:00:00 +02:00
Sylvestre Ledru
f3a47428f8 Document where is the source doc 2021-08-24 22:35:41 +02:00
Sylvestre Ledru
111d3e37bb
Merge pull request #2570 from miDeb/chgrp/no-duplication
chgrp/chown: move common code to `uucore`
2021-08-24 21:58:15 +02:00
Sylvestre Ledru
7c62337229
Merge pull request #2589 from devnexen/itmpx_netbsd
uucore netbsd update
2021-08-24 21:57:22 +02:00
Sylvestre Ledru
23d5e86c9b
Merge pull request #2595 from blyxxyz/clippy-workspace
Run clippy on the full workspace
2021-08-24 21:31:39 +02:00
Michael Debertol
ea41cc0ff6 uucore/fs: use the latest resolution that did not fail
When we ignore failures resolving symbolic links we should keep the
latest resolution that did not fail, not the original path.
2021-08-24 21:18:10 +02:00
Jan Verbeek
acfd1ebe57 fixup! Run clippy on the full workspace 2021-08-24 17:28:10 +02:00
Jan Verbeek
d06c074829 Run clippy on the full workspace
These lints were cluttering up the "problems" tab in my VS
Code. `--workspace` fixes the disparity.
2021-08-24 17:10:16 +02:00
Michael Debertol
4e251706be refactor: move shared chown logic to uucore 2021-08-24 15:22:05 +02:00