From 56805cd20232d0065be1091df04969c5597d75b1 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Wed, 14 Dec 2005 22:46:02 +0000 Subject: [PATCH] (check_ordering_compatibility): New function. (main): Use it. --- src/sort.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/sort.c b/src/sort.c index a778b7bf87..e887a6dbbd 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) -- 2.47.3