mirror of
https://github.com/holub/mame
synced 2025-07-03 00:56:03 +03:00
Fixed trace command access a parameter beyond the list supplied, added an error message if you provide an invalid boolean, allow boolean to be case-insensitive and skip empty strings when parsing booleans. [smf]
This commit is contained in:
parent
4c791d4320
commit
c56cd675f2
@ -387,15 +387,18 @@ bool debugger_commands::validate_number_parameter(const char *param, UINT64 *res
|
||||
bool debugger_commands::validate_boolean_parameter(const char *param, bool *result)
|
||||
{
|
||||
/* nullptr parameter does nothing and returns no error */
|
||||
if (param == nullptr)
|
||||
if (param == nullptr || strlen(param) == 0)
|
||||
return true;
|
||||
|
||||
/* evaluate the expression; success if no error */
|
||||
bool is_true = (strcmp(param, "true") == 0 || strcmp(param, "TRUE") == 0 || strcmp(param, "1") == 0);
|
||||
bool is_false = (strcmp(param, "false") == 0 || strcmp(param, "FALSE") == 0 || strcmp(param, "0") == 0);
|
||||
bool is_true = (core_stricmp(param, "true") == 0 || strcmp(param, "1") == 0);
|
||||
bool is_false = (core_stricmp(param, "false") == 0 || strcmp(param, "0") == 0);
|
||||
|
||||
if (!is_true && !is_false)
|
||||
{
|
||||
m_console.printf("Invalid boolean '%s'\n", param);
|
||||
return false;
|
||||
}
|
||||
|
||||
*result = is_true;
|
||||
|
||||
@ -2482,7 +2485,7 @@ void debugger_commands::execute_trace_internal(int ref, int params, const char *
|
||||
return;
|
||||
if (!validate_boolean_parameter((params > 2) ? param[2] : nullptr, &detect_loops))
|
||||
return;
|
||||
if (!debug_command_parameter_command(action = param[3]))
|
||||
if (!debug_command_parameter_command(action = (params > 3) ? param[3] : nullptr))
|
||||
return;
|
||||
|
||||
/* open the file */
|
||||
|
Loading…
Reference in New Issue
Block a user