]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
column: use err_exclusive_options()
authorKarel Zak <kzak@redhat.com>
Mon, 6 Mar 2017 11:09:59 +0000 (12:09 +0100)
committerKarel Zak <kzak@redhat.com>
Tue, 2 May 2017 10:18:00 +0000 (12:18 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
text-utils/column.c

index 14123643f3496ed800abe3f0edb4c5f0ea1a1a56..f38c6932dd1ac6cdaa90263dcb56f62de29e6ed8 100644 (file)
@@ -51,6 +51,7 @@
 #include "closestream.h"
 #include "ttyutils.h"
 #include "strv.h"
+#include "optutils.h"
 
 #include "libsmartcols.h"
 
@@ -388,7 +389,7 @@ int main(int argc, char **argv)
                .termwidth = 80
        };
 
-       int ch;
+       int c;
        unsigned int eval = 0;          /* exit value */
 
        static const struct option longopts[] =
@@ -406,6 +407,12 @@ int main(int argc, char **argv)
                { "version",             no_argument,       NULL, 'V' },
                { NULL, 0, NULL, 0 },
        };
+       static const ul_excl_t excl[] = {       /* rows and cols in ASCII order */
+               { 'J','x' },
+               { 't','x' },
+               { 0 }
+       };
+       int excl_st[ARRAY_SIZE(excl)] = UL_EXCL_STATUS_INIT;
 
        setlocale(LC_ALL, "");
        bindtextdomain(PACKAGE, LOCALEDIR);
@@ -416,8 +423,11 @@ int main(int argc, char **argv)
        ctl.output_separator = "  ";
        ctl.input_separator = mbs_to_wcs("\t ");
 
-       while ((ch = getopt_long(argc, argv, "hVc:Jn:N:s:txo:", longopts, NULL)) != -1)
-               switch(ch) {
+       while ((c = getopt_long(argc, argv, "hVc:Jn:N:s:txo:", longopts, NULL)) != -1) {
+
+               err_exclusive_options(c, longopts, excl, excl_st);
+
+               switch(c) {
                case 'J':
                        ctl.json = 1;
                        ctl.mode = COLUMN_MODE_TABLE;
@@ -453,6 +463,7 @@ int main(int argc, char **argv)
                        break;
                default:
                        errtryhelp(EXIT_FAILURE);
+               }
        }
        argc -= optind;
        argv += optind;