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

@ -470,7 +470,7 @@ extern int BSDopterr;
extern int BSDoptind;
extern int BSDoptopt;
extern int BSDoptreset;
extern const char *BSDoptarg;
extern char *BSDoptarg;
int BSDgetopt(int, char *const *, const char *);
#define getopt(ac, av, o) BSDgetopt(ac, av, o)
#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 optopt = '?'; /* character checked for validity */
int optreset; /* reset getopt */
const char *optarg; /* argument associated with option */
char *optarg; /* argument associated with option */
#define PRINT_ERROR ((opterr) && (*options != ':'))
@ -134,7 +134,7 @@ const char *optarg; /* argument associated with option */
#define BADARG ((*options == ':') ? (int)':' : (int)'?')
#define INORDER (int)1
#define EMSG ""
#define EMSG (char *)""
static int getopt_internal(int, char * const *, const char *,
const struct option *, int *, int);
@ -143,7 +143,7 @@ static int parse_long_options(char * const *, const char *,
static int gcd(int, int);
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 */
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,
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;
int i, match;