optarg should be "extern char *" not "extern const char *".

This commit is contained in:
Nicholas Marriott
2025-05-01 07:53:02 +01:00
parent 1905afb3d8
commit 6cc1a607fc
2 changed files with 9 additions and 9 deletions

View File

@ -466,11 +466,11 @@ int utf8proc_wctomb(char *, wchar_t);
#endif #endif
/* getopt.c */ /* getopt.c */
extern int BSDopterr; extern int BSDopterr;
extern int BSDoptind; extern int BSDoptind;
extern int BSDoptopt; extern int BSDoptopt;
extern int BSDoptreset; extern int BSDoptreset;
extern const char *BSDoptarg; extern char *BSDoptarg;
int BSDgetopt(int, char *const *, const char *); int BSDgetopt(int, char *const *, const char *);
#define getopt(ac, av, o) BSDgetopt(ac, av, o) #define getopt(ac, av, o) BSDgetopt(ac, av, o)
#define opterr BSDopterr #define opterr BSDopterr

View File

@ -121,7 +121,7 @@ int opterr = 1; /* if error message should be printed */
int optind = 1; /* index into parent argv vector */ int optind = 1; /* index into parent argv vector */
int optopt = '?'; /* character checked for validity */ int optopt = '?'; /* character checked for validity */
int optreset; /* reset getopt */ int optreset; /* reset getopt */
const char *optarg; /* argument associated with option */ char *optarg; /* argument associated with option */
#define PRINT_ERROR ((opterr) && (*options != ':')) #define PRINT_ERROR ((opterr) && (*options != ':'))
@ -134,7 +134,7 @@ const char *optarg; /* argument associated with option */
#define BADARG ((*options == ':') ? (int)':' : (int)'?') #define BADARG ((*options == ':') ? (int)':' : (int)'?')
#define INORDER (int)1 #define INORDER (int)1
#define EMSG "" #define EMSG (char *)""
static int getopt_internal(int, char * const *, const char *, static int getopt_internal(int, char * const *, const char *,
const struct option *, int *, int); const struct option *, int *, int);
@ -143,7 +143,7 @@ static int parse_long_options(char * const *, const char *,
static int gcd(int, int); static int gcd(int, int);
static void permute_args(int, int, int, char * const *); static void permute_args(int, int, int, char * const *);
static const char *place = EMSG; /* option letter processing */ static char *place = EMSG; /* option letter processing */
/* XXX: set optreset to 1 rather than these two */ /* XXX: set optreset to 1 rather than these two */
static int nonopt_start = -1; /* first non option argument (for permute) */ static int nonopt_start = -1; /* first non option argument (for permute) */
@ -221,7 +221,7 @@ static int
parse_long_options(char * const *nargv, const char *options, parse_long_options(char * const *nargv, const char *options,
const struct option *long_options, int *idx, int short_too) const struct option *long_options, int *idx, int short_too)
{ {
const char *current_argv, *has_equal; char *current_argv, *has_equal;
size_t current_argv_len; size_t current_argv_len;
int i, match; int i, match;