From af331a9e7cae7ede8d7af2e4f711230315f8a781 Mon Sep 17 00:00:00 2001 From: Leonid Yuriev Date: Fri, 25 Sep 2020 01:49:01 +0300 Subject: [PATCH] mdbx-tools: fix getopt's messages for windows. Thank to Andrey Sporaw for the reporting. Change-Id: I7531427c48b1a2f5483e2f04175cded2d34062a8 --- src/wingetopt.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/wingetopt.c b/src/wingetopt.c index 7feb223f..4f27d648 100644 --- a/src/wingetopt.c +++ b/src/wingetopt.c @@ -40,14 +40,6 @@ #define EOF (-1) #endif -#define ERR(s, c) \ - if (opterr) { \ - fputs(argv[0], stderr); \ - fputs(s, stderr); \ - fputc(c, stderr); \ - } - -int opterr = 1; int optind = 1; int optopt; char *optarg; @@ -67,7 +59,7 @@ int getopt(int argc, char *const argv[], const char *opts) { } optopt = c = argv[optind][sp]; if (c == ':' || (cp = strchr(opts, c)) == NULL) { - ERR(": illegal option -- ", c); + fprintf(stderr, "%s: %s -- %c\n", argv[0], "illegal option", c); if (argv[optind][++sp] == '\0') { optind++; sp = 1; @@ -78,7 +70,8 @@ int getopt(int argc, char *const argv[], const char *opts) { if (argv[optind][sp + 1] != '\0') optarg = &argv[optind++][sp + 1]; else if (++optind >= argc) { - ERR(": option requires an argument -- ", c); + fprintf(stderr, "%s: %s -- %c\n", argv[0], "option requires an argument", + c); sp = 1; return '?'; } else