diff options
author | Pádraig Brady <P@draigBrady.com> | 2010-05-22 14:19:50 +0100 |
---|---|---|
committer | Pádraig Brady <P@draigBrady.com> | 2010-05-24 12:12:24 +0100 |
commit | 63761c027c6facf80d78834f9f1ee02139b116fe (patch) | |
tree | 4e87127d5af34a356a4807b4d63e55cbdf5f6dce /src | |
parent | fdff32e1834f88363854cefaba10150bff066607 (diff) | |
download | coreutils-63761c027c6facf80d78834f9f1ee02139b116fe.tar.xz |
sort: adjust the leading blanks --debug warning
* src/sort.c (key_warnings): Always warn about significant leading
blanks when character offsets are specified, unless they key is
possibly a line offset, i.e. of the form -k1.x,1.y. Also suppress
this warning if the user could be sorting right aligned indexes.
Diffstat (limited to 'src')
-rw-r--r-- | src/sort.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/sort.c b/src/sort.c index 8a9309aa8..e6cc2c27c 100644 --- a/src/sort.c +++ b/src/sort.c @@ -2261,8 +2261,14 @@ key_warnings (struct keyfield const *gkey, bool gkey_only) error (0, 0, _("key %lu has zero width and will be ignored"), keynum); /* Warn about significant leading blanks. */ - if (!gkey_only && tab == TAB_DEFAULT && !key->skipsblanks - && !key_numeric (key) && !key->month) + 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)) + || (!key->skipsblanks && key->schar) + || (!key->skipeblanks && key->echar))) error (0, 0, _("leading blanks are significant in key %lu; " "consider also specifying `b'"), keynum); |