From f737f7f0cb5145c8618ae5794380032eea9cbbe1 Mon Sep 17 00:00:00 2001 From: Tanguy Pruvot Date: Mon, 20 Oct 2014 04:01:06 +0200 Subject: [PATCH] Fix usage and big strings on windows (colors rel.) vsnprintf doesnt return the len on windows on fail, so use _vscprintf --- compat/winansi.c | 12 +++++++++-- cpu-miner.c | 52 ++++++++++++++++++++++++------------------------ 2 files changed, 36 insertions(+), 28 deletions(-) diff --git a/compat/winansi.c b/compat/winansi.c index c0ea115..50e8388 100644 --- a/compat/winansi.c +++ b/compat/winansi.c @@ -16,7 +16,6 @@ * Copyright 2008 Peter Harris */ - /* Functions to be wrapped: */ @@ -324,7 +323,7 @@ int winansi_fputs(const char *str, FILE *stream) int winansi_vfprintf(FILE *stream, const char *format, va_list list) { int len, rv; - char small_buf[256]; + char small_buf[256] = { 0 }; char *buf = small_buf; va_list cp; @@ -338,6 +337,11 @@ int winansi_vfprintf(FILE *stream, const char *format, va_list list) va_copy(cp, list); len = vsnprintf(small_buf, sizeof(small_buf), format, cp); +#ifdef WIN32 + /* bug on long strings without that */ + if (len == -1) + len = _vscprintf(format, cp); +#endif va_end(cp); if (len > sizeof(small_buf) - 1) { @@ -346,6 +350,10 @@ int winansi_vfprintf(FILE *stream, const char *format, va_list list) goto abort; len = vsnprintf(buf, len + 1, format, list); +#ifdef WIN32 + if (len == -1) + len = _vscprintf(format, list); +#endif } rv = ansi_emulate(buf, stream); diff --git a/cpu-miner.c b/cpu-miner.c index 60f2c8c..5fc0891 100644 --- a/cpu-miner.c +++ b/cpu-miner.c @@ -246,32 +246,32 @@ struct option { static char const usage[] = "\ Usage: " PROGRAM_NAME " [OPTIONS]\n\ Options:\n\ - -a, --algo=ALGO specify the algorithm to use\n\ - anime Animecoin hash\n\ - blake Blake 256 (like NEOS blake)\n\ - blakecoin Old Blake 256 (8 rounds)\n\ - deep Deepcoin hash\n\ - fresh Freshcoin hash (shavite 80)\n\ - fugue256 Fuguecoin hash\n\ - groestl Groestlcoin hash\n\ - heavy Heavycoin hash\n\ - keccak Keccak-256 (Maxcoin) hash\n\ - jackpot Jackpot hash\n\ - luffa Doomcoin hash\n\ - mjollnir Mjollnircoin hash\n\ - myr-gr Myriad-Groestl hash\n\ - nist5 NIST5 (TalkCoin) hash\n\ - penta Pentablake hash (5x Blake 512)\n\ - quark Quark hash\n\ - qubit Qubit hash\n\ - whirl Whirlcoin (old whirlpool)\n\ - x11 X11 (DarkCoin) hash\n\ - x13 X13 (MaruCoin) hash\n\ - x14 X14 hash\n\ - x15 X15 hash\n\ - x17 X17 (peoplecurrency) hash\n\ - dmd-gr Diamond-Groestl hash\n\ - -d, --devices takes a comma separated list of CUDA devices to use.\n\ + -a, --algo=ALGO specify the hash algorithm to use\n\ + anime Animecoin\n\ + blake Blake 256 (SFR/NEOS)\n\ + blakecoin Fast Blake 256 (8 rounds)\n\ + deep Deepcoin\n\ + dmd-gr Diamond-Groestl\n\ + fresh Freshcoin (shavite 80)\n\ + fugue256 Fuguecoin\n\ + groestl Groestlcoin\n\ + heavy Heavycoin\n\ + jackpot Jackpot\n\ + keccak Keccak-256 (Maxcoin)\n\ + luffa Doomcoin\n\ + mjollnir Mjollnircoin\n\ + myr-gr Myriad-Groestl\n\ + nist5 NIST5 (TalkCoin)\n\ + penta Pentablake hash (5x Blake 512)\n\ + quark Quark\n\ + qubit Qubit\n\ + x11 X11 (DarkCoin)\n\ + x13 X13 (MaruCoin)\n\ + x14 X14\n\ + x15 X15\n\ + x17 X17 (peoplecurrency)\n\ + whirl Whirlcoin (old whirlpool)\n\ + -d, --devices Comma separated list of CUDA devices to use.\n\ Device IDs start counting from 0! Alternatively takes\n\ string names of your cards like gtx780ti or gt640#2\n\ (matching 2nd gt640 in the PC)\n\