1
0
mirror of https://github.com/GOSTSec/sgminer synced 2025-02-05 19:44:21 +00:00

VS2010 build: ccan/opt

Cherry-picked by veox.
This commit is contained in:
Sanjin Trošelj 2014-01-27 18:22:40 +01:00 committed by Noel Maersk
parent 84eefc74cd
commit 5ce16a44db
3 changed files with 14 additions and 10 deletions

View File

@ -11,7 +11,7 @@
/* FIXME: asprintf module? */
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);
return str;
}
@ -74,7 +74,11 @@ char *opt_set_floatval(const char *arg, float *f)
char *endp;
errno = 0;
#if (_MSC_VER >= 1800)
*f = strtof(arg, &endp);
#else
*f = strtod(arg, &endp);
#endif
if (*endp || !arg[0])
return arg_bad("'%s' is not a number", arg);
if (errno)

View File

@ -152,7 +152,7 @@ static void check_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;
}
@ -202,19 +202,19 @@ bool opt_parse(int *argc, char *argv[], void (*errlog)(const char *fmt, ...))
int ret;
unsigned offset = 0;
#ifdef WIN32
#if defined(WIN32) && !defined(_MSC_VER)
char *original_argv0 = argv[0];
argv[0] = (char*)basename(argv[0]);
#endif
#endif
/* This helps opt_usage. */
opt_argv0 = argv[0];
while ((ret = parse_one(argc, argv, &offset, errlog)) == 1);
#ifdef WIN32
#if defined(WIN32) && !defined(_MSC_VER)
argv[0] = original_argv0;
#endif
#endif
/* parse_one returns 0 on finish, -1 on error */
return (ret == 0);
@ -249,7 +249,7 @@ void opt_log_stderr_exit(const char *fmt, ...)
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);
return str;
}

View File

@ -6,7 +6,7 @@
#include "private.h"
/* 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)
{
@ -33,7 +33,7 @@ char *opt_usage(const char *argv0, const char *extra)
for (i = 0; i < opt_count; i++) {
if (opt_table[i].cb == (void *)opt_usage_and_exit
&& opt_table[i].u.carg) {
extra = opt_table[i].u.carg;
extra = (const char *)opt_table[i].u.carg;
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)
return NULL;