This commit differentiates Base64 strings that are known to be invalid
before decoding (because their length is not a multiple of 4), from
Base64 strings that are invalid at decoding (padding is invalid).
* feat: add compact float formatting for half and bfloat16 in od
Implement trim_float_repr() to remove trailing zeros from float strings while preserving signs and exponents, and pad_float_repr() to align trimmed floats to fixed width. Update format_item_f16() and format_item_bf16() to produce compact output matching GNU od. Add regression tests for float16 and bfloat16 compact printing.
* refactor(od): format multiline format! in format_item_bf16 for readability
Reformat the format! macro call in the format_item_bf16 function in prn_float.rs
to span multiple lines, improving code readability without changing functionality.
* fix(od): preserve canonical precision for f16/bf16 float formats
Remove trimming of trailing zeros from f16 and bf16 float representations
in od output to maintain original precision and align behavior with
f32/f64 formatters, ensuring stable output across platforms. Update
corresponding tests to reflect the change in expected output.
* refactor(od): simplify float padding format and update tests
- Remove redundant `width = width` parameter from `format!` macro in `pad_float_repr`
- Add "bfloat" to spell-checker ignore list for better test coverage on bf16 format
* feat(od): trim trailing zeros in float outputs for GNU compatibility
Add `trim_trailing_zeros` function to remove trailing zeros and redundant decimal points from formatted floats, ensuring compact output matching GNU od for f16 and bf16 types. Update `format_item_f16` and `format_item_bf16` to apply trimming before padding.
* fix: preserve trailing zeros in F16 and BF16 float formats to match GNU od output
Remove the `trim_trailing_zeros` function and update `format_item_f16` and `format_item_bf16` to keep the raw formatted strings without trimming trailing zeros. This ensures consistent column widths and aligns with GNU od behavior for 16-bit float representations, preventing misalignment in output tables.
* refactor(od/prn_float): combine multiline format! into single line in format_item_f16
The format! macro call in format_item_f16 was split across multiple lines with newlines. This change consolidates it into a single line for improved code readability and consistency with similar patterns in the file, without altering the function's output or logic.
* feat(od): trim trailing zeros in half-precision and bfloat16 float outputs
- Add `trim_float_repr` function to remove unnecessary trailing zeros and padding from normalized float strings, leaving exponents unchanged.
- Update `format_item_f16` and `format_item_bf16` to apply trimming while maintaining column alignment via re-padding.
- Update test expectations to reflect the more compact float representations (e.g., "1" instead of "1.0000000").
* refactor: simplify float trimming condition in prn_float.rs
Replace `if let Some(_) = s.find('.')` with `s.find('.').is_some()` in the `trim_float_repr` function to improve code clarity and idiomatic Rust usage while maintaining the same logic for checking decimal presence=black.
* Update src/uu/od/src/prn_float.rs
Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
---------
Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
* feat: Add support for long double floating-point numbers and refine general float formatting.
* feat: Enhance `od` error reporting for file I/O, width, and offset parsing, including overflow detection and input validation.
* feat: Improve long double parsing by converting f128 to f64, enhance overflow error reporting with `libc::ERANGE`, and prevent final offset printing on input errors.
* style: Apply minor formatting adjustments across the `od` module.
* refactor: simplify float formatting logic and update string handling syntax
* fix: Correct float formatting logic to use decimal for numbers within range and exponential otherwise.
* refactor(test): use helper function in test_calculate_alignment
Replace repetitive assert_eq! calls with a new assert_alignment helper
to improve test readability and reduce code duplication. The helper
encapsulates alignment checks for OutputInfo::calculate_alignment,
making tests clearer and easier to maintain.
* feat(cspell): add ERANGE to jargon wordlist
Added "ERANGE" to the dictionary to prevent spell checker flagging it as a misspelling, as it's a valid errno constant from C libraries.
* feat(od): improve width error handling and subnormal float output
Refactor width option parsing in OdOptions to use i18n-compatible error messages via translate! macro, consolidating redundant error branches for better maintainability. Enhance float formatting for f16 and bf16 by introducing format_binary16_like helper to properly display subnormal values with exponential notation, removing the obsolete format_float_simple function and adding subnormal detection functions for accurate representation in od's output.
* refactor(od): simplify format_item_bf16 by removing redundant variable
Remove unnecessary `value` variable in `format_item_bf16` function, eliminating
a redundant cast and inline `f` directly for clarity and minor efficiency gain.
* fix(od): standardize option names in error messages
Remove hardcoded "--" prefixes from localization strings in en-US.ftl and fr-FR.ftl, replacing with a computed display name that includes "--" and optionally the short form (e.g., "--option" or "--option, -s"). Update parse_bytes_option and read_bytes functions to pass an option_display_name, enabling consistent error message formatting across localizations. Add validation to reject zero width values as invalid arguments. Improves user experience by providing clearer, more consistent option references in error outputs.
* refactor: condense format! macro in format_item_bf16 for readability
Removed unnecessary line breaks in the format! expression, keeping the code more concise while maintaining functionality. This improves code style in the float printing module.
* fix(od): add external quoting for filenames in error messages
The MultifileReader now uses `fname.maybe_quote().external(true)` when displaying permission and I/O errors, ensuring filenames are properly quoted for user-facing output (e.g., handling special characters that might confuse shells). This prevents potential issues with filename display in error logs.
* refactor(od): Rename f128_to_f64 to u128_to_f64 for clarity
Renamed the function in input_decoder.rs from f128_to_f64 to u128_to_f64
to accurately reflect its purpose of converting u128 integer bits to f64,
improving code readability and reducing potential confusion over float types.
* refactor(od): simplify error handling in OdOptions using combinators
Use map_err and the try operator to replace a verbose match statement,
making the code more concise and idiomatic Rust. This improves readability
without altering functionality.
* Update src/uu/od/src/od.rs
Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
* Update src/uu/od/src/od.rs
Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
* Update src/uu/od/src/parse_inputs.rs
Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
* Update src/uu/od/src/od.rs
Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
* Update src/uu/od/src/parse_inputs.rs
Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
* Update src/uu/od/src/parse_inputs.rs
Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
* refactor(od): remove leaking from translated error messages in parse_offset_operand
Eliminated use of `.leak()` and unnecessary `.to_string()` calls on translated error strings in the `parse_offset_operand` function. This simplifies error handling, improves memory safety by avoiding intentional leaks, and makes the code cleaner without functional changes.
---------
Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
* fix(seq): handle BrokenPipe like GNU
* test: add Unix-specific test for seq command broken pipe handling
- Ensures seq exits gracefully with code 0 and reports "Broken pipe" error on stderr when stdout pipe is prematurely closed
- Validates correct behavior for common scenario where output is piped to commands like head that terminate early
* refactor(test): translate Japanese comment to English in test_seq.rs
- Updated a comment in the test for broken pipe behavior to use English instead of Japanese, enhancing readability for non-Japanese speakers and aligning with project standards. No functional changes to the test logic.
* Implemented saved state parser for stty
* Add compatibility to macos flag type
* Added many example state parsing integration tests with GNU compatibility checks and documentation
* Spelling and formatting fixes
* Matching behaviour of adding the help command after invocations and spelling fixes
* GNU tests were being skipped because they were not at the sufficient version
* Fixed messaging error for invalid states to not show full path
* Normalizing the test output and reverting lib change
* Discovered that the limit depends on platform specific values derived from a LIBC value
* Spelling fixes and setting flags to 0 for cross platform compatibility
* Clippy fixes
* Disabling tests due to invalid printing of control chars and using GNU for printing
* Redisabling failing test as outside of the scope of this PR
* Adding g prefix support to normalize stderr
* Spell checker fixes
* Normalizing command for both gnu and uutils output
* removing single value from testing since it can be interpreted as Baud rate
* Fixing spelling mistake
Add shared CPU hardware capability detection in uucore to prevent
code duplication across utilities. This provides a unified interface
for detecting CPU features (AVX512, AVX2, PCLMUL, SSE2, ASIMD) and
respecting GLIBC_TUNABLES environment variable.
This unblocks PR #9088 (cksum --debug) and PR #9144 (wc --debug) by
providing a common implementation that both utilities can use.
Features:
- CPU feature detection with caching (singleton pattern)
- GLIBC_TUNABLES parsing for hwcaps restrictions
- Cross-platform support (x86/x86_64, aarch64)
- Comprehensive test coverage
- Zero-cost abstractions using std::arch
Implementation details:
- Uses std::arch feature detection (no external deps for detection)
- Adds cfg-if dependency for conditional compilation
- Feature-gated behind "hardware" feature flag
- Android excluded (no CPUID access in sandboxed environment)
Related: #9088, #9144