[hackers] [sbase][PATCH] tr: fix behavior of cflag when using character classes

From: <noneofyourbusiness_AT_danwin1210.de>
Date: Sun, 6 Aug 2023 22:50:25 +0200

From: noneofyourbusiness <noneofyourbusiness_AT_danwin1210.de>

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_AT_danwin1210.de>
---
 tr.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/tr.c b/tr.c
index c5dbe7e..c96dbdd 100644
--- a/tr.c
+++ b/tr.c
_AT_@ -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);
-- 
2.41.0
Received on Sun Aug 06 2023 - 22:50:25 CEST

This archive was generated by hypermail 2.3.0 : Mon Aug 07 2023 - 18:12:50 CEST