switch to getopt - iomenu - interactive terminal-based selection menu HTML git clone git://bitreich.org/iomenu git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/iomenu DIR Log DIR Files DIR Refs DIR Tags DIR README DIR LICENSE --- DIR commit d6c740ae9f36ae68149a9c438664213aaff06e97 DIR parent 7ffa2976a3b8c78a0eb5a4158d9dc7528d563c73 HTML Author: Josuah Demangeon <mail@josuah.net> Date: Thu, 8 Mar 2018 15:57:21 +0100 switch to getopt Diffstat: M iomenu.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) --- DIR diff --git a/iomenu.c b/iomenu.c @@ -10,6 +10,7 @@ #include <string.h> #include <termios.h> #include <unistd.h> +#include <getopt.h> #include "utf8.h" #include "str.h" @@ -398,16 +399,13 @@ usage(void) exit(EXIT_FAILURE); } -/* -** XXX: switch to getopt. -*/ static void parse_opt(int argc, char *argv[]) { - for (argv++, argc--; argc > 0; argv++, argc--) { - if (argv[0][0] != '-') - usage(); - switch ((*argv)[1]) { + int c; + + while ((c = getopt(argc, argv, "#")) != -1) { + switch (c) { case '#': flag_hs = 1; break;