Skip to content

Conversation

@jgarzik
Copy link
Contributor

@jgarzik jgarzik commented Nov 30, 2025

No description provided.

@jgarzik jgarzik requested a review from Copilot November 30, 2025 22:31
@jgarzik jgarzik self-assigned this Nov 30, 2025
@jgarzik jgarzik added the enhancement New feature or request label Nov 30, 2025
Copilot finished reviewing on behalf of jgarzik November 30, 2025 22:32
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR includes multiple updates across different utilities and test files. The main changes include:

  • Refactored is_some_and to is_none_or for clearer logic in cd.rs and parse.rs
  • Comprehensive test coverage additions for printf, echo, and more utilities
  • Complete implementation of floating-point support and POSIX-compliant formatting in printf
  • Fixed escape sequence handling in echo (corrected form-feed and vertical-tab codes)
  • Added MORE environment variable support to more utility
  • Added stdin buffering support for multiple - operands in more
  • Updated MSRV from 1.80.0 to 1.84.0
  • Updated documentation and README to reflect test coverage improvements

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
sh/builtin/cd.rs Refactored condition using is_none_or for better readability
make/src/parser/parse.rs Refactored condition using is_none_or for better readability
display/tests/printf/mod.rs Added comprehensive test suite with 500+ lines covering all printf format specifiers
display/tests/more/mod.rs Added tests for MORE environment variable and helper function
display/tests/echo/mod.rs Expanded test coverage for all escape sequences and edge cases
display/printf.rs Complete rewrite implementing floating-point formats, proper integer formatting, and POSIX compliance
display/more.rs Added MORE env var parsing and stdin buffering for multiple - operands
display/echo.rs Fixed escape sequences and implemented octal escape parsing
clippy.toml Updated MSRV to 1.84.0
README.md Updated test coverage status moving utilities to Stage 3
CONTRIBUTING.md Improved contributing guidelines with better structure and clarity

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


fn format_arg_uint(conv: &ConvSpec, arg: usize) -> Vec<u8> {
format_arg_string(conv, arg.to_string().as_bytes())
/// Format an integer with all POSIX flags applied
Copy link

Copilot AI Nov 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function lacks documentation explaining its purpose, parameters, and return value. Add a doc comment describing the POSIX formatting rules applied, particularly how flags (+, , #, 0, -) interact with width and precision.

Suggested change
/// Format an integer with all POSIX flags applied
/// Formats an integer according to POSIX printf-style rules, applying all relevant flags, width, and precision.
///
/// # Parameters
/// - `conv`: The conversion specifier, containing formatting flags, width, and precision.
/// - `value`: The integer value to format.
/// - `is_signed`: Whether the value should be treated as signed (affects sign display).
/// - `base`: The numeric base for formatting (e.g., 8 for octal, 16 for hexadecimal).
/// - `upper`: If true, hexadecimal digits are uppercase.
///
/// # Return
/// Returns a `Vec<u8>` containing the formatted integer as bytes.
///
/// # POSIX Formatting Rules
/// Applies the following flags and their interactions:
/// - `+` (sign): Always show sign for signed values; overrides space flag.
/// - ` ` (space): Prefix a space for positive signed values if `+` is not specified.
/// - `#` (alternate form): For octal, prefixes with `0`; for hexadecimal, prefixes with `0x` or `0X` (if value is nonzero).
/// - `0` (zero pad): Pads with zeros to fill width, but ignored if precision is specified or if left-justify (`-`) is set.
/// - `-` (left justify): Left-justifies the output within the field width; overrides zero-padding.
/// - `width`: Minimum field width; pads with spaces or zeros as above.
/// - `precision`: Minimum number of digits; pads with zeros to reach precision. If precision is specified, zero-padding (`0`) is ignored.
///
/// The order of output is: sign, prefix (if any), digits (with precision applied), then padding (spaces or zeros) as required by width and flags.
///
/// # Examples
/// - `"%+08x"` with value `42` produces `"+000002a"`
/// - `"%#6o"` with value `10` produces `" 012"`
///

Copilot uses AI. Check for mistakes.
display/more.rs Outdated
println!("{line}");
// Format header differently for stdin vs file
if *file_path == PathBuf::from("-") {
let header_width = 18; // len("(standard input)") + 4
Copy link

Copilot AI Nov 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Magic number 18 is hardcoded with a comment, but the comment calculation is incorrect. "(standard input)" has 16 characters, not 14. Consider computing this dynamically: let header_width = \"(standard input)\".len() + 2; where 2 accounts for the border padding.

Suggested change
let header_width = 18; // len("(standard input)") + 4
let header_width = "(standard input)".len() + 2; // 2 for border padding

Copilot uses AI. Check for mistakes.
@jgarzik jgarzik merged commit de6efb5 into main Nov 30, 2025
4 checks passed
@jgarzik jgarzik deleted the updates branch November 30, 2025 23:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants