summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/sort.c4
-rwxr-xr-xtests/misc/sort-debug-keys7
2 files changed, 10 insertions, 1 deletions
diff --git a/src/sort.c b/src/sort.c
index 06b0d95a1..13954cbbc 100644
--- a/src/sort.c
+++ b/src/sort.c
@@ -2214,7 +2214,9 @@ debug_key (struct line const *line, struct keyfield const *key)
char *tighter_lim = beg;
- if (key->month)
+ if (lim < beg)
+ tighter_lim = lim;
+ else if (key->month)
getmonth (beg, &tighter_lim);
else if (key->general_numeric)
ignore_value (strtold (beg, &tighter_lim));
diff --git a/tests/misc/sort-debug-keys b/tests/misc/sort-debug-keys
index daa6c18b0..238c33e23 100755
--- a/tests/misc/sort-debug-keys
+++ b/tests/misc/sort-debug-keys
@@ -234,6 +234,10 @@ _
_
>a
_
+A>chr10
+ ^ no match for key
+B>chr1
+ ^ no match for key
EOF
(
@@ -275,6 +279,9 @@ env printf '1a\x002b\x00' | sort -s -n -z --debug
# Check that \0 and \t intermix.
printf '\0\ta\n' | sort -s -k2b,2 --debug | tr -d '\0'
+
+# Check that key end before key start is not underlined
+printf 'A\tchr10\nB\tchr1\n' | sort -s -k2.4b,2.3n --debug
) > out
compare out exp || fail=1