-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
Description
When complementing, we basically translate all bytes not mentioned in STRING1 to bytes in STRING2. This means that only the first 256-len(ARRAYISH1) bytes of ARRAY2 can be accessed.
GNU tr issues a (confusing, but well-intentioned) error message if the command-line argument contains garbage:
$ x230="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
$ echo -n 'hello' | ../gnu/src/tr -c '[:upper:]' "${x230}" # 256-26 times 'x'
xxxxx
$ echo -n 'hello' | ../gnu/src/tr -c '[:upper:]' "${x230}x" # 256-26+1 times 'x'
../gnu/src/tr: when translating with complemented character classes,
string2 must map all characters in the domain to one
[$? = 1]
$ echo -n 'hello' | cargo run tr -c '[:upper:]' "${x230}" # we accidentally treat this correctly
xxxxx
$ echo -n 'hello' | cargo run tr -c '[:upper:]' "${x230}x" # this needs to change
xxxxxComputing the ideal size should be easy, but checking it isn't:
- If we just consider the length of STRING2, then this will obviously fail due to expansions
- I believe there was some reason why checking the length of ARRAY2 didn't work. Hmm. I'm confused.
(Original issue: #6133)