+
Skip to content

Conversation

sylvestre
Copy link
Contributor

should fix tests/od/od-N

Copy link

github-actions bot commented Oct 8, 2025

GNU testsuite comparison:

Skipping an intermittent issue tests/misc/tee (passes in this run but fails in the 'main' branch)
Congrats! The gnu test tests/od/od-N is no longer failing!

@sylvestre sylvestre marked this pull request as ready for review October 9, 2025 05:34
Comment on lines +1007 to +1012
// Test with -S10 to filter out short strings
new_ucmd!()
.arg("-S10")
.pipe_in(b"\x01 \x00 \x00")
.succeeds()
.stdout_is("0000001 \n0000014 \n");
Copy link
Contributor

Choose a reason for hiding this comment

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

There is a disconnect between the comment and the code: there are no short strings in the piped in data that could be filtered out ;-)

sylvestre and others added 2 commits October 9, 2025 09:44
Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
Copy link

github-actions bot commented Oct 9, 2025

GNU testsuite comparison:

Congrats! The gnu test tests/od/od-N is no longer failing!

Comment on lines +1022 to +1028
let expected = format!("0000000 {}\n", " ".repeat(100));
new_ucmd!()
.arg("-N100")
.arg("-S1")
.pipe_in([b' '; 100])
.succeeds()
.stdout_is(&expected);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you could show the same with a single-digit -N value.

translate!("od-error-invalid-argument", "option" => "-S", "value" => s.quote()),
)
})?;
if n == 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

GNU od allows 0:

$ printf "hello\x0world\x0" | od -S0
0000000 hello
0000006 world

Ok(n) => Some(n),
Err(e) => {
Some(s) => {
let n = s.parse::<usize>().map_err(|_| {
Copy link
Contributor

@cakebaker cakebaker Oct 9, 2025

Choose a reason for hiding this comment

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

I think you have to use parse_number_of_bytes here. I think you can use parse_bytes_option to handle options::STRINGS.

line_bytes: usize,
output_duplicates: bool,
radix: Radix,
string_min_length: Option<usize>,
Copy link
Contributor

@cakebaker cakebaker Oct 9, 2025

Choose a reason for hiding this comment

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

Does string_min_length have to be an Option? Probably yes, you seem to use it to mark a "strings mode".

Comment on lines +325 to 326
"output strings of at least BYTES graphic chars. 3 is assumed when \
BYTES is not specified.",
Copy link
Contributor

@cakebaker cakebaker Oct 9, 2025

Choose a reason for hiding this comment

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

Instead of just modifying the string, you could move it to the ftl files and use translate! here.

}

/// String search mode for od -S option
fn strings_mode(
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe there is a better name for this function?

Comment on lines +586 to +596
if radix == Radix::NoPrefix {
println!("{string_content}");
} else {
let offset_str = match radix {
Radix::Decimal => format!("{offset:07}"),
Radix::Hexadecimal => format!("{offset:07x}"),
Radix::Octal => format!("{offset:07o}"),
Radix::NoPrefix => unreachable!(),
};
println!("{offset_str} {string_content}");
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Here it might be an option to do everything in the match to get rid of the unreachable.

Copy link
Contributor

@cakebaker cakebaker left a comment

Choose a reason for hiding this comment

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

Done :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载