summaryrefslogtreecommitdiff
path: root/src/sort.c
diff options
context:
space:
mode:
authorAssaf Gordon <assafgordon@gmail.com>2016-05-31 20:19:38 -0400
committerAssaf Gordon <assafgordon@gmail.com>2016-05-31 21:29:52 -0400
commit6223bf94bfeac75fb4252095864a80545ba00a0d (patch)
tree6f6c6c499f3c711bc4bc01a9fdf675d0fbf001cd /src/sort.c
parentd548f87595a193e21b170368bc8fc2ded4dadb73 (diff)
downloadcoreutils-6223bf94bfeac75fb4252095864a80545ba00a0d.tar.xz
sort: modify 'leading spaces' debug warning scenarios
Print warning regardless of locale, avoid warning if key is zero width. Problem reported by Karl Berry in http://bugs.gnu.org/23665 . * src/sort.c: (key_warnings): change conditions for 'leading spaces' warning. * tests/misc/sort-debug-warn.sh: adjust tests accordingly.
Diffstat (limited to 'src/sort.c')
-rw-r--r--src/sort.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/sort.c b/src/sort.c
index aa52b7569..f717604ca 100644
--- a/src/sort.c
+++ b/src/sort.c
@@ -2424,16 +2424,15 @@ key_warnings (struct keyfield const *gkey, bool gkey_only)
}
/* Warn about field specs that will never match. */
- if (key->sword != SIZE_MAX && key->eword < key->sword)
+ bool zero_width = key->sword != SIZE_MAX && key->eword < key->sword;
+ if (zero_width)
error (0, 0, _("key %lu has zero width and will be ignored"), keynum);
/* Warn about significant leading blanks. */
bool implicit_skip = key_numeric (key) || key->month;
- bool maybe_space_aligned = !hard_LC_COLLATE && default_key_compare (key)
- && !(key->schar || key->echar);
bool line_offset = key->eword == 0 && key->echar != 0; /* -k1.x,1.y */
- if (!gkey_only && tab == TAB_DEFAULT && !line_offset
- && ((!key->skipsblanks && !(implicit_skip || maybe_space_aligned))
+ if (!zero_width && !gkey_only && tab == TAB_DEFAULT && !line_offset
+ && ((!key->skipsblanks && !implicit_skip)
|| (!key->skipsblanks && key->schar)
|| (!key->skipeblanks && key->echar)))
error (0, 0, _("leading blanks are significant in key %lu; "