removed bool conversion and implicit empty check (nw)

This commit is contained in:
Miodrag Milanovic 2015-04-19 12:08:52 +02:00
parent 337342a4c6
commit 71c4d9f304
32 changed files with 70 additions and 69 deletions

View File

@ -498,7 +498,7 @@ void cheat_script::script_entry::execute(cheat_manager &manager, UINT64 &arginde
}
// if there is a string to display, compute it
if (m_format)
if (!m_format.empty())
{
// iterate over arguments and evaluate them
UINT64 params[MAX_ARGUMENTS];
@ -529,7 +529,7 @@ void cheat_script::script_entry::save(emu_file &cheatfile) const
astring tempstring;
// output an action
if (!m_format)
if (m_format.empty())
{
cheatfile.printf("\t\t\t<action");
if (!m_condition.is_empty())
@ -785,14 +785,14 @@ void cheat_entry::save(emu_file &cheatfile) const
cheatfile.printf("\t<cheat desc=\"%s\"", m_description.c_str());
if (m_numtemp != DEFAULT_TEMP_VARIABLES)
cheatfile.printf(" tempvariables=\"%d\"", m_numtemp);
if (!m_comment && m_parameter == NULL && !has_scripts)
if (m_comment.empty() && m_parameter == NULL && !has_scripts)
cheatfile.printf(" />\n");
else
{
cheatfile.printf(">\n");
// save the comment
if (m_comment)
if (!m_comment.empty())
cheatfile.printf("\t\t<comment><![CDATA[\n%s\n\t\t]]></comment>\n", m_comment.c_str());
// output the parameter, if present
@ -961,10 +961,10 @@ void cheat_entry::menu_text(astring &description, astring &state, UINT32 &flags)
// some cheat entries are just text for display
if (is_text_only())
{
if (description)
if (!description.empty())
{
description.trimspace();
if (!description)
if (description.empty())
description.cpy(MENU_SEPARATOR_ITEM);
}
flags = MENU_FLAG_DISABLE;
@ -1218,7 +1218,7 @@ void cheat_manager::render_text(render_container &container)
{
// render any text and free it along the way
for (int linenum = 0; linenum < ARRAY_LENGTH(m_output); linenum++)
if (m_output[linenum])
if (!m_output[linenum].empty())
{
// output the text
machine().ui().draw_text_full(&container, m_output[linenum].c_str(),

View File

@ -186,7 +186,7 @@ int cli_frontend::execute(int argc, char **argv)
// otherwise, error on the options
throw emu_fatalerror(MAMERR_INVALID_CONFIG, "%s", option_errors.trimspace().c_str());
}
if (option_errors)
if (!option_errors.empty())
osd_printf_error("Error in command line:\n%s\n", option_errors.trimspace().c_str());
// determine the base name of the EXE
@ -207,7 +207,7 @@ int cli_frontend::execute(int argc, char **argv)
m_options.revert(OPTION_PRIORITY_INI);
m_options.parse_standard_inis(option_errors);
}
if (option_errors)
if (!option_errors.empty())
osd_printf_error("Error in command line:\n%s\n", option_errors.trimspace().c_str());
// if we can't find it, give an appropriate error
@ -1555,7 +1555,7 @@ void cli_frontend::execute_commands(const char *exename)
// other commands need the INIs parsed
astring option_errors;
m_options.parse_standard_inis(option_errors);
if (option_errors)
if (!option_errors.empty())
osd_printf_error("%s\n", option_errors.c_str());
// createconfig?

View File

@ -1035,14 +1035,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)
if (buffer.empty())
buffer.printf("Currently ignoring device '%s'", exec->device().tag());
else
buffer.catprintf(", '%s'", exec->device().tag());
}
/* special message for none */
if (!buffer)
if (buffer.empty())
buffer.printf("Not currently ignoring any devices");
debug_console_printf(machine, "%s\n", buffer.c_str());
}
@ -1100,14 +1100,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)
if (buffer.empty())
buffer.printf("Currently observing CPU '%s'", exec->device().tag());
else
buffer.catprintf(", '%s'", exec->device().tag());
}
/* special message for none */
if (!buffer)
if (buffer.empty())
buffer.printf("Not currently observing any devices");
debug_console_printf(machine, "%s\n", buffer.c_str());
}
@ -1328,9 +1328,9 @@ static void execute_bplist(running_machine &machine, int ref, int params, const
for (device_debug::breakpoint *bp = device->debug()->breakpoint_first(); bp != NULL; bp = bp->next())
{
buffer.printf("%c%4X @ %s", bp->enabled() ? ' ' : 'D', bp->index(), core_i64_hex_format(bp->address(), device->debug()->logaddrchars()));
if (astring(bp->condition()) != astring("1"))
if (astring(bp->condition()).cmp("1")!=0)
buffer.catprintf(" if %s", bp->condition());
if (astring(bp->action()) != astring(""))
if (astring(bp->action()).cmp("")!=0)
buffer.catprintf(" do %s", bp->action());
debug_console_printf(machine, "%s\n", buffer.c_str());
printed++;
@ -1498,9 +1498,9 @@ static void execute_wplist(running_machine &machine, int ref, int params, const
core_i64_hex_format(wp->space().byte_to_address(wp->address()), wp->space().addrchars()),
core_i64_hex_format(wp->space().byte_to_address_end(wp->address() + wp->length()) - 1, wp->space().addrchars()),
types[wp->type() & 3]);
if (astring(wp->condition()) != astring("1"))
if (astring(wp->condition()).cmp("1")!=0)
buffer.catprintf(" if %s", wp->condition());
if (astring(wp->action()) != astring(""))
if (astring(wp->action()).cmp("")!=0)
buffer.catprintf(" do %s", wp->action());
debug_console_printf(machine, "%s\n", buffer.c_str());
printed++;

View File

@ -2908,7 +2908,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)
if (!bp->m_action.empty())
debug_console_execute_command(m_device.machine(), bp->m_action.c_str(), 0);
// print a notification, unless the action made us go again
@ -2927,7 +2927,7 @@ void device_debug::breakpoint_check(offs_t pc)
global->execution_state = EXECUTION_STATE_STOPPED;
// if we hit, evaluate the action
if (rp->m_action)
if (!rp->m_action.empty())
{
debug_console_execute_command(m_device.machine(), rp->m_action.c_str(), 0);
}
@ -3037,7 +3037,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)
if (!wp->m_action.empty())
debug_console_execute_command(space.machine(), wp->m_action.c_str(), 0);
// print a notification, unless the action made us go again
@ -3480,7 +3480,7 @@ void device_debug::tracer::update(offs_t pc)
m_loops = 0;
// execute any trace actions first
if (m_action)
if (!m_action.empty())
debug_console_execute_command(m_debug.m_device.machine(), m_action.c_str(), 0);
// print the address

