From 4d1fc8fafabfe36c87f04943e17123e79c45f803 Mon Sep 17 00:00:00 2001 From: Aaron Giles Date: Sat, 21 Aug 2010 19:27:14 +0000 Subject: [PATCH] Swap: (astring.len() != 0) -> astring Swap: (astring.len() == 0) -> !astring --- src/emu/debug/debugcmd.c | 8 ++++---- src/emu/diimage.c | 10 +++++----- src/emu/diimage.h | 10 +++++----- src/emu/input.c | 2 +- src/emu/inputseq.c | 2 +- src/emu/machine.c | 2 +- src/emu/machine.h | 2 +- src/emu/uimenu.c | 2 +- src/emu/validity.c | 4 ++-- 9 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/emu/debug/debugcmd.c b/src/emu/debug/debugcmd.c index f0cea80fc53..e18466b51e3 100644 --- a/src/emu/debug/debugcmd.c +++ b/src/emu/debug/debugcmd.c @@ -998,14 +998,14 @@ static void execute_ignore(running_machine *machine, int ref, int params, const /* build up a comma-separated list */ if (!exec->device().debug()->observing()) { - if (buffer.len() == 0) + if (!buffer) buffer.printf("Currently ignoring device '%s'", exec->device().tag()); else buffer.catprintf(", '%s'", exec->device().tag()); } /* special message for none */ - if (buffer.len() == 0) + if (!buffer) buffer.printf("Not currently ignoring any devices"); debug_console_printf(machine, "%s\n", buffer.cstr()); } @@ -1060,14 +1060,14 @@ static void execute_observe(running_machine *machine, int ref, int params, const /* build up a comma-separated list */ if (exec->device().debug()->observing()) { - if (buffer.len() == 0) + if (!buffer) buffer.printf("Currently observing CPU '%s'", exec->device().tag()); else buffer.catprintf(", '%s'", exec->device().tag()); } /* special message for none */ - if (buffer.len() == 0) + if (!buffer) buffer.printf("Not currently observing any devices"); debug_console_printf(machine, "%s\n", buffer.cstr()); } diff --git a/src/emu/diimage.c b/src/emu/diimage.c index fa6b1a5f793..295265c59f4 100644 --- a/src/emu/diimage.c +++ b/src/emu/diimage.c @@ -271,7 +271,7 @@ const image_device_format *device_image_interface::device_get_named_creatable_fo void device_image_interface::clear_error() { m_err = IMAGE_ERROR_SUCCESS; - if (m_err_message.len()!=0) + if (m_err_message) { m_err_message.reset(); } @@ -297,7 +297,7 @@ static const char *const messages[] = const char *device_image_interface::error() { - return (m_err_message.len()!=0) ? m_err_message.cstr() : messages[m_err]; + return (m_err_message) ? m_err_message.cstr() : messages[m_err]; } @@ -413,7 +413,7 @@ void device_image_interface::setup_working_directory() const char * device_image_interface::working_directory() { /* check to see if we've never initialized the working directory */ - if (m_working_directory.len() == 0) + if (!m_working_directory) setup_working_directory(); return m_working_directory; @@ -593,7 +593,7 @@ void device_image_interface::image_checkhash() int rc; /* only calculate CRC if it hasn't been calculated, and the open_mode is read only */ - if (m_hash.len()==0 && !m_writeable && !m_created) + if (!m_hash && !m_writeable && !m_created) { /* do not cause a linear read of 600 megs please */ /* TODO: use SHA/MD5 in the CHD header as the hash */ @@ -628,7 +628,7 @@ UINT32 device_image_interface::crc() UINT32 crc = 0; image_checkhash(); - if (m_hash.len()!= 0) + if (m_hash) crc = hash_data_extract_crc32(m_hash.cstr()); return crc; diff --git a/src/emu/diimage.h b/src/emu/diimage.h index 2fa91f5006f..7bb3e60a91d 100644 --- a/src/emu/diimage.h +++ b/src/emu/diimage.h @@ -222,11 +222,11 @@ public: void seterror(image_error_t err, const char *message); void message(const char *format, ...); - bool exists() { return m_name.len() != 0; } - const char *filename() { if (m_name.len()==0) return NULL; else return m_name; } - const char *basename() { if (m_basename.len()==0) return NULL; else return m_basename; } - const char *basename_noext() { if (m_basename_noext.len()==0) return NULL; else return m_basename_noext; } - const char *filetype() { if (m_filetype.len()==0) return NULL; else return m_filetype; } + bool exists() { return m_name; } + const char *filename() { if (!m_name) return NULL; else return m_name; } + const char *basename() { if (!m_basename) return NULL; else return m_basename; } + const char *basename_noext() { if (!m_basename_noext) return NULL; else return m_basename_noext; } + const char *filetype() { if (!m_filetype) return NULL; else return m_filetype; } core_file *image_core_file() { return m_file; } UINT64 length() { check_for_file(); return core_fsize(m_file); } bool is_writable() { return m_writeable; } diff --git a/src/emu/input.c b/src/emu/input.c index 47824850b57..5488959a778 100644 --- a/src/emu/input.c +++ b/src/emu/input.c @@ -1353,7 +1353,7 @@ astring &input_code_to_token(running_machine *machine, astring &string, input_co devindex[0] = 0; /* determine the itemid part; look up in the table if we don't have a token */ - if (item != NULL && item->token.len() != 0) + if (item != NULL && item->token) devcode = item->token; else { diff --git a/src/emu/inputseq.c b/src/emu/inputseq.c index adf9c0cf157..972e4c4f149 100644 --- a/src/emu/inputseq.c +++ b/src/emu/inputseq.c @@ -418,7 +418,7 @@ astring &input_seq_name(running_machine *machine, astring &string, const input_s input_code code = seq->code[codenum]; /* if this is a code item which is not valid, don't copy it and remove any preceding ORs/NOTs */ - if (!INPUT_CODE_IS_INTERNAL(code) && input_code_name(machine, codestr, code).len() == 0) + if (!INPUT_CODE_IS_INTERNAL(code) && !input_code_name(machine, codestr, code)) { while (copycodenum > 0 && INPUT_CODE_IS_INTERNAL(seqcopy.code[copycodenum - 1])) copycodenum--; diff --git a/src/emu/machine.c b/src/emu/machine.c index 8313e204dc9..f7695409328 100644 --- a/src/emu/machine.c +++ b/src/emu/machine.c @@ -789,7 +789,7 @@ void running_machine::handle_saveload() file_error filerr = FILERR_NONE; // if no name, bail - if (m_saveload_pending_file.len() == 0) + if (!m_saveload_pending_file) goto cancel; // if there are anonymous timers, we can't save just yet, and we can't load yet either diff --git a/src/emu/machine.h b/src/emu/machine.h index 3f672bd8166..586ccafb787 100644 --- a/src/emu/machine.h +++ b/src/emu/machine.h @@ -298,7 +298,7 @@ public: machine_phase phase() const { return m_current_phase; } bool paused() const { return m_paused || (m_current_phase != MACHINE_PHASE_RUNNING); } bool scheduled_event_pending() const { return m_exit_pending || m_hard_reset_pending; } - bool save_or_load_pending() const { return (m_saveload_pending_file.len() != 0); } + bool save_or_load_pending() const { return (m_saveload_pending_file); } bool exit_pending() const { return m_exit_pending; } bool new_driver_pending() const { return (m_new_driver_pending != NULL); } const char *new_driver_name() const { return m_new_driver_pending->name; } diff --git a/src/emu/uimenu.c b/src/emu/uimenu.c index a75703b61fd..c30a0843654 100644 --- a/src/emu/uimenu.c +++ b/src/emu/uimenu.c @@ -2577,7 +2577,7 @@ static void menu_cheat(running_machine *machine, ui_menu *menu, void *parameter, case IPT_UI_DISPLAY_COMMENT: case IPT_UI_UP: case IPT_UI_DOWN: - if (cheat_get_comment(event->itemref).len() != 0) + if (cheat_get_comment(event->itemref)) popmessage("Cheat Comment:\n%s", cheat_get_comment(event->itemref).cstr()); break; } diff --git a/src/emu/validity.c b/src/emu/validity.c index 14d317489e1..25f51ab468c 100644 --- a/src/emu/validity.c +++ b/src/emu/validity.c @@ -499,7 +499,7 @@ static bool validate_roms(int drivnum, const machine_config *config, region_arra for (rgnnum = 0; rgnnum < ARRAY_LENGTH(rgninfo->entries); rgnnum++) { /* stop when we hit an empty */ - if (rgninfo->entries[rgnnum].tag.len() == 0) + if (!rgninfo->entries[rgnnum].tag) { currgn = &rgninfo->entries[rgnnum]; currgn->tag.cpy(fulltag); @@ -650,7 +650,7 @@ static bool validate_gfx(int drivnum, const machine_config *config, region_array for (rgnnum = 0; rgnnum < ARRAY_LENGTH(rgninfo->entries); rgnnum++) { /* stop if we hit an empty */ - if (rgninfo->entries[rgnnum].tag.len() == 0) + if (!rgninfo->entries[rgnnum].tag) { mame_printf_error("%s: %s has gfx[%d] referencing non-existent region '%s'\n", driver->source_file, driver->name, gfxnum, region); error = true;