mirror of
https://github.com/isar/libmdbx.git
synced 2024-12-30 03:14:14 +08:00
mdbx-tools: fix getopt's messages for windows.
Thank to Andrey Sporaw for the reporting. Change-Id: I7531427c48b1a2f5483e2f04175cded2d34062a8
This commit is contained in:
parent
75a4463811
commit
af331a9e7c
@ -40,14 +40,6 @@
|
|||||||
#define EOF (-1)
|
#define EOF (-1)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define ERR(s, c) \
|
|
||||||
if (opterr) { \
|
|
||||||
fputs(argv[0], stderr); \
|
|
||||||
fputs(s, stderr); \
|
|
||||||
fputc(c, stderr); \
|
|
||||||
}
|
|
||||||
|
|
||||||
int opterr = 1;
|
|
||||||
int optind = 1;
|
int optind = 1;
|
||||||
int optopt;
|
int optopt;
|
||||||
char *optarg;
|
char *optarg;
|
||||||
@ -67,7 +59,7 @@ int getopt(int argc, char *const argv[], const char *opts) {
|
|||||||
}
|
}
|
||||||
optopt = c = argv[optind][sp];
|
optopt = c = argv[optind][sp];
|
||||||
if (c == ':' || (cp = strchr(opts, c)) == NULL) {
|
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') {
|
if (argv[optind][++sp] == '\0') {
|
||||||
optind++;
|
optind++;
|
||||||
sp = 1;
|
sp = 1;
|
||||||
@ -78,7 +70,8 @@ int getopt(int argc, char *const argv[], const char *opts) {
|
|||||||
if (argv[optind][sp + 1] != '\0')
|
if (argv[optind][sp + 1] != '\0')
|
||||||
optarg = &argv[optind++][sp + 1];
|
optarg = &argv[optind++][sp + 1];
|
||||||
else if (++optind >= argc) {
|
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;
|
sp = 1;
|
||||||
return '?';
|
return '?';
|
||||||
} else
|
} else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user