View File

@ -599,7 +599,7 @@ void parsed_expression::copy(const parsed_expression &src)
{
m_symtable = src.m_symtable;
m_original_string.cpy(src.m_original_string);
if (m_original_string)
if (!m_original_string.empty())
parse_string_into_tokens();
}

View File

@ -166,7 +166,7 @@ public:
static void static_set_clock(device_t &device, UINT32 clock);
static void static_set_static_config(device_t &device, const void *config) { device.m_static_config = config; }
static void static_set_input_default(device_t &device, const input_device_default *config) { device.m_input_defaults = config; }
static void static_set_default_bios_tag(device_t &device, const char *tag) { astring default_bios_tag(tag); device.m_default_bios_tag = default_bios_tag; }
static void static_set_default_bios_tag(device_t &device, const char *tag) { std::string default_bios_tag(tag); device.m_default_bios_tag = default_bios_tag; }
// state helpers
void config_complete();

View File

@ -210,7 +210,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)
if (!m_err_message.empty())
{
m_err_message.reset();
}
@ -236,7 +236,7 @@ static const char *const messages[] =
const char *device_image_interface::error()
{
return (m_err_message) ? m_err_message.c_str() : messages[m_err];
return (!m_err_message.empty()) ? m_err_message.c_str() : messages[m_err];
}
@ -351,7 +351,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)
if (m_working_directory.empty())
setup_working_directory();
return m_working_directory.c_str();
@ -900,7 +900,7 @@ bool device_image_interface::load_internal(const char *path, bool is_create, int
// if we had launched from softlist with a specified part, e.g. "shortname:part"
// we would have recorded the wrong name, so record it again based on software_info
if (m_software_info_ptr && m_full_software_name)
if (m_software_info_ptr && !m_full_software_name.empty())
m_err = set_image_filename(m_full_software_name.c_str());
// check if image should be read-only

View File

@ -170,11 +170,11 @@ public:
void seterror(image_error_t err, const char *message);
void message(const char *format, ...) ATTR_PRINTF(2,3);
bool exists() { return m_image_name; }
const char *filename() { if (!m_image_name) return NULL; else return m_image_name.c_str(); }
const char *basename() { if (!m_basename) return NULL; else return m_basename.c_str(); }
const char *basename_noext() { if (!m_basename_noext) return NULL; else return m_basename_noext.c_str(); }
const char *filetype() { if (!m_filetype) return NULL; else return m_filetype.c_str(); }
bool exists() { return !m_image_name.empty(); }
const char *filename() { if (m_image_name.empty()) return NULL; else return m_image_name.c_str(); }
const char *basename() { if (m_basename.empty()) return NULL; else return m_basename.c_str(); }
const char *basename_noext() { if (m_basename_noext.empty()) return NULL; else return m_basename_noext.c_str(); }
const char *filetype() { if (m_filetype.empty()) return NULL; else return m_filetype.c_str(); }
core_file *image_core_file() { return m_file; }
UINT64 length() { check_for_file(); return core_fsize(m_file); }
bool is_readonly() { return m_readonly; }

View File

@ -492,7 +492,7 @@ void emu_options::set_system_name(const char *name)
// first set the new name
astring error;
set_value(OPTION_SYSTEMNAME, name, OPTION_PRIORITY_CMDLINE, error);
assert(!error);
assert(error.empty());
// remove any existing device options and then add them afresh
remove_device_options();
@ -531,7 +531,7 @@ bool emu_options::parse_one_ini(const char *basename, int priority, astring *err
bool result = parse_ini_file(file, priority, OPTION_PRIORITY_DRIVER_INI, error);
// append errors if requested
if (error && error_string != NULL)
if (!error.empty() && error_string != NULL)
error_string->catprintf("While parsing %s:\n%s\n", file.fullpath(), error.c_str());
return result;

View File

@ -229,7 +229,7 @@ hash_collection &emu_file::hashes(const char *types)
needed.cat(*scan);
// if we need nothing, skip it
if (!needed)
if (needed.empty())
return m_hashes;
// load the ZIP file if needed

View File

@ -1502,7 +1502,7 @@ const char *input_manager::code_name(astring &str, input_code code) const
// concatenate the strings
str.cpy(devclass);
if (devindex)
if (!devindex.empty())
str.cat(" ").cat(devindex);
if (devcode[0] != 0)
str.cat(" ").cat(devcode);
@ -1543,7 +1543,7 @@ const char *input_manager::code_to_token(astring &str, input_code code) const
// concatenate the strings
str.cpy(devclass);
if (devindex)
if (!devindex.empty())
str.cat("_").cat(devindex);
if (devcode[0] != 0)
str.cat("_").cat(devcode);

View File

@ -1519,7 +1519,7 @@ ioport_field::~ioport_field()
const char *ioport_field::name() const
{
// if we have a non-default name, use that
if (m_live != NULL && m_live->name)
if (m_live != NULL && !m_live->name.empty())
return m_live->name.c_str();
if (m_name != NULL)
return m_name;
@ -2481,7 +2481,7 @@ time_t ioport_manager::initialize()
{
astring errors;
m_portlist.append(*device, errors);
if (errors)
if (!errors.empty())
osd_printf_error("Input port errors:\n%s", errors.c_str());
}

View File

@ -892,7 +892,7 @@ void running_machine::handle_saveload()
// if no name, bail
emu_file file(m_saveload_searchpath, openflags);
if (!m_saveload_pending_file)
if (m_saveload_pending_file.empty())
goto cancel;
// if there are anonymous timers, we can't save just yet, and we can't load yet either

View File

@ -182,7 +182,7 @@ public:
bool ui_active() const { return m_ui_active; }
const char *basename() const { return m_basename.c_str(); }
int sample_rate() const { return m_sample_rate; }
bool save_or_load_pending() const { return m_saveload_pending_file; }
bool save_or_load_pending() const { return !m_saveload_pending_file.empty(); }
screen_device *first_screen() const { return primary_screen; }
// additional helpers

View File

@ -168,7 +168,7 @@ void ram_device::device_validity_check(validity_checker &valid) const
osd_printf_warning("Setting value to default %s\n",m_default_size);
astring error;
mconfig().options().set_value(OPTION_RAMSIZE, m_default_size, OPTION_PRIORITY_CMDLINE, error);
assert(!error);
assert(error.empty());
}
}

View File

@ -1313,7 +1313,7 @@ void layout_element::component::load_bitmap()
m_hasalpha[0] = render_load_png(m_bitmap[0], *m_file[0], m_dirname.c_str(), m_imagefile[0].c_str());
// load the alpha bitmap if specified
if (m_bitmap[0].valid() && m_alphafile[0])
if (m_bitmap[0].valid() && !m_alphafile[0].empty())
render_load_png(m_bitmap[0], *m_file[0], m_dirname.c_str(), m_alphafile[0].c_str(), true);
// if we can't load the bitmap, allocate a dummy one and report an error
@ -1327,7 +1327,7 @@ void layout_element::component::load_bitmap()
m_bitmap[0].pix32((step + line) % 100, line % 100) = rgb_t(0xff,0xff,0xff,0xff);
// log an error
if (!m_alphafile[0])
if (m_alphafile[0].empty())
osd_printf_warning("Unable to load component bitmap '%s'\n", m_imagefile[0].c_str());
else
osd_printf_warning("Unable to load component bitmap '%s'/'%s'\n", m_imagefile[0].c_str(), m_alphafile[0].c_str());

View File

@ -207,7 +207,7 @@ public:
const render_color &color() const { return m_color; }
int orientation() const { return m_orientation; }
render_container *screen_container(running_machine &machine) const;
bool has_input() const { return bool(m_input_tag); }
bool has_input() const { return !m_input_tag.empty(); }
const char *input_tag_and_mask(ioport_value &mask) const { mask = m_input_mask; return m_input_tag.c_str(); }
// fetch state based on configured source

View File

@ -173,12 +173,12 @@ void save_manager::save_memory(device_t *device, const char *module, const char
for (state_entry *entry = m_entry_list.first(); entry != NULL; entry = entry->next())
{
// stop when we find an entry whose name is after ours
if (entry->m_name > totalname)
if (entry->m_name.cmp(totalname)>0)
break;
insert_after = entry;
// error if we are equal
if (entry->m_name == totalname)
if (entry->m_name.cmp(totalname)==0)
fatalerror("Duplicate save state registration entry (%s)\n", totalname.c_str());
}

View File

@ -104,7 +104,7 @@ void ui_menu_file_manager::populate()
bool first_entry = true;
astring prev_owner;
if (m_warnings)
if (!m_warnings.empty())
{
item_append(m_warnings.c_str(), NULL, MENU_FLAG_DISABLE, NULL);
item_append("", NULL, MENU_FLAG_DISABLE, NULL);

View File

@ -122,14 +122,14 @@ void ui_menu_bios_selection::handle()
if (strcmp(dev->tag(),":")==0) {
astring error;
machine().options().set_value("bios", val-1, OPTION_PRIORITY_CMDLINE, error);
assert(!error);
assert(error.empty());
} else {
astring error;
astring value;
astring temp;
value.printf("%s,bios=%d",machine().options().main_value(temp,dev->owner()->tag()+1),val-1);
machine().options().set_value(dev->owner()->tag()+1, value.c_str(), OPTION_PRIORITY_CMDLINE, error);
assert(!error);
assert(error.empty());
}
reset(UI_MENU_RESET_REMEMBER_REF);
}

View File

@ -136,7 +136,7 @@ void ui_menu_slot_devices::set_slot_device(device_slot_interface *slot, const ch
{
astring error;
machine().options().set_value(slot->device().tag()+1, val, OPTION_PRIORITY_CMDLINE, error);
assert(!error);
assert(error.empty());
}
/*-------------------------------------------------

View File

@ -2422,5 +2422,5 @@ void ui_manager::set_use_natural_keyboard(bool use_natural_keyboard)
m_use_natural_keyboard = use_natural_keyboard;
astring error;
machine().options().set_value(OPTION_NATURAL_KEYBOARD, use_natural_keyboard, OPTION_PRIORITY_CMDLINE, error);
assert(!error);
assert(error.empty());
}

View File

@ -882,7 +882,7 @@ void validity_checker::validate_inputs()
portlist.append(*device, errorbuf);
// report any errors during construction
if (errorbuf)
if (!errorbuf.empty())
osd_printf_error("I/O port error during construction:\n%s\n", errorbuf.c_str());
// do a first pass over ports to add their names and find duplicates

View File

@ -65,8 +65,8 @@ public:
char operator[](int index) const { return (index < len()) ? m_text[index] : 0; }
// implicit boolean conversion operators
operator bool() { return m_text[0] != 0; }
operator bool() const { return m_text[0] != 0; }
//operator bool() { return m_text[0] != 0; }
//operator bool() const { return m_text[0] != 0; }
// C string conversion operators and helpers
const char *c_str() const { return m_text; }
@ -77,6 +77,7 @@ public:
// length query
int len() const { return m_len; }
bool empty() const { return m_len==0; }
// copy helpers
astring &cpy(const char *src, int count);

View File

@ -925,7 +925,7 @@ chd_error chdcd_parse_cue(const char *tocfname, cdrom_toc &outtoc, chdcd_track_i
if (trknum == (outtoc.numtrks-1))
{
/* if we have the same filename as the last track, do it that way */
if (trknum != 0 && outinfo.track[trknum].fname == outinfo.track[trknum-1].fname)
if (trknum != 0 && (outinfo.track[trknum].fname.cmp(outinfo.track[trknum-1].fname)==0))
{
tlen = get_file_size(outinfo.track[trknum].fname.c_str());
if (tlen == 0)
@ -952,7 +952,7 @@ chd_error chdcd_parse_cue(const char *tocfname, cdrom_toc &outtoc, chdcd_track_i
else
{
/* if we have the same filename as the next track, do it that way */
if (outinfo.track[trknum].fname == outinfo.track[trknum+1].fname)
if (outinfo.track[trknum].fname.cmp(outinfo.track[trknum+1].fname)==0)
{
outtoc.tracks[trknum].frames = outinfo.track[trknum+1].idx0offs - outinfo.track[trknum].idx0offs;

View File

@ -362,7 +362,7 @@ bool core_options::parse_command_line(int argc, char **argv, int priority, astri
if (curentry->type() == OPTION_COMMAND)
{
// can only have one command
if (m_command)
if (!m_command.empty())
{
error_string.catprintf("Error: multiple commands specified -%s and %s\n", m_command.c_str(), curarg);
return false;
@ -701,7 +701,7 @@ void core_options::remove_entry(core_options::entry &delentry)
{
// remove all names from the map
for (int name = 0; name < ARRAY_LENGTH(delentry.m_name); name++)
if (delentry.m_name[name])
if (!delentry.m_name[name].empty())
m_entrymap.remove(delentry.m_name[name].c_str());
// remove the entry from the list

View File

@ -75,7 +75,7 @@ public:
public:
// getters
entry *next() const { return m_next; }
const char *name(int index = 0) const { return (index < ARRAY_LENGTH(m_name) && m_name[index]) ? m_name[index].c_str() : NULL; }
const char *name(int index = 0) const { return (index < ARRAY_LENGTH(m_name) && !m_name[index].empty()) ? m_name[index].c_str() : NULL; }
const char *description() const { return m_description; }
const char *value() const { return m_data.c_str(); }
const char *default_value() const { return m_defdata.c_str(); }
@ -87,7 +87,7 @@ public:
bool is_header() const { return type() == OPTION_HEADER; }
bool is_command() const { return type() == OPTION_COMMAND; }
bool is_internal() const { return m_flags & OPTION_FLAG_INTERNAL; }
bool has_range() const { return (m_minimum && m_maximum); }
bool has_range() const { return (!m_minimum.empty() && !m_maximum.empty()); }
int priority() const { return m_priority; }
// setters

View File

@ -481,7 +481,7 @@ static void dview_draw_title(DView *dv)
dview_draw_outlined_box(dv, RECT_DVIEW_TITLE, 0, 0, dv->bounds.width(), TITLE_HEIGHT, col);
if (!dv->title)
if (dv->title.empty())
return;
for (i = 0; i<strlen(dv->title.c_str()); i++)

View File

@ -551,7 +551,7 @@ void windows_osd_interface::init(running_machine &machine)
options.set_value(OSDOPTION_SOUND, "none", OPTION_PRIORITY_MAXIMUM, error_string);
options.set_value(OSDOPTION_VIDEO, "none", OPTION_PRIORITY_MAXIMUM, error_string);
options.set_value(OPTION_SECONDS_TO_RUN, bench, OPTION_PRIORITY_MAXIMUM, error_string);
assert(!error_string);
assert(error_string.empty());
}
// determine if we are profiling, and adjust options appropriately
@ -561,7 +561,7 @@ void windows_osd_interface::init(running_machine &machine)
options.set_value(OPTION_THROTTLE, false, OPTION_PRIORITY_MAXIMUM, error_string);
options.set_value(OSDOPTION_MULTITHREADING, false, OPTION_PRIORITY_MAXIMUM, error_string);
options.set_value(OSDOPTION_NUMPROCESSORS, 1, OPTION_PRIORITY_MAXIMUM, error_string);
assert(!error_string);
assert(error_string.empty());
}
// thread priority

View File

@ -320,7 +320,7 @@ public:
if (offset >= startoffs && offset < endoffs)
{
// if we don't already have this file open, open it now
if (m_file == NULL || m_lastfile != m_info.track[tracknum].fname)
if (m_file == NULL || m_lastfile.cmp(m_info.track[tracknum].fname)!=0)
{
if (m_file != NULL)
core_fclose(m_file);

View File

@ -318,7 +318,7 @@ static int join_file(const char *filename, const char *outname, int write_output
compute_hash_as_string(computedhash, splitbuffer, length);
// compare
if (computedhash != expectedhash)
if (computedhash.cmp(expectedhash)!=0)
{
printf("\n");
fprintf(stderr, "Fatal error: file '%s' has incorrect hash\n Expected: %s\n Computed: %s\n", infilename.c_str(), expectedhash.c_str(), computedhash.c_str());

View File

@ -423,7 +423,7 @@ static int recurse_dir(int srcrootlen, int dstrootlen, astring &srcdir, astring
dstfile.printf("%s%c%s.html", dstdir.c_str(), PATH_SEPARATOR[0], curlist->name.c_str());
if (indexfile != NULL)
core_fprintf(indexfile, "\t<li><a href=\"%s.html\">%s</a></li>\n", curlist->name.c_str(), curlist->name.c_str());
result = output_file(type, srcrootlen, dstrootlen, srcfile, dstfile, srcdir == dstdir, tempheader, tempfooter);
result = output_file(type, srcrootlen, dstrootlen, srcfile, dstfile, srcdir.cmp(dstdir)==0, tempheader, tempfooter);
}
}
@ -879,7 +879,7 @@ static bool find_include_file(astring &srcincpath, int srcrootlen, int dstrootle
astring tempinc(srcincpath, 0, sepindex);
// if we don't match, stop
if (tempfile != tempinc)
if (tempfile.cmp(tempinc)!=0)
break;
lastsepindex = sepindex + 1;
}