This commit adds checks for block size constants. Misconfigured sizes
could lead to overflows or performance issues. While such cases are
expected to be rare or unlikely, it's better to be notified of them
early.
The value of the variable remains unchanged (4096 = 2 ^ 12), but using a
bitwise expression provides two benefits:
- follows the same approach used for configuring BLOCK_SIZE
- indicates that a power-of-two value is preferred for this kind of
constant
bytecount uses vector operations to speed up line counting.
At least on x86 with AVX2 support, the vectors are 256-byte wide,
and operations are much faster if the data is aligned.
Saves about 4% of total performance, matching wc's performance.
This commit improves the reliability of the writing logic and removes
implicit dependencies between the preferred I/O size and the block size.
For example, in earlier versions, using BLOCK_SIZE != N * IO_SIZE could
lead to overflows due to alignment with values larger than the buffer
size.
This commit allows aligning output data by 4K to better match GNU shred.
The 4K block size is configured as a constant because it provides a
widely used value in the simplest way. However, there is a chance that
some systems may use a different value. So far, I haven't encountered
anything other than 4K, I decided not to overcomplicate the approach for
now.
* Parsing echo flags manually without clap as clap introduced various problematic interactions with hyphens
* fixed error where multiple flags would parse wrong
* Spelling & formatting fixes
* docu for EchoFlag struct
* more extensive comment/documentation
* revert POSIXLY_CORRECT check to only check if it is set
* Fixed problem of overwriting flags. Added test for same issue
* cargo fmt
* cspell
* Update src/uu/echo/src/echo.rs
Enabling POSIXLY_CORRECT flag if value is not UTF-8
Co-authored-by: Jan Verbeek <jan.verbeek@posteo.nl>
---------
Co-authored-by: Jan Verbeek <jan.verbeek@posteo.nl>
* fixes#7763
- introduce macOS-specific config guard
- added test for testing tail stdin when redirected (`>`) from file and
when through a pipe (`|`)
* created test to mock behavior in #7763, with comments
added drop line
* re-enabled test_stdin_redirect_dir_when_target_os_is_macos, and added a check to handle error message
* added location of current directory so test env can find script
* adjusting to try to have FreeBSD find the file in CI test
* putting in /env instead of assuming bash
* removed ignore macro
* added comments explaining the need for specific macOS cases, including reference to rust-lang issue: https://github.com/rust-lang/rust/issues/95239
* expr: Fix regex escape logic
We have to track if the previous character was already escaped to determine
if the '\' character should be interpreted as an escape character.
* expr: Fix parsing caret (^) as character class negation token
* expr: Add tests for parsing carets in regex
* expr: Add missing semicolon
* expr: Simplify boolean assignment
Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
---------
Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>