[hackers] [PATCH 2/3][sbase] sort: Don't do top-level sort when -k is used

From: Richard Ipsum <richardipsum_AT_vx21.xyz>
Date: Tue, 31 Dec 2019 19:50:59 +0000

---
 sort.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/sort.c b/sort.c
index 941b694..e974011 100644
--- a/sort.c
+++ b/sort.c
_AT_@ -196,7 +196,8 @@ slinecmp(struct line *a, struct line *b)
 			x = strtod(col1.line.data, NULL);
 			y = strtod(col2.line.data, NULL);
 			res = (x < y) ? -1 : (x > y);
-		} else if (kd->flags & (MOD_D | MOD_F | MOD_I)) {
+		} else if ((kd->flags & MOD_D) | (kd->flags & MOD_F) |
+		           (kd->flags & MOD_I)) {
 			res = skipmodcmp(&col1.line, &col2.line, kd->flags);
 		} else {
 			res = linecmp(&col1.line, &col2.line);
_AT_@ -386,10 +387,13 @@ main(int argc, char *argv[])
 		usage();
 	} ARGEND
 
-	/* -b shall only apply to custom key definitions */
-	if (TAILQ_EMPTY(&kdhead) && global_flags)
-		addkeydef("1", global_flags & ~(MOD_STARTB | MOD_ENDB));
-	addkeydef("1", global_flags & MOD_R);
+	if (TAILQ_EMPTY(&kdhead)) {
+		if (global_flags) {
+			/* -b shall only apply to custom key definitions */
+			addkeydef("1", global_flags & ~(MOD_STARTB | MOD_ENDB));
+		}
+		addkeydef("1", global_flags & MOD_R);
+	}
 
 	if (!argc) {
 		if (Cflag || cflag) {
-- 
2.24.1
Received on Tue Dec 31 2019 - 20:50:59 CET

This archive was generated by hypermail 2.3.0 : Tue Dec 31 2019 - 21:24:24 CET