From 0e09afc1a814682a1d9ea5eb70d8f6fc5a708f33 Mon Sep 17 00:00:00 2001 From: Aaron Giles Date: Sat, 21 Aug 2010 19:23:48 +0000 Subject: [PATCH] Added bool operator to astring, returning true if the string is not empty. Conveniently, this creates ambiguity if you write astring == NULL. Rooted out remaining cases where we were doing that and fixed them. --- src/emu/cheat.c | 10 +++++----- src/emu/debug/debugcpu.c | 6 +++--- src/emu/debugint/debugint.c | 2 +- src/emu/mconfig.c | 2 +- src/lib/util/astring.h | 1 + 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/emu/cheat.c b/src/emu/cheat.c index 4bc4ec7ea6a..91cd1fcf141 100644 --- a/src/emu/cheat.c +++ b/src/emu/cheat.c @@ -518,7 +518,7 @@ void cheat_render_text(running_machine *machine, render_container *container) /* render any text and free it along the way */ for (linenum = 0; linenum < ARRAY_LENGTH(cheatinfo->output); linenum++) - if (cheatinfo->output[linenum].len() != 0) + if (cheatinfo->output[linenum]) { /* output the text */ ui_draw_text_full(container, cheatinfo->output[linenum], @@ -956,7 +956,7 @@ static void cheat_execute_script(cheat_private *cheatinfo, cheat_entry *cheat, s } /* if there is a string to display, compute it */ - if (entry->format.len() != 0) + if (entry->format) { UINT64 params[MAX_ARGUMENTS]; output_argument *arg; @@ -1283,14 +1283,14 @@ static void cheat_entry_save(mame_file *cheatfile, const cheat_entry *cheat) mame_fprintf(cheatfile, "\tdescription.cstr()); if (cheat->numtemp != DEFAULT_TEMP_VARIABLES) mame_fprintf(cheatfile, " tempvariables=\"%d\"", cheat->numtemp); - if (cheat->comment.len() == 0 && cheat->parameter == NULL && scriptcount == 0) + if (!cheat->comment && cheat->parameter == NULL && scriptcount == 0) mame_fprintf(cheatfile, " />\n"); else { mame_fprintf(cheatfile, ">\n"); /* save the comment */ - if (cheat->comment.len() != 0) + if (cheat->comment) mame_fprintf(cheatfile, "\t\t\n", cheat->comment.cstr()); /* output the parameter, if present */ @@ -1704,7 +1704,7 @@ static void script_entry_save(mame_file *cheatfile, const script_entry *entry) astring tempstring; /* output an action */ - if (entry->format.len() == 0) + if (!entry->format) { mame_fprintf(cheatfile, "\t\t\tcondition != NULL) diff --git a/src/emu/debug/debugcpu.c b/src/emu/debug/debugcpu.c index 1efac6ecc74..52746397fa0 100644 --- a/src/emu/debug/debugcpu.c +++ b/src/emu/debug/debugcpu.c @@ -2557,7 +2557,7 @@ void device_debug::breakpoint_check(offs_t pc) global->execution_state = EXECUTION_STATE_STOPPED; // if we hit, evaluate the action - if (bp->m_action.len() != 0) + if (bp->m_action) debug_console_execute_command(m_device.machine, bp->m_action, 0); // print a notification, unless the action made us go again @@ -2650,7 +2650,7 @@ void device_debug::watchpoint_check(address_space &space, int type, offs_t addre global->execution_state = EXECUTION_STATE_STOPPED; // if we hit, evaluate the action - if (wp->m_action != NULL) + if (wp->m_action) debug_console_execute_command(space.machine, wp->m_action, 0); // print a notification, unless the action made us go again @@ -3011,7 +3011,7 @@ void device_debug::tracer::update(offs_t pc) m_loops = 0; // execute any trace actions first - if (m_action != NULL) + if (m_action) debug_console_execute_command(m_debug.m_device.machine, m_action, 0); // print the address diff --git a/src/emu/debugint/debugint.c b/src/emu/debugint/debugint.c index 25e923d91f7..74f601fe172 100644 --- a/src/emu/debugint/debugint.c +++ b/src/emu/debugint/debugint.c @@ -492,7 +492,7 @@ static void dview_draw_title(DView *dv) dview_draw_outlined_box(dv, RECT_DVIEW_TITLE, 0, 0, rect_get_width(&dv->bounds), TITLE_HEIGHT, col); - if (dv->title == NULL) + if (!dv->title) return; for (i=0; ititle); i++) diff --git a/src/emu/mconfig.c b/src/emu/mconfig.c index 22d47fd31b2..0e10d39cbda 100644 --- a/src/emu/mconfig.c +++ b/src/emu/mconfig.c @@ -145,7 +145,7 @@ void machine_config::detokenize(const machine_config_token *tokens, const device case MCONFIG_TOKEN_DEVICE_MODIFY: tag = TOKEN_GET_STRING(tokens); - device = m_devicelist.find(owner->subtag(tempstring, tag)); + device = m_devicelist.find(owner->subtag(tempstring, tag).cstr()); if (device == NULL) fatalerror("Unable to find device: tag=%s\n", tempstring.cstr()); break; diff --git a/src/lib/util/astring.h b/src/lib/util/astring.h index 02f102c0a73..e38d2d7fe71 100644 --- a/src/lib/util/astring.h +++ b/src/lib/util/astring.h @@ -333,6 +333,7 @@ public: astring &reset() { return cpy(""); } astring &expand(int length) { astring_expand(this, length); return *this; } + operator bool() const { return this->text[0] != 0; } operator char *() { return this->text; } operator const char *() const { return astring_c(this); } const char *cstr() const { return astring_c(this); }