coreutils/src
Jalil David Salamé Messina 3c47f27698 tr: calculate complement set early
Fixes #6163 and adds a test to verify that a regression is not caused.

Instead of inverting the conditions to check (e.g. delete characters **not** present in set1) invert
set1 when passed the complement flag (`-c`, `-C`, `--complement`). This is done by calculating set1
then "inverting" it by subtracting from the "full" (universe) set (0..=u8::MAX).

This fixes issue 6163 because it was caused by a combination of the `-c` and `-t` flag. `-c` is the
abovementioned complement flag and `-t`/`--truncate-set1` truncates set1 to the length of set2. What
happened in issue 6163 is that `set1={b'Y'}` and `set2={b'Z'}`, when truncated set1 stays the same
and we proceed. The problem is GNU utils does not consider set1 to be `{b'Y'}`, but the complement
of `{b'Y'}`, that is `U \ {b'Y'}={0, 1, ..., b'X', b'Z', ...}`, thus it is truncated to `{0}`.

We can verify this by doing: `printf '\0' | tr -c -t Y Z`, which prints `Z` to stdout as expected.

Additionally, by calculating the complement of set1 we no longer need to consider the complement
flag when doing the translate operation, this allows us to delete a lot of code.
2024-05-04 19:55:49 +02:00
..
bin multicall: add --list to list all utils 2024-04-30 17:26:02 +02:00
uu tr: calculate complement set early 2024-05-04 19:55:49 +02:00
uucore fix(deps): update rust crate wild to 2.2.1 2024-05-03 05:40:58 +00:00
uucore_procs fix(deps): update rust crate proc-macro2 to 1.0.81 2024-05-03 05:41:47 +00:00
uuhelp_parser Try to release 0.0.26 to see if the artifacts are generated 2024-03-30 22:51:24 +01:00