8000 l10n: port stat for translation + use thiserror + add french by sylvestre · Pull Request #8243 · uutils/coreutils · GitHub
[go: up one dir, main page]

Skip to content

l10n: port stat for translation + use thiserror + add french #8243

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sylvestre
Copy link
Contributor
  • I had to update the logic to handle french accents (and other chars)

Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/timeout/timeout (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/misc/stdbuf (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/misc/tee (passes in this run but fails in the 'main' branch)

Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/misc/stdbuf (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/timeout/timeout (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/misc/tee (passes in this run but fails in the 'main' branch)

Comment on lines 178 to 180
/// Scans for a number at the beginning of the string
/// Returns the parsed number and the character count (not byte count)
/// This was updated to properly handle UTF-8 by tracking both character and byte counts
Copy link
Contributor
@cakebaker cakebaker Jun 25, 2025

Choose a reason for hiding this comment

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

I thought a bit more about the changes made to this function and somehow it doesn't make much sense to have both character and byte counts. We only deal with ASCII characters (+, -, and 0 - 9) and thus character count and byte count are the same.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, good point!

Copy link

GNU testsuite comparison:

Skipping an intermittent issue tests/timeout/timeout (passes in this run but fails in the 'main' branch)

Comment on lines -152 to -164
let mut i = 0;
let mut count = 0;

match chars.next() {
Some('-' | '+' | '0'..='9') => i += 1,
Some('-' | '+' | '0'..='9') => {
count += 1;
}
_ => return None,
}
for c in chars {
match c {
'0'..='9' => i += 1,
_ => break,
}

for _ in chars.take_while(char::is_ascii_digit) {
count += 1;
}
if i > 0 {
F::from_str(&self[..i]).ok().map(|x| (x, i))
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 can simplify it with something like:

let count = chars
    .next()
    .filter(|&c| c.is_ascii_digit() || c == '-' || c == '+')
    .map(|_| 1 + chars.take_while(char::is_ascii_digit).count())
    .unwrap_or(0);

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
0