summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2005-12-14 22:46:02 +0000
committerPaul Eggert <eggert@cs.ucla.edu>2005-12-14 22:46:02 +0000
commit56805cd20232d0065be1091df04969c5597d75b1 (patch)
tree2df6c6abbfd5618dfe1f5a489f179009b33fa88b /src
parentce1be021a75b31e21e554e3dca0c492e909852c3 (diff)
downloadcoreutils-56805cd20232d0065be1091df04969c5597d75b1.tar.xz
(check_ordering_compatibility): New function.
(main): Use it.
Diffstat (limited to 'src')
-rw-r--r--src/sort.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/sort.c b/src/sort.c
index a778b7bf8..e887a6dbb 100644
--- a/src/sort.c
+++ b/src/sort.c
@@ -2034,6 +2034,39 @@ insertkey (struct keyfield *key)
key->next = NULL;
}
+/* Check compatibility of ordering options. */
+
+static void
+check_ordering_compatibility (void)
+{
+ struct keyfield const *key;
+
+ for (key = keylist; key; key = key->next)
+ if ((1 < (key->random + key->numeric + key->general_numeric + key->month
+ + !!key->ignore))
+ || (key->random && key->translate))
+ {
+ char opts[7];
+ char *p = opts;
+ if (key->ignore == nondictionary)
+ *p++ = 'd';
+ if (key->translate)
+ *p++ = 'f';
+ if (key->general_numeric)
+ *p++ = 'g';
+ if (key->ignore == nonprinting)
+ *p++ = 'i';
+ if (key->month)
+ *p++ = 'M';
+ if (key->numeric)
+ *p++ = 'n';
+ if (key->random)
+ *p++ = 'R';
+ *p = '\0';
+ error (SORT_FAILURE, 0, _("options `-%s' are incompatible"), opts);
+ }
+}
+
/* Report a bad field specification SPEC, with extra info MSGID. */
static void badfieldspec (char const *, char const *)
@@ -2510,6 +2543,8 @@ main (int argc, char **argv)
need_random |= gkey.random;
}
+ check_ordering_compatibility ();
+
reverse = gkey.reverse;
if (need_random)