1
0
Fork 0

(svn r3380) -Fix: removed 'size' from r3379, because it was pretty silly

-Note: no longer showhelp publish -p, as it is deprecated
release/0.4.5
truelight 2006-01-07 10:15:46 +00:00
parent 835cd6ea28
commit e373bd02ba
3 changed files with 9 additions and 17 deletions

View File

@ -206,23 +206,19 @@ int GetDriverParamInt(const char* const* parm, const char* name, int def)
} }
int GetDriverList(char* p, int size) char *GetDriverList(char* p)
{ {
const DriverClass* dc; const DriverClass* dc;
int pos;
for (dc = _driver_classes; dc != endof(_driver_classes); dc++) { for (dc = _driver_classes; dc != endof(_driver_classes); dc++) {
const DriverDesc* dd; const DriverDesc* dd;
pos = snprintf(p, size, "List of %s drivers:\n", dc->name); p += sprintf(p, "List of %s drivers:\n", dc->name);
p += pos; size -= pos;
for (dd = dc->descs; dd->name != NULL; dd++) { for (dd = dc->descs; dd->name != NULL; dd++) {
pos = snprintf(p, size, "%10s: %s\n", dd->name, dd->longname); p += sprintf(p, "%10s: %s\n", dd->name, dd->longname);
p += pos; size -= pos;
} }
pos = snprintf(p, size, "\n"); p += sprintf(p, "\n");
p += pos; size -= pos;
} }
return size; return p;
} }

View File

@ -8,6 +8,6 @@ void LoadDriver(int driver, const char *name);
bool GetDriverParamBool(const char* const* parm, const char* name); bool GetDriverParamBool(const char* const* parm, const char* name);
int GetDriverParamInt(const char* const* parm, const char* name, int def); int GetDriverParamInt(const char* const* parm, const char* name, int def);
int GetDriverList(char* p, int size); char *GetDriverList(char* p);
#endif /* DRIVER_H */ #endif /* DRIVER_H */

View File

@ -120,14 +120,11 @@ extern const char _openttd_revision[];
static void showhelp(void) static void showhelp(void)
{ {
char buf[4096], *p; char buf[4096], *p;
int size, pos;
p = buf; p = buf;
size = sizeof(buf);
pos = snprintf(p, size, "OpenTTD %s\n", _openttd_revision); p += sprintf(p, "OpenTTD %s\n", _openttd_revision);
p += pos; size -= pos; p += sprintf(p,
pos = snprintf(p, size,
"\n" "\n"
"\n" "\n"
"Command line options:\n" "Command line options:\n"
@ -151,9 +148,8 @@ static void showhelp(void)
" -c config_file = Use 'config_file' instead of 'openttd.cfg'\n" " -c config_file = Use 'config_file' instead of 'openttd.cfg'\n"
"\n" "\n"
); );
p += pos; size -= pos;
size = GetDriverList(p, size); p = GetDriverList(p);
ShowInfo(buf); ShowInfo(buf);
} }