mirror of
https://github.com/GOSTSec/sgminer
synced 2025-02-11 06:25:18 +00:00
VS2010 build: ccan/opt
Cherry-picked by veox.
This commit is contained in:
parent
84eefc74cd
commit
5ce16a44db
@ -11,7 +11,7 @@
|
|||||||
/* FIXME: asprintf module? */
|
/* FIXME: asprintf module? */
|
||||||
static char *arg_bad(const char *fmt, const char *arg)
|
static char *arg_bad(const char *fmt, const char *arg)
|
||||||
{
|
{
|
||||||
char *str = malloc(strlen(fmt) + strlen(arg));
|
char *str = (char *)malloc(strlen(fmt) + strlen(arg));
|
||||||
sprintf(str, fmt, arg);
|
sprintf(str, fmt, arg);
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
@ -74,7 +74,11 @@ char *opt_set_floatval(const char *arg, float *f)
|
|||||||
char *endp;
|
char *endp;
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
|
#if (_MSC_VER >= 1800)
|
||||||
*f = strtof(arg, &endp);
|
*f = strtof(arg, &endp);
|
||||||
|
#else
|
||||||
|
*f = strtod(arg, &endp);
|
||||||
|
#endif
|
||||||
if (*endp || !arg[0])
|
if (*endp || !arg[0])
|
||||||
return arg_bad("'%s' is not a number", arg);
|
return arg_bad("'%s' is not a number", arg);
|
||||||
if (errno)
|
if (errno)
|
||||||
|
@ -152,7 +152,7 @@ static void check_opt(const struct opt_table *entry)
|
|||||||
|
|
||||||
static void add_opt(const struct opt_table *entry)
|
static void add_opt(const struct opt_table *entry)
|
||||||
{
|
{
|
||||||
opt_table = realloc(opt_table, sizeof(opt_table[0]) * (opt_count+1));
|
opt_table = (struct opt_table *)realloc(opt_table, sizeof(opt_table[0]) * (opt_count + 1));
|
||||||
opt_table[opt_count++] = *entry;
|
opt_table[opt_count++] = *entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -202,19 +202,19 @@ bool opt_parse(int *argc, char *argv[], void (*errlog)(const char *fmt, ...))
|
|||||||
int ret;
|
int ret;
|
||||||
unsigned offset = 0;
|
unsigned offset = 0;
|
||||||
|
|
||||||
#ifdef WIN32
|
#if defined(WIN32) && !defined(_MSC_VER)
|
||||||
char *original_argv0 = argv[0];
|
char *original_argv0 = argv[0];
|
||||||
argv[0] = (char*)basename(argv[0]);
|
argv[0] = (char*)basename(argv[0]);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* This helps opt_usage. */
|
/* This helps opt_usage. */
|
||||||
opt_argv0 = argv[0];
|
opt_argv0 = argv[0];
|
||||||
|
|
||||||
while ((ret = parse_one(argc, argv, &offset, errlog)) == 1);
|
while ((ret = parse_one(argc, argv, &offset, errlog)) == 1);
|
||||||
|
|
||||||
#ifdef WIN32
|
#if defined(WIN32) && !defined(_MSC_VER)
|
||||||
argv[0] = original_argv0;
|
argv[0] = original_argv0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* parse_one returns 0 on finish, -1 on error */
|
/* parse_one returns 0 on finish, -1 on error */
|
||||||
return (ret == 0);
|
return (ret == 0);
|
||||||
@ -249,7 +249,7 @@ void opt_log_stderr_exit(const char *fmt, ...)
|
|||||||
|
|
||||||
char *opt_invalid_argument(const char *arg)
|
char *opt_invalid_argument(const char *arg)
|
||||||
{
|
{
|
||||||
char *str = malloc(sizeof("Invalid argument '%s'") + strlen(arg));
|
char *str = (char *)malloc(sizeof("Invalid argument '%s'") + strlen(arg));
|
||||||
sprintf(str, "Invalid argument '%s'", arg);
|
sprintf(str, "Invalid argument '%s'", arg);
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
#include "private.h"
|
#include "private.h"
|
||||||
|
|
||||||
/* We only use this for pointer comparisons. */
|
/* We only use this for pointer comparisons. */
|
||||||
const char opt_hidden[1];
|
const char opt_hidden[1] = { 0 };
|
||||||
|
|
||||||
static unsigned write_short_options(char *str)
|
static unsigned write_short_options(char *str)
|
||||||
{
|
{
|
||||||
@ -33,7 +33,7 @@ char *opt_usage(const char *argv0, const char *extra)
|
|||||||
for (i = 0; i < opt_count; i++) {
|
for (i = 0; i < opt_count; i++) {
|
||||||
if (opt_table[i].cb == (void *)opt_usage_and_exit
|
if (opt_table[i].cb == (void *)opt_usage_and_exit
|
||||||
&& opt_table[i].u.carg) {
|
&& opt_table[i].u.carg) {
|
||||||
extra = opt_table[i].u.carg;
|
extra = (const char *)opt_table[i].u.carg;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -61,7 +61,7 @@ char *opt_usage(const char *argv0, const char *extra)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
p = ret = malloc(len);
|
p = ret = (char *)malloc(len);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user