mirror of
https://github.com/holub/mame
synced 2025-07-04 17:38:08 +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)
|
bool debugger_commands::validate_boolean_parameter(const char *param, bool *result)
|
||||||
{
|
{
|
||||||
/* nullptr parameter does nothing and returns no error */
|
/* nullptr parameter does nothing and returns no error */
|
||||||
if (param == nullptr)
|
if (param == nullptr || strlen(param) == 0)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
/* evaluate the expression; success if no error */
|
/* evaluate the expression; success if no error */
|
||||||
bool is_true = (strcmp(param, "true") == 0 || strcmp(param, "TRUE") == 0 || strcmp(param, "1") == 0);
|
bool is_true = (core_stricmp(param, "true") == 0 || strcmp(param, "1") == 0);
|
||||||
bool is_false = (strcmp(param, "false") == 0 || strcmp(param, "FALSE") == 0 || strcmp(param, "0") == 0);
|
bool is_false = (core_stricmp(param, "false") == 0 || strcmp(param, "0") == 0);
|
||||||
|
|
||||||
if (!is_true && !is_false)
|
if (!is_true && !is_false)
|
||||||
|
{
|
||||||
|
m_console.printf("Invalid boolean '%s'\n", param);
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
*result = is_true;
|
*result = is_true;
|
||||||
|
|
||||||
@ -2482,7 +2485,7 @@ void debugger_commands::execute_trace_internal(int ref, int params, const char *
|
|||||||
return;
|
return;
|
||||||
if (!validate_boolean_parameter((params > 2) ? param[2] : nullptr, &detect_loops))
|
if (!validate_boolean_parameter((params > 2) ? param[2] : nullptr, &detect_loops))
|
||||||
return;
|
return;
|
||||||
if (!debug_command_parameter_command(action = param[3]))
|
if (!debug_command_parameter_command(action = (params > 3) ? param[3] : nullptr))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* open the file */
|
/* open the file */
|
||||||
|
Loading…
Reference in New Issue
Block a user