Skip to content

tr: check a complemented SET1 the way GNU does - #15009

Open
Socialpranker wants to merge 1 commit into
uutils:mainfrom
Socialpranker:tr-complement-check-order
Open

Socialpranker wants to merge 1 commit into
uutils:mainfrom
Socialpranker:tr-complement-check-order

Conversation

@Socialpranker

Copy link
Copy Markdown
Contributor

With -c, uutils checks SET2's [:upper:]/[:lower:] against positions in SET1, but a complemented SET1 has no such positions. It also reports the complement rule before the "longer than SET2" rule. Found by diffing against GNU 9.12:

$ echo AbC1z | tr -c '[:upper:]' '[:lower:]'
tr: when translating with string1 longer than string2,     # GNU
the latter string must not end with a character class
tr: when translating with complemented character classes,  # uutils
string2 must map all characters in the domain to one

$ echo AbC1z | tr -c '\000-\377' '[:upper:]'
AbC1z                                                      # GNU
tr: when translating, every 'upper'/'lower' in set2 must   # uutils
be matched by a 'upper'/'lower' in the same position in set1

The fix skips the alignment check under -c and runs the complement check after the length check. Tests added in test_tr.rs.

@xtqqczze

xtqqczze commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator

@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown

GNU testsuite comparison:

Congrats! The gnu test tests/id/setgid is no longer failing!

This branch has not been deployed

No deployments
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