Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/uu/ptx/src/ptx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,18 @@ fn create_word_set(config: &Config, filter: &WordFilter, file_map: &FileMap) ->
};
// match words with given regex
for mat in reg.find_iter(line) {
// GNU-compatible default behavior: ignore non-alphabetic starts
// when no explicit word-regexp was provided.
if filter.word_regex == Config::default().context_regex {
if !&line[mat.start()..mat.end()]
.chars()
.next()
.is_some_and(char::is_alphabetic)
Comment thread
Xylphy marked this conversation as resolved.
Outdated
{
continue;
}
}

let (beg, end) = (mat.start(), mat.end());
if config.input_ref && ((beg, end) == (ref_beg, ref_end)) {
continue;
Expand Down
10 changes: 10 additions & 0 deletions tests/by-util/test_ptx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,16 @@ fn test_unicode_padding_alignment() {
.stdout_only(" a\n é\n");
}

#[test]
fn test_gnu_compat_numeric_token_with_emoji_produces_no_index() {
// GNU ptx produces no output for this input in default mode.
new_ucmd!()
.pipe_in("012345678901234567890123456789🛠\n")
.succeeds()
.stdout_only("")
.no_stderr();
Comment thread
Xylphy marked this conversation as resolved.
Outdated
}

#[test]
fn test_unicode_truncation_alignment() {
new_ucmd!()
Expand Down
Loading