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 @@ @@ -16,7 +16,6 @@
* Copyright 2008 Peter Harris <git@peter.is-a-geek.org>
*/
/*
Functions to be wrapped:
*/
@ -324,7 +323,7 @@ int winansi_fputs(const char *str, FILE *stream) @@ -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) @@ -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) @@ -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);

52
cpu-miner.c

@ -246,32 +246,32 @@ struct option { @@ -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\

Loading…
Cancel
Save