kopia lustrzana https://github.com/Hamlib/Hamlib
Fix cppcheck warning in getopt.c removing alloca
rodzic
34e4279a78
commit
7dc98d3b79
25
lib/getopt.c
25
lib/getopt.c
|
@ -22,26 +22,10 @@
|
||||||
*/
|
*/
|
||||||
/* NOTE!!! AIX requires this to be the first thing in the file.
|
/* NOTE!!! AIX requires this to be the first thing in the file.
|
||||||
Do not put ANYTHING before it! */
|
Do not put ANYTHING before it! */
|
||||||
#if !defined (__GNUC__) && defined (_AIX)
|
|
||||||
#pragma alloca
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __GNUC__
|
|
||||||
#define alloca __builtin_alloca
|
|
||||||
#else /* not __GNUC__ */
|
|
||||||
#if defined (HAVE_ALLOCA_H) || (defined(sparc) && (defined(sun) || (!defined(USG) && !defined(SVR4) && !defined(__svr4__))))
|
|
||||||
#include <alloca.h>
|
|
||||||
#else
|
|
||||||
#ifndef _AIX
|
|
||||||
char *alloca();
|
|
||||||
#endif
|
|
||||||
#endif /* alloca.h */
|
|
||||||
#endif /* not __GNUC__ */
|
|
||||||
|
|
||||||
#if !__STDC__ && !defined(const) && IN_GCC
|
#if !__STDC__ && !defined(const) && IN_GCC
|
||||||
#define const
|
#define const
|
||||||
#endif
|
#endif
|
||||||
|
@ -67,12 +51,9 @@ char *alloca();
|
||||||
/* This needs to come after some library #include
|
/* This needs to come after some library #include
|
||||||
to get __GNU_LIBRARY__ defined. */
|
to get __GNU_LIBRARY__ defined. */
|
||||||
#ifdef __GNU_LIBRARY__
|
#ifdef __GNU_LIBRARY__
|
||||||
#undef alloca
|
|
||||||
/* Don't include stdlib.h for non-GNU C libraries because some of them
|
/* Don't include stdlib.h for non-GNU C libraries because some of them
|
||||||
contain conflicting prototypes for getopt. */
|
contain conflicting prototypes for getopt. */
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#else /* Not GNU C library. */
|
|
||||||
#define __alloca alloca
|
|
||||||
#endif /* GNU C library. */
|
#endif /* GNU C library. */
|
||||||
|
|
||||||
/* If GETOPT_COMPAT is defined, `+' as well as `--' can introduce a
|
/* If GETOPT_COMPAT is defined, `+' as well as `--' can introduce a
|
||||||
|
@ -244,7 +225,7 @@ exchange(argv)
|
||||||
char **argv;
|
char **argv;
|
||||||
{
|
{
|
||||||
int nonopts_size = (last_nonopt - first_nonopt) * sizeof(char *);
|
int nonopts_size = (last_nonopt - first_nonopt) * sizeof(char *);
|
||||||
char **temp = (char **) __alloca(nonopts_size);
|
char **temp = (char **) malloc(nonopts_size);
|
||||||
|
|
||||||
/* Interchange the two blocks of data in ARGV. */
|
/* Interchange the two blocks of data in ARGV. */
|
||||||
|
|
||||||
|
@ -259,6 +240,7 @@ char **argv;
|
||||||
|
|
||||||
first_nonopt += (optind - last_nonopt);
|
first_nonopt += (optind - last_nonopt);
|
||||||
last_nonopt = optind;
|
last_nonopt = optind;
|
||||||
|
free(temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Scan elements of ARGV (whose length is ARGC) for option characters
|
/* Scan elements of ARGV (whose length is ARGC) for option characters
|
||||||
|
@ -326,8 +308,6 @@ const struct option *longopts;
|
||||||
int *longind;
|
int *longind;
|
||||||
int long_only;
|
int long_only;
|
||||||
{
|
{
|
||||||
int option_index;
|
|
||||||
|
|
||||||
optarg = 0;
|
optarg = 0;
|
||||||
|
|
||||||
/* Initialize the internal data when the first call is made.
|
/* Initialize the internal data when the first call is made.
|
||||||
|
@ -474,6 +454,7 @@ int long_only;
|
||||||
int ambig = 0;
|
int ambig = 0;
|
||||||
const struct option *pfound = NULL;
|
const struct option *pfound = NULL;
|
||||||
int indfound;
|
int indfound;
|
||||||
|
int option_index;
|
||||||
|
|
||||||
while (*s && *s != '=')
|
while (*s && *s != '=')
|
||||||
{
|
{
|
||||||
|
|
Ładowanie…
Reference in New Issue