From: Alan Cox Date: Tue, 26 Jun 2018 20:25:10 +0000 (+0100) Subject: getopt: Add missing POSIX optopt X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=7eacec73ac5215232e383f79948324d753fa40be;p=FUZIX.git getopt: Add missing POSIX optopt --- diff --git a/Library/include/getopt.h b/Library/include/getopt.h index 374acc54..b0893467 100644 --- a/Library/include/getopt.h +++ b/Library/include/getopt.h @@ -7,6 +7,7 @@ extern char *optarg; extern int opterr; extern int optind; +extern int optopt; extern int getopt(int __argc, char *__argv[], char *__shortopts); diff --git a/Library/include/stdlib.h b/Library/include/stdlib.h index 4d78fb4a..bc944136 100644 --- a/Library/include/stdlib.h +++ b/Library/include/stdlib.h @@ -89,10 +89,7 @@ extern void qsort(void *__base, size_t __num, size_t __size, cmp_func_t __cmp); #define mb_len(a,b) strnlen(a,b) -extern int opterr; -extern int optind; -extern char *optarg; -extern int getopt(int __argc, char *__argv[], char *__optstring); +#include extern char *getpass(char *__prompt); diff --git a/Library/libs/getopt.c b/Library/libs/getopt.c index abbfabd5..c02ef299 100644 --- a/Library/libs/getopt.c +++ b/Library/libs/getopt.c @@ -18,6 +18,7 @@ int opterr = 1; /* error => print message */ int optind = 1; /* next argv[] index */ +int optopt; const char *optarg = NULL; /* option parameter if any */ static int Err(const char *name, const char *mess, int c) @@ -30,6 +31,7 @@ static int Err(const char *name, const char *mess, int c) name, mess, c ); } + optopt = c; return '?'; /* erroneous-option marker */ }