summaryrefslogtreecommitdiffstatshomepage
path: root/src/frontend/mame
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2019-09-26 20:53:06 +1000
committer Vas Crabb <vas@vastheman.com>2019-09-26 20:53:06 +1000
commit9a12ab37afb3e43d9d3c296b34348b835bafb2ea (patch)
tree6af7ce1fc5f52b1518100a1be926514cd2f34feb /src/frontend/mame
parent9d4b7b02acdb79fac05606f57c3fddd08593cba8 (diff)
Make osd_printf_* use util/strformat semantics.
(nw) This has been a long time coming but it's here at last. It should be easier now that logerror, popmessage and osd_printf_* behave like string_format and stream_format. Remember the differences from printf: * Any object with a stream out operator works with %s * %d, %i, %o, %x, %X, etc. work out the size by magic * No sign extending promotion to int for short/char * No widening/narrowing conversions for characters/strings * Same rules on all platforms, insulated from C runtime library * No format warnings from compiler * Assert in debug builds if number of arguments doesn't match format (nw) Also removed a pile of redundant c_str and string_format, and some workarounds for not being able to portably format 64-bit integers or long long.
Diffstat (limited to 'src/frontend/mame')
-rw-r--r--src/frontend/mame/cheat.cpp4
-rw-r--r--src/frontend/mame/clifront.cpp18
-rw-r--r--src/frontend/mame/media_ident.cpp12
-rw-r--r--src/frontend/mame/pluginopts.cpp7
-rw-r--r--src/frontend/mame/ui/filesel.cpp2
-rw-r--r--src/frontend/mame/ui/inifile.cpp4
-rw-r--r--src/frontend/mame/ui/miscmenu.cpp4
-rw-r--r--src/frontend/mame/ui/selmenu.cpp2
-rw-r--r--src/frontend/mame/ui/selsoft.cpp4
9 files changed, 28 insertions, 29 deletions
diff --git a/src/frontend/mame/cheat.cpp b/src/frontend/mame/cheat.cpp
index 815c788e241..26737460fee 100644
--- a/src/frontend/mame/cheat.cpp
+++ b/src/frontend/mame/cheat.cpp
@@ -810,14 +810,14 @@ bool cheat_entry::activate()
// if we're a oneshot cheat, execute the "on" script and indicate change
execute_on_script();
changed = true;
- m_manager.machine().popmessage("Activated %s", m_description.c_str());
+ m_manager.machine().popmessage("Activated %s", m_description);
}
else if (is_oneshot_parameter() && (m_state != SCRIPT_STATE_OFF))
{
// if we're a oneshot parameter cheat and we're active, execute the "state change" script and indicate change
execute_change_script();
changed = true;
- m_manager.machine().popmessage("Activated\n %s = %s", m_description.c_str(), m_parameter->text());
+ m_manager.machine().popmessage("Activated\n %s = %s", m_description, m_parameter->text());
}
return changed;
diff --git a/src/frontend/mame/clifront.cpp b/src/frontend/mame/clifront.cpp
index d8c1420e656..46c7f9cbe63 100644
--- a/src/frontend/mame/clifront.cpp
+++ b/src/frontend/mame/clifront.cpp
@@ -252,7 +252,7 @@ void cli_frontend::start_execution(mame_machine_manager *manager, const std::vec
if (option_errors.tellp() > 0)
{
std::string option_errors_string = option_errors.str();
- osd_printf_error("Error in command line:\n%s\n", strtrimspace(option_errors_string).c_str());
+ osd_printf_error("Error in command line:\n%s\n", strtrimspace(option_errors_string));
}
// if we can't find it, give an appropriate error
@@ -284,7 +284,7 @@ int cli_frontend::execute(std::vector<std::string> &args)
{
std::string str(fatal.string());
strtrimspace(str);
- osd_printf_error("%s\n", str.c_str());
+ osd_printf_error("%s\n", str);
m_result = (fatal.exitcode() != 0) ? fatal.exitcode() : EMU_ERR_FATALERROR;
// if a game was specified, wasn't a wildcard, and our error indicates this was the
@@ -313,7 +313,7 @@ int cli_frontend::execute(std::vector<std::string> &args)
if (0 <= match)
{
game_driver const &drv(drivlist.driver(match));
- osd_printf_error("%s", util::string_format("%-18s%-*s(%s, %s)\n", drv.name, titlelen + 2, drv.type.fullname(), drv.manufacturer, drv.year).c_str());
+ osd_printf_error("%-18s%-*s(%s, %s)\n", drv.name, titlelen + 2, drv.type.fullname(), drv.manufacturer, drv.year);
}
}
}
@@ -392,7 +392,7 @@ void cli_frontend::listsource(const std::vector<std::string> &args)
{
auto const list_system_source = [] (device_type type)
{
- osd_printf_info("%-16s %s\n", type.shortname(), core_filename_extract_base(type.source()).c_str());
+ osd_printf_info("%-16s %s\n", type.shortname(), core_filename_extract_base(type.source()));
};
apply_action(
args,
@@ -493,9 +493,9 @@ void cli_frontend::listbrothers(const std::vector<std::string> &args)
{
int clone_of = drivlist.clone();
if (clone_of != -1)
- osd_printf_info("%-20s %-16s %s\n", core_filename_extract_base(drivlist.driver().type.source()).c_str(), drivlist.driver().name, (clone_of == -1 ? "" : drivlist.driver(clone_of).name));
+ osd_printf_info("%-20s %-16s %s\n", core_filename_extract_base(drivlist.driver().type.source()), drivlist.driver().name, (clone_of == -1 ? "" : drivlist.driver(clone_of).name));
else
- osd_printf_info("%-20s %s\n", core_filename_extract_base(drivlist.driver().type.source()).c_str(), drivlist.driver().name);
+ osd_printf_info("%-20s %s\n", core_filename_extract_base(drivlist.driver().type.source()), drivlist.driver().name);
}
}
@@ -580,7 +580,7 @@ void cli_frontend::listroms(const std::vector<std::string> &args)
{
if (hashes.flag(util::hash_collection::FLAG_BAD_DUMP))
osd_printf_info(" BAD");
- osd_printf_info(" %s", hashes.macro_string().c_str());
+ osd_printf_info(" %s", hashes.macro_string());
}
else
osd_printf_info(" NO GOOD DUMP KNOWN");
@@ -1615,7 +1615,7 @@ void cli_frontend::execute_commands(const char *exename)
if (m_options.command() == CLICOMMAND_SHOWUSAGE)
{
osd_printf_info("Usage: %s [machine] [media] [software] [options]",exename);
- osd_printf_info("\n\nOptions:\n%s", m_options.output_help().c_str());
+ osd_printf_info("\n\nOptions:\n%s", m_options.output_help());
return;
}
@@ -1640,7 +1640,7 @@ void cli_frontend::execute_commands(const char *exename)
std::ostringstream option_errors;
mame_options::parse_standard_inis(m_options,option_errors);
if (option_errors.tellp() > 0)
- osd_printf_error("%s\n", option_errors.str().c_str());
+ osd_printf_error("%s\n", option_errors.str());
// createconfig?
if (m_options.command() == CLICOMMAND_CREATECONFIG)
diff --git a/src/frontend/mame/media_ident.cpp b/src/frontend/mame/media_ident.cpp
index d15bee95dae..dc88fae4365 100644
--- a/src/frontend/mame/media_ident.cpp
+++ b/src/frontend/mame/media_ident.cpp
@@ -161,18 +161,18 @@ void media_identifier::collect_files(std::vector<file_info> &info, char const *p
if (util::archive_file::error::NONE == err)
digest_data(info, curfile.c_str(), &data[0], length);
else
- osd_printf_error("%s: error decompressing file\n", curfile.c_str());
+ osd_printf_error("%s: error decompressing file\n", curfile);
}
catch (...)
{
// resizing the buffer could cause a bad_alloc if archive contains large files
- osd_printf_error("%s: error decompressing file\n", curfile.c_str());
+ osd_printf_error("%s: error decompressing file\n", curfile);
}
data.clear();
}
else
{
- osd_printf_error("%s: file too large to decompress into memory\n", curfile.c_str());
+ osd_printf_error("%s: file too large to decompress into memory\n", curfile);
}
}
}
@@ -209,12 +209,12 @@ void media_identifier::digest_file(std::vector<file_info> &info, char const *pat
m_total++;
if (err != CHDERR_NONE)
{
- osd_printf_info("%-20sNOT A CHD\n", core_filename_extract_base(path).c_str());
+ osd_printf_info("%-20sNOT A CHD\n", core_filename_extract_base(path));
m_nonroms++;
}
else if (!chd.compressed())
{
- osd_printf_info("%-20sis a writeable CHD\n", core_filename_extract_base(path).c_str());
+ osd_printf_info("%-20sis a writeable CHD\n", core_filename_extract_base(path));
}
else
{
@@ -413,7 +413,7 @@ void media_identifier::print_results(std::vector<file_info> const &info)
{
for (file_info const &file : info)
{
- osd_printf_info("%-20s", core_filename_extract_base(file.name()).c_str());
+ osd_printf_info("%-20s", core_filename_extract_base(file.name()));
if (file.matches().empty())
{
osd_printf_info("NO MATCH\n");
diff --git a/src/frontend/mame/pluginopts.cpp b/src/frontend/mame/pluginopts.cpp
index 5bbddaf1473..3828be3c8cd 100644
--- a/src/frontend/mame/pluginopts.cpp
+++ b/src/frontend/mame/pluginopts.cpp
@@ -73,15 +73,14 @@ bool plugin_options::load_plugin(const std::string &path)
if (document.HasParseError())
{
- std::string error(GetParseError_En(document.GetParseError()));
- osd_printf_error("Unable to parse plugin definition file %s. Errors returned:\n", path.c_str());
- osd_printf_error("%s\n", error.c_str());
+ const std::string error(GetParseError_En(document.GetParseError()));
+ osd_printf_error("Unable to parse plugin definition file %s. Errors returned:\n%s", path, error);
return false;
}
if (!document["plugin"].IsObject())
{
- osd_printf_error("Bad plugin definition file %s:\n", path.c_str());
+ osd_printf_error("Bad plugin definition file %s:\n", path);
return false;
}
diff --git a/src/frontend/mame/ui/filesel.cpp b/src/frontend/mame/ui/filesel.cpp
index 49136d04f64..9e9d5e44296 100644
--- a/src/frontend/mame/ui/filesel.cpp
+++ b/src/frontend/mame/ui/filesel.cpp
@@ -421,7 +421,7 @@ void menu_file_selector::populate(float &customtop, float &custombottom)
// build the menu for each item
if (osd_file::error::NONE != err)
{
- osd_printf_verbose("menu_file_selector::populate: error opening directory '%s' (%d)\n", m_current_directory.c_str(), int(err));
+ osd_printf_verbose("menu_file_selector::populate: error opening directory '%s' (%d)\n", m_current_directory, int(err));
}
else
{
diff --git a/src/frontend/mame/ui/inifile.cpp b/src/frontend/mame/ui/inifile.cpp
index b68be00122b..028abc9c87b 100644
--- a/src/frontend/mame/ui/inifile.cpp
+++ b/src/frontend/mame/ui/inifile.cpp
@@ -64,7 +64,7 @@ void inifile_manager::load_ini_category(size_t file, size_t category, std::unord
emu_file fp(m_options.categoryini_path(), OPEN_FLAG_READ);
if (fp.open(filename) != osd_file::error::NONE)
{
- osd_printf_error("Failed to open category file %s for reading\n", filename.c_str());
+ osd_printf_error("Failed to open category file %s for reading\n", filename);
return;
}
@@ -72,7 +72,7 @@ void inifile_manager::load_ini_category(size_t file, size_t category, std::unord
if (fp.seek(offset, SEEK_SET) || (fp.tell() != offset))
{
fp.close();
- osd_printf_error("Failed to seek to category offset in file %s\n", filename.c_str());
+ osd_printf_error("Failed to seek to category offset in file %s\n", filename);
return;
}
diff --git a/src/frontend/mame/ui/miscmenu.cpp b/src/frontend/mame/ui/miscmenu.cpp
index 397eb5801ff..0c263e2b875 100644
--- a/src/frontend/mame/ui/miscmenu.cpp
+++ b/src/frontend/mame/ui/miscmenu.cpp
@@ -608,7 +608,7 @@ void menu_export::handle()
// and do the dirty work
info_xml_creator creator(machine().options());
creator.output(pfile, filter, include_devices);
- machine().popmessage(_("%s.xml saved under ui folder."), filename.c_str());
+ machine().popmessage(_("%s.xml saved under ui folder."), filename);
}
}
break;
@@ -645,7 +645,7 @@ void menu_export::handle()
util::stream_format(buffer, "%-18s\"%s\"\n", drvlist.driver().name, drvlist.driver().type.fullname());
file.puts(buffer.str().c_str());
file.close();
- machine().popmessage(_("%s.txt saved under ui folder."), filename.c_str());
+ machine().popmessage(_("%s.txt saved under ui folder."), filename);
}
}
break;
diff --git a/src/frontend/mame/ui/selmenu.cpp b/src/frontend/mame/ui/selmenu.cpp
index 1833f61528c..a021348c273 100644
--- a/src/frontend/mame/ui/selmenu.cpp
+++ b/src/frontend/mame/ui/selmenu.cpp
@@ -1013,7 +1013,7 @@ void menu_select_launch::check_for_icons(char const *listname)
current.append(PATH_SEPARATOR);
current.append(listname);
}
- osd_printf_verbose("Checking for icons in directory %s\n", current.c_str());
+ osd_printf_verbose("Checking for icons in directory %s\n", current);
// open and walk the directory
osd::directory::ptr const dir(osd::directory::open(current));
diff --git a/src/frontend/mame/ui/selsoft.cpp b/src/frontend/mame/ui/selsoft.cpp
index 4c86aaae9a4..ef5d6a5d1c3 100644
--- a/src/frontend/mame/ui/selsoft.cpp
+++ b/src/frontend/mame/ui/selsoft.cpp
@@ -225,12 +225,12 @@ void menu_select_software::handle()
if (!mfav.is_favorite_system_software(*swinfo))
{
mfav.add_favorite_software(*swinfo);
- machine().popmessage(_("%s\n added to favorites list."), swinfo->longname.c_str());
+ machine().popmessage(_("%s\n added to favorites list."), swinfo->longname);
}
else
{
- machine().popmessage(_("%s\n removed from favorites list."), swinfo->longname.c_str());
+ machine().popmessage(_("%s\n removed from favorites list."), swinfo->longname);
mfav.remove_favorite_software(*swinfo);
}
}