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 <noneofyourbusiness@danwin1210.de>
This commit is contained in:
noneofyourbusiness 2023-08-06 22:50:25 +02:00 committed by Roberto E. Vargas Caballero
parent 0b4c2ceb2f
commit f14887c765
1 changed files with 4 additions and 6 deletions

10
tr.c
View File

@ -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);