Repository navigation
Conversation
|
GNU testsuite comparison: |
Merging this PR will not alter performance1 warning
Comparing Footnotes
|
|
As no human would write such duplication of code, i guess it is LLM generated ... |
There was a problem hiding this comment.
In the newly added tests you always use -m or -cm. However, this means only your changes in count_fast.rs are tested due to the logic in word_count_from_reader in wc.rs. To test your changes in wc.rs you also have to provide -w or -L.
|
sr, refactored 💀 |
d906c13 to
1ed5ccd
Compare
| @@ -616,11 +617,21 @@ fn process_chunk< | |||
| total.lines += 1; | |||
| } | |||
| if SHOW_CHARS { | |||
| total.chars += 1; | |||
| if chars_are_bytes { | |||
There was a problem hiding this comment.
seriously ?!
please review your patches before substitutions ...
There was a problem hiding this comment.
i thought clippy had the ability to check for empty if :v
|
GNU testsuite comparison: |
1ed5ccd to
bf04096
Compare
|
GNU testsuite comparison: |
|
GNU testsuite comparison: |
224212a to
3eb470f
Compare
|
GNU testsuite comparison: |
|
|
||
| /// Check if the current locale is C or POSIX (where characters == bytes). | ||
| /// This follows GNU coreutils behavior where MB_CUR_MAX == 1 in these locales. | ||
| pub(crate) fn is_c_or_posix_locale() -> bool { |
There was a problem hiding this comment.
We have two functions already doing this:
- src/uucore/src/lib/features/i18n/charmap.rs:33 - inside get_encoding(), uses the same ["LC_ALL", "LC_CTYPE", "LANG"] lookup and the same "C"/"POSIX" short-circuit. Not exposed as a
public helper. - src/uu/uniq/src/uniq.rs:189 - Uniq::is_c_locale(), a private method with the identical env
lookup, used for the exact same purpose (chars==bytes in C/POSIX).
maybe dedup this?
|
tks, i wasn't sure how broad you wanted the dedup to be The latest commit adds a shared helper in |
| /// | ||
| /// Empty values are ignored, matching the locale precedence used for character | ||
| /// map detection. | ||
| pub fn get_effective_ctype_locale() -> Option<String> { |
There was a problem hiding this comment.
does it need to be pub ?
There was a problem hiding this comment.
this doesn't need to be pub, only the boolean helper is used outside this module, so will make the raw locale lookup private
32cccc9 to
3effba3
Compare
3effba3 to
2b823e4
Compare
88c7571 to
2e332a9
Compare
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.
| if COUNT_CHARS { | ||
| total.chars += if simd_allowed { | ||
| bytecount::num_chars(&buf[..n]) | ||
| if chars_are_bytes { |
There was a problem hiding this comment.
could be a single if chars_are_bytes { n } else if simd_allowed { .. } else { .. }, and drop the duplicated comment
| let mut in_word = false; | ||
| let mut current_len = 0; | ||
| let is_posixly_correct = *IS_POSIXLY_CORRECT; | ||
| let chars_are_bytes = SHOW_CHARS && locale_encoding() == Encoding::SingleByte; |
There was a problem hiding this comment.
chars_are_bytes already includes SHOW_CHARS, so do we still need the new generic on handle_error?
|
|
||
| #[test] | ||
| fn test_utf8() { | ||
| // Requires UTF-8 locale for character counting |
There was a problem hiding this comment.
same comment 11 times, please remove them :)
| } | ||
|
|
||
| #[test] | ||
| #[cfg_attr(wasi_runner, ignore = "WASI has no native C/POSIX locale")] |
There was a problem hiding this comment.
why ignore on wasi? the runner forwards LC_ALL via --env, so this should pass there too
There was a problem hiding this comment.
i missed the --env forwarding, iwll remove the ignore and let WASI CI verify
| #[cfg_attr(wasi_runner, ignore = "WASI has no native C/POSIX locale")] | ||
| fn test_wc_chars_default_locale() { | ||
| // When no locale is set (empty LC_ALL), it defaults to POSIX (chars == bytes) | ||
| // This ensures backward compatibility |
There was a problem hiding this comment.
this isn't backward compatibility, it changes the default behavior
|
|
||
| #[test] | ||
| #[cfg_attr(wasi_runner, ignore = "WASI has no native C/POSIX locale")] | ||
| fn test_wc_multibyte_c_locale() { |
There was a problem hiding this comment.
mostly duplicates test_wc_chars_c_locale, could you merge them into one loop over inputs?
|
thanks for the update! |
2e332a9 to
d4fce06
Compare
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.
d4fce06 to
8cab248
Compare
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.
8cab248 to
a40113f
Compare
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.
- Count bytes instead of UTF-8 characters for wc -m in C/POSIX (single-byte) locales, matching GNU coreutils. - Cover both the fast path (count_fast.rs) and the decoder path (wc.rs), including invalid byte sequences in single-byte locales. - Leave UTF-8 invalid-byte handling and wc -L unchanged. - Add byte-exact regression tests with explicit locales for both paths. Fixes uutils#9712. Refs uutils#5831.
a40113f to
49cd7ea
Compare
Fix
wc -mto count bytes as characters in C/POSIX locales, matching GNU coreutils.uucorelocale encoding detection.tests:
Add regression tests for C/POSIX and UTF-8 locales, covering both counting paths (
-mand-wm) and invalid byte sequences.Fixes #9712
Refs #5831