-
Notifications
You must be signed in to change notification settings - Fork 32
Updates #429
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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_andtois_none_orfor clearer logic incd.rsandparse.rs - Comprehensive test coverage additions for
printf,echo, andmoreutilities - 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
moreutility - Added stdin buffering support for multiple
-operands inmore - 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 |
Copilot
AI
Nov 30, 2025
There was a problem hiding this comment.
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.
| /// 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"` | |
| /// |
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 |
Copilot
AI
Nov 30, 2025
There was a problem hiding this comment.
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.
| let header_width = 18; // len("(standard input)") + 4 | |
| let header_width = "(standard input)".len() + 2; // 2 for border padding |
No description provided.