From 841a55985e60a16f745422fb9aa06c420d8be8ba Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Mon, 18 Jan 2016 14:38:07 +0100 Subject: [PATCH] Fix for hang, emu_options::add_slot_options was changed, other things are just cleanup (nw) --- src/emu/clifront.cpp | 2 +- src/emu/debug/express.cpp | 6 +++--- src/emu/dislot.cpp | 4 ++-- src/emu/emuopts.cpp | 14 +++++++------- src/emu/mconfig.cpp | 8 ++++---- src/emu/romload.cpp | 2 +- src/emu/screen.cpp | 2 +- src/emu/ui/info_pty.cpp | 2 +- src/emu/ui/miscmenu.cpp | 6 +++--- src/emu/ui/slotopt.cpp | 6 +++--- src/emu/validity.cpp | 2 +- 11 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/emu/clifront.cpp b/src/emu/clifront.cpp index 21205e2beac..85593abe260 100644 --- a/src/emu/clifront.cpp +++ b/src/emu/clifront.cpp @@ -648,7 +648,7 @@ void cli_frontend::listslots(const char *gamename) { if (slot->fixed()) continue; // output the line, up to the list of extensions - printf("%-13s%-10s ", first ? drivlist.driver().name : "", std::string(slot->device().tag()).erase(0,1).c_str()); + printf("%-13s%-10s ", first ? drivlist.driver().name : "", std::string(slot->device().tag()).substr(1).c_str()); bool first_option = true; diff --git a/src/emu/debug/express.cpp b/src/emu/debug/express.cpp index 62324092a28..ebd2e1d4889 100644 --- a/src/emu/debug/express.cpp +++ b/src/emu/debug/express.cpp @@ -927,15 +927,15 @@ void parsed_expression::parse_symbol_or_number(parse_token &token, const char *& // if we have an 0x prefix, we must be a hex value if (buffer[0] == '0' && buffer[1] == 'x') - return parse_number(token, buffer.c_str() + 2, 16, expression_error::INVALID_NUMBER); + return parse_number(token, buffer.substr(2).c_str(), 16, expression_error::INVALID_NUMBER); // if we have a # prefix, we must be a decimal value if (buffer[0] == '#') - return parse_number(token, buffer.c_str() + 1, 10, expression_error::INVALID_NUMBER); + return parse_number(token, buffer.substr(1).c_str(), 10, expression_error::INVALID_NUMBER); // if we have a $ prefix, we are a hex value if (buffer[0] == '$') - return parse_number(token, buffer.c_str() + 1, 16, expression_error::INVALID_NUMBER); + return parse_number(token, buffer.substr(1).c_str(), 16, expression_error::INVALID_NUMBER); // check for a symbol match symbol_entry *symbol = m_symtable->find_deep(buffer.c_str()); diff --git a/src/emu/dislot.cpp b/src/emu/dislot.cpp index f5522a17aea..a7b1ffa22e3 100644 --- a/src/emu/dislot.cpp +++ b/src/emu/dislot.cpp @@ -65,8 +65,8 @@ device_t* device_slot_interface::get_card_device() { std::string subtag; device_t *dev = nullptr; - if (device().mconfig().options().exists(device().tag().c_str()+1)) - subtag = device().mconfig().options().main_value(device().tag().c_str()+1); + if (device().mconfig().options().exists(device().tag().substr(1).c_str())) + subtag = device().mconfig().options().main_value(device().tag().substr(1).c_str()); else if (m_default_option != nullptr) subtag.assign(m_default_option); if (!subtag.empty()) { diff --git a/src/emu/emuopts.cpp b/src/emu/emuopts.cpp index 627b4b0a991..34c8eb4ff20 100644 --- a/src/emu/emuopts.cpp +++ b/src/emu/emuopts.cpp @@ -241,19 +241,19 @@ bool emu_options::add_slot_options(bool isfirstpass) first = false; // retrieve info about the device instance - const char *name = slot->device().tag().c_str() + 1; - if (!exists(name)) + std::string name(slot->device().tag().substr(1).c_str()); + if (!exists(name.c_str())) { // add the option UINT32 flags = OPTION_STRING | OPTION_FLAG_DEVICE; - const char *defvalue = slot->default_option(); - if (defvalue != nullptr) + std::string defvalue = (slot->default_option()==nullptr) ? std::string() : slot->default_option(); + if (defvalue.length() > 0) { - const device_slot_option *option = slot->option(defvalue); + const device_slot_option *option = slot->option(defvalue.c_str()); if (option != nullptr && !option->selectable()) flags |= OPTION_FLAG_INTERNAL; } - add_entry(name, nullptr, flags, defvalue, true); + add_entry(name.c_str(), nullptr, flags, defvalue.c_str(), true); } } return (options_count() != starting_count); @@ -278,7 +278,7 @@ void emu_options::update_slot_options() for (device_slot_interface *slot = iter.first(); slot != nullptr; slot = iter.next()) { // retrieve info about the device instance - std::string name(slot->device().tag().c_str()+1); + std::string name(slot->device().tag().substr(1).c_str()); if (exists(name.c_str()) && slot->first_option() != nullptr) { std::string defvalue = slot->get_default_card_software(); diff --git a/src/emu/mconfig.cpp b/src/emu/mconfig.cpp index 9e86e2206ad..a138842c2a5 100644 --- a/src/emu/mconfig.cpp +++ b/src/emu/mconfig.cpp @@ -40,9 +40,9 @@ machine_config::machine_config(const game_driver &gamedrv, emu_options &options) { device_t &owner = slot->device(); std::string selval; - bool isdefault = (options.priority(owner.tag().c_str()+1)==OPTION_PRIORITY_DEFAULT); - if (is_selected_driver && options.exists(owner.tag().c_str()+1)) - selval = options.main_value(owner.tag().c_str()+1); + bool isdefault = (options.priority(owner.tag().substr(1).c_str())==OPTION_PRIORITY_DEFAULT); + if (is_selected_driver && options.exists(owner.tag().substr(1).c_str())) + selval = options.main_value(owner.tag().substr(1).c_str()); else if (slot->default_option() != nullptr) selval.assign(slot->default_option()); @@ -67,7 +67,7 @@ machine_config::machine_config(const game_driver &gamedrv, emu_options &options) device_t::static_set_input_default(*new_dev, input_device_defaults); } else - throw emu_fatalerror("Unknown slot option '%s' in slot '%s'", selval.c_str(), owner.tag().c_str()+1); + throw emu_fatalerror("Unknown slot option '%s' in slot '%s'", selval.c_str(), owner.tag().substr(1).c_str()); } } diff --git a/src/emu/romload.cpp b/src/emu/romload.cpp index da47851b40b..41526d97e95 100644 --- a/src/emu/romload.cpp +++ b/src/emu/romload.cpp @@ -1460,7 +1460,7 @@ rom_load_manager::rom_load_manager(running_machine &machine) if (device->owner() == nullptr) { specbios.assign(machine.options().bios()); } else { - specbios = machine.options().sub_value(std::string(device->owner()->tag()).c_str()+1,"bios"); + specbios = machine.options().sub_value(std::string(device->owner()->tag()).substr(1).c_str(),"bios"); if (specbios.empty()) { specbios = device->default_bios_tag(); } diff --git a/src/emu/screen.cpp b/src/emu/screen.cpp index fc33c2e342f..e634ec66df2 100644 --- a/src/emu/screen.cpp +++ b/src/emu/screen.cpp @@ -1140,7 +1140,7 @@ void screen_device::finalize_burnin() // compute the name and create the file emu_file file(machine().options().snapshot_directory(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS); - file_error filerr = file.open(machine().basename(), PATH_SEPARATOR "burnin-", this->tag().c_str() + 1, ".png") ; + file_error filerr = file.open(machine().basename(), PATH_SEPARATOR "burnin-", this->tag().substr(1).c_str(), ".png") ; if (filerr == FILERR_NONE) { png_info pnginfo = { nullptr }; diff --git a/src/emu/ui/info_pty.cpp b/src/emu/ui/info_pty.cpp index 9d2710c82e0..1562f82018a 100644 --- a/src/emu/ui/info_pty.cpp +++ b/src/emu/ui/info_pty.cpp @@ -28,7 +28,7 @@ void ui_menu_pty_info::populate() pty_interface_iterator iter(machine().root_device()); for (device_pty_interface *pty = iter.first(); pty != nullptr; pty = iter.next()) { - const char *port_name = pty->device().owner()->tag().c_str() + 1; + const char *port_name = pty->device().owner()->tag().substr(1).c_str(); if (pty->is_open()) { item_append(port_name , pty->slave_name() , MENU_FLAG_DISABLE , nullptr); } else { diff --git a/src/emu/ui/miscmenu.cpp b/src/emu/ui/miscmenu.cpp index e9b095e97f3..59153c96ad6 100644 --- a/src/emu/ui/miscmenu.cpp +++ b/src/emu/ui/miscmenu.cpp @@ -81,7 +81,7 @@ void ui_menu_bios_selection::populate() val = ROM_GETHASHDATA(rom); } } - item_append(device->tag()==":" ? "driver" : device->tag().c_str()+1, val, MENU_FLAG_LEFT_ARROW | MENU_FLAG_RIGHT_ARROW, (void *)device); + item_append(device->tag()==":" ? "driver" : device->tag().substr(1).c_str(), val, MENU_FLAG_LEFT_ARROW | MENU_FLAG_RIGHT_ARROW, (void *)device); } } @@ -124,9 +124,9 @@ void ui_menu_bios_selection::handle() assert(error.empty()); } else { std::string error; - std::string value = machine().options().main_value(dev->owner()->tag().c_str()+1); + std::string value = machine().options().main_value(dev->owner()->tag().substr(1).c_str()); strcatprintf(value,",bios=%d",val-1); - machine().options().set_value(dev->owner()->tag().c_str()+1, value.c_str(), OPTION_PRIORITY_CMDLINE, error); + machine().options().set_value(dev->owner()->tag().substr(1).c_str(), value.c_str(), OPTION_PRIORITY_CMDLINE, error); assert(error.empty()); } reset(UI_MENU_RESET_REMEMBER_REF); diff --git a/src/emu/ui/slotopt.cpp b/src/emu/ui/slotopt.cpp index 7dd12a302a1..f115cb1b5a1 100644 --- a/src/emu/ui/slotopt.cpp +++ b/src/emu/ui/slotopt.cpp @@ -29,7 +29,7 @@ device_slot_option *ui_menu_slot_devices::slot_get_current_option(device_slot_in } else { - current = machine().options().main_value(slot->device().tag().c_str() + 1); + current = machine().options().main_value(slot->device().tag().substr(1).c_str()); } return slot->option(current.c_str()); @@ -135,7 +135,7 @@ const char *ui_menu_slot_devices::slot_get_option(device_slot_interface *slot, i void ui_menu_slot_devices::set_slot_device(device_slot_interface *slot, const char *val) { std::string error; - machine().options().set_value(slot->device().tag().c_str()+1, val, OPTION_PRIORITY_CMDLINE, error); + machine().options().set_value(slot->device().tag().substr(1).c_str(), val, OPTION_PRIORITY_CMDLINE, error); assert(error.empty()); } @@ -166,7 +166,7 @@ void ui_menu_slot_devices::populate() opt_name.append(" [internal]"); } - item_append(slot->device().tag().c_str() + 1, opt_name.c_str(), (slot->fixed() || slot_get_length(slot) == 0) ? 0 : (MENU_FLAG_LEFT_ARROW | MENU_FLAG_RIGHT_ARROW), (void *)slot); + item_append(slot->device().tag().substr(1).c_str(), opt_name.c_str(), (slot->fixed() || slot_get_length(slot) == 0) ? 0 : (MENU_FLAG_LEFT_ARROW | MENU_FLAG_RIGHT_ARROW), (void *)slot); } item_append(MENU_SEPARATOR_ITEM, nullptr, 0, nullptr); item_append("Reset", nullptr, 0, (void *)1); diff --git a/src/emu/validity.cpp b/src/emu/validity.cpp index fa8c8c58ef1..b3068ae7993 100644 --- a/src/emu/validity.cpp +++ b/src/emu/validity.cpp @@ -1042,7 +1042,7 @@ void validity_checker::build_output_prefix(std::string &str) // if we have a current (non-root) device, indicate that if (m_current_device != nullptr && m_current_device->owner() != nullptr) - str.append(m_current_device->name()).append(" device '").append(m_current_device->tag().c_str()+1).append("': "); + str.append(m_current_device->name()).append(" device '").append(m_current_device->tag().substr(1).c_str()).append("': "); // if we have a current port, indicate that as well if (m_current_ioport != nullptr)