commit f14887c76522b3a5d375351b6aa8432430447f6a
Author: noneofyourbusiness <[email protected]>
AuthorDate: Sun Aug 6 22:50:25 2023 +0200
Commit: Roberto E. Vargas Caballero <[email protected]>
CommitDate: Thu Sep 21 15:27:01 2023 +0200
tr: fix behavior of cflag when using character classes
a simple test case:
printf ab3 | tr -c '[:alpha:]' '\n'
output should be ab<newline>, previously you would find just newlines.
Signed-off-by: noneofyourbusiness <[email protected]>
diff --git a/tr.c b/tr.c
index c5dbe7e..c96dbdd 100644
--- a/tr.c
+++ b/tr.c
@@ -250,12 +250,10 @@ read:
}
}
if (set1check && set1check(r)) {
- if (dflag) {
- if (cflag)
- goto write;
- else
- goto read;
- }
+ if (cflag)
+ goto write;
+ if (dflag)
+ goto read;
if (set2check) {
if (set2check == islowerrune)
r = tolowerrune(r);