Browse Source

Fix usage and big strings on windows (colors rel.)

vsnprintf doesnt return the len on windows on fail, so use _vscprintf
2upstream
Tanguy Pruvot 10 years ago
parent
commit
f737f7f0cb
  1. 12
      compat/winansi.c
  2. 52
      cpu-miner.c

12
compat/winansi.c

@ -16,7 +16,6 @@
* Copyright 2008 Peter Harris <git@peter.is-a-geek.org> * Copyright 2008 Peter Harris <git@peter.is-a-geek.org>
*/ */
/* /*
Functions to be wrapped: 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 winansi_vfprintf(FILE *stream, const char *format, va_list list)
{ {
int len, rv; int len, rv;
char small_buf[256]; char small_buf[256] = { 0 };
char *buf = small_buf; char *buf = small_buf;
va_list cp; va_list cp;
@ -338,6 +337,11 @@ int winansi_vfprintf(FILE *stream, const char *format, va_list list)
va_copy(cp, list); va_copy(cp, list);
len = vsnprintf(small_buf, sizeof(small_buf), format, cp); 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); va_end(cp);
if (len > sizeof(small_buf) - 1) { if (len > sizeof(small_buf) - 1) {
@ -346,6 +350,10 @@ int winansi_vfprintf(FILE *stream, const char *format, va_list list)
goto abort; goto abort;
len = vsnprintf(buf, len + 1, format, list); len = vsnprintf(buf, len + 1, format, list);
#ifdef WIN32
if (len == -1)
len = _vscprintf(format, list);
#endif
} }
rv = ansi_emulate(buf, stream); rv = ansi_emulate(buf, stream);

52
cpu-miner.c

@ -246,32 +246,32 @@ struct option {
static char const usage[] = "\ static char const usage[] = "\
Usage: " PROGRAM_NAME " [OPTIONS]\n\ Usage: " PROGRAM_NAME " [OPTIONS]\n\
Options:\n\ Options:\n\
-a, --algo=ALGO specify the algorithm to use\n\ -a, --algo=ALGO specify the hash algorithm to use\n\
anime Animecoin hash\n\ anime Animecoin\n\
blake Blake 256 (like NEOS blake)\n\ blake Blake 256 (SFR/NEOS)\n\
blakecoin Old Blake 256 (8 rounds)\n\ blakecoin Fast Blake 256 (8 rounds)\n\
deep Deepcoin hash\n\ deep Deepcoin\n\
fresh Freshcoin hash (shavite 80)\n\ dmd-gr Diamond-Groestl\n\
fugue256 Fuguecoin hash\n\ fresh Freshcoin (shavite 80)\n\
groestl Groestlcoin hash\n\ fugue256 Fuguecoin\n\
heavy Heavycoin hash\n\ groestl Groestlcoin\n\
keccak Keccak-256 (Maxcoin) hash\n\ heavy Heavycoin\n\
jackpot Jackpot hash\n\ jackpot Jackpot\n\
luffa Doomcoin hash\n\ keccak Keccak-256 (Maxcoin)\n\
mjollnir Mjollnircoin hash\n\ luffa Doomcoin\n\
myr-gr Myriad-Groestl hash\n\ mjollnir Mjollnircoin\n\
nist5 NIST5 (TalkCoin) hash\n\ myr-gr Myriad-Groestl\n\
penta Pentablake hash (5x Blake 512)\n\ nist5 NIST5 (TalkCoin)\n\
quark Quark hash\n\ penta Pentablake hash (5x Blake 512)\n\
qubit Qubit hash\n\ quark Quark\n\
whirl Whirlcoin (old whirlpool)\n\ qubit Qubit\n\
x11 X11 (DarkCoin) hash\n\ x11 X11 (DarkCoin)\n\
x13 X13 (MaruCoin) hash\n\ x13 X13 (MaruCoin)\n\
x14 X14 hash\n\ x14 X14\n\
x15 X15 hash\n\ x15 X15\n\
x17 X17 (peoplecurrency) hash\n\ x17 X17 (peoplecurrency)\n\
dmd-gr Diamond-Groestl hash\n\ whirl Whirlcoin (old whirlpool)\n\
-d, --devices takes a comma separated list of CUDA devices to use.\n\ -d, --devices Comma separated list of CUDA devices to use.\n\
Device IDs start counting from 0! Alternatively takes\n\ Device IDs start counting from 0! Alternatively takes\n\
string names of your cards like gtx780ti or gt640#2\n\ string names of your cards like gtx780ti or gt640#2\n\
(matching 2nd gt640 in the PC)\n\ (matching 2nd gt640 in the PC)\n\

Loading…
Cancel
Save