]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
(check_ordering_compatibility): New function.
authorPaul Eggert <eggert@cs.ucla.edu>
Wed, 14 Dec 2005 22:46:02 +0000 (22:46 +0000)
committerPaul Eggert <eggert@cs.ucla.edu>
Wed, 14 Dec 2005 22:46:02 +0000 (22:46 +0000)
(main): Use it.

src/sort.c

index a778b7bf8772ee7ed6588702c75e57e466dcb906..e887a6dbbd1063a11e3ad6f5a4d6dbf8ca26dcf2 100644 (file)
@@ -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)