From bb94b560b7aa8e37469913382c0e383a76593c45 Mon Sep 17 00:00:00 2001
From: Assaf Gordon <assafgordon@gmail.com>
Date: Tue, 31 May 2016 20:03:03 -0400
Subject: [PATCH 1/3] sort: clearify 'key' meaning in debug warnings

Avoids possible confusion between sorting keys and input fields.
Suggested by Karl Berry in http://bugs.gnu.org/23665 .

* src/sort.c: (key_warnings): rephrase 'key' to 'sort key' in warning
messages.
* tests/misc/sort-debug-warn.sh: adjust tests accordingly.
---
 src/sort.c                    |  9 +++++----
 tests/misc/sort-debug-warn.sh | 20 ++++++++++----------
 2 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/src/sort.c b/src/sort.c
index aa52b75..72ee995 100644
--- a/src/sort.c
+++ b/src/sort.c
@@ -2419,13 +2419,14 @@ key_warnings (struct keyfield const *gkey, bool gkey_only)
                       umaxtostr (eword + 1
                                  + (key->echar == SIZE_MAX), tmp));
             }
-          error (0, 0, _("obsolescent key %s used; consider %s instead"),
+          error (0, 0, _("obsolescent sort key %s used; consider %s instead"),
                  quote_n (0, obuf), quote_n (1, nbuf));
         }
 
       /* Warn about field specs that will never match.  */
       if (key->sword != SIZE_MAX && key->eword < key->sword)
-        error (0, 0, _("key %lu has zero width and will be ignored"), keynum);
+        error (0, 0, _("sort key %lu has zero width and will be ignored"),
+               keynum);
 
       /* Warn about significant leading blanks.  */
       bool implicit_skip = key_numeric (key) || key->month;
@@ -2436,7 +2437,7 @@ key_warnings (struct keyfield const *gkey, bool gkey_only)
           && ((!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; "
+        error (0, 0, _("leading blanks are significant in sort key %lu; "
                        "consider also specifying 'b'"), keynum);
 
       /* Warn about numeric comparisons spanning fields,
@@ -2449,7 +2450,7 @@ key_warnings (struct keyfield const *gkey, bool gkey_only)
           if (!sword)
             sword++;
           if (!eword || sword < eword)
-            error (0, 0, _("key %lu is numeric and spans multiple fields"),
+            error (0, 0, _("sort key %lu is numeric and spans multiple fields"),
                    keynum);
         }
 
diff --git a/tests/misc/sort-debug-warn.sh b/tests/misc/sort-debug-warn.sh
index a31132d..da86d37 100755
--- a/tests/misc/sort-debug-warn.sh
+++ b/tests/misc/sort-debug-warn.sh
@@ -21,11 +21,11 @@ print_ver_ sort
 
 cat <<\EOF > exp
 sort: using simple byte comparison
-sort: key 1 has zero width and will be ignored
+sort: sort key 1 has zero width and will be ignored
 sort: using simple byte comparison
-sort: key 1 has zero width and will be ignored
+sort: sort key 1 has zero width and will be ignored
 sort: using simple byte comparison
-sort: key 1 is numeric and spans multiple fields
+sort: sort key 1 is numeric and spans multiple fields
 sort: using simple byte comparison
 sort: options '-bghMRrV' are ignored
 sort: using simple byte comparison
@@ -41,12 +41,12 @@ sort: option '-b' is ignored
 sort: using simple byte comparison
 sort: using simple byte comparison
 sort: using simple byte comparison
-sort: leading blanks are significant in key 1; consider also specifying 'b'
+sort: leading blanks are significant in sort key 1; consider also specifying 'b'
 sort: using simple byte comparison
-sort: leading blanks are significant in key 1; consider also specifying 'b'
+sort: leading blanks are significant in sort key 1; consider also specifying 'b'
 sort: option '-d' is ignored
 sort: using simple byte comparison
-sort: leading blanks are significant in key 1; consider also specifying 'b'
+sort: leading blanks are significant in sort key 1; consider also specifying 'b'
 sort: option '-i' is ignored
 sort: using simple byte comparison
 sort: using simple byte comparison
@@ -77,10 +77,10 @@ compare exp out || fail=1
 
 cat <<\EOF > exp
 sort: using simple byte comparison
-sort: key 1 is numeric and spans multiple fields
-sort: obsolescent key '+2 -1' used; consider '-k 3,1' instead
-sort: key 2 has zero width and will be ignored
-sort: leading blanks are significant in key 2; consider also specifying 'b'
+sort: sort key 1 is numeric and spans multiple fields
+sort: obsolescent sort key '+2 -1' used; consider '-k 3,1' instead
+sort: sort key 2 has zero width and will be ignored
+sort: leading blanks are significant in sort key 2; consider also specifying 'b'
 sort: option '-b' is ignored
 sort: option '-r' only applies to last-resort comparison
 EOF
-- 
2.7.0

