From: Mikko Rasa Date: Mon, 19 Dec 2022 19:11:40 +0000 (+0200) Subject: Use format() when creating strings from more than two parts X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=8b133e26e29abbe79886c47d57637eb18ea9cb24;p=builder.git Use format() when creating strings from more than two parts --- diff --git a/source/androidapplicationcomponent.cpp b/source/androidapplicationcomponent.cpp index 26277c8..95eb944 100644 --- a/source/androidapplicationcomponent.cpp +++ b/source/androidapplicationcomponent.cpp @@ -1,4 +1,5 @@ #include +#include #include "androidapplicationcomponent.h" #include "androidmanifestfile.h" #include "androidresourcefile.h" @@ -50,7 +51,7 @@ void AndroidApplicationComponent::create_targets() const apk_sources.push_back(resource_bundle); const Architecture &arch = package.get_builder().get_current_arch(); - string lib_dir = "//"+name+"/lib/"; + string lib_dir = format("//%s/lib/", name); if(arch.get_type()=="arm") { lib_dir += "armeabi"; @@ -60,7 +61,7 @@ void AndroidApplicationComponent::create_targets() const else lib_dir += arch.get_type(); - string assets_dir = "//"+name+"/assets"; + string assets_dir = format("//%s/assets", name); for(Target *t: contents) { Target *staged = 0; diff --git a/source/booleanevaluator.cpp b/source/booleanevaluator.cpp index 6891abc..58a6fcf 100644 --- a/source/booleanevaluator.cpp +++ b/source/booleanevaluator.cpp @@ -1,7 +1,9 @@ #include +#include #include "booleanevaluator.h" using namespace std; +using namespace Msp; BooleanEvaluator::BooleanEvaluator(const ValueFunction &f): func([&f](const string &value, const string *){ return f(value); }), @@ -51,7 +53,7 @@ bool BooleanEvaluator::evaluate(const string &str) else if(ops.find(*i)!=string::npos) push_op(*i); else - throw runtime_error("syntax error at "+string(1, *i)); + throw runtime_error(format("syntax error at %c", *i)); } } @@ -67,7 +69,7 @@ bool BooleanEvaluator::evaluate(const string &str) void BooleanEvaluator::push_op(char op) { if(last_was_op!=is_unary(op)) - throw runtime_error("syntax error at "+string(1, op)); + throw runtime_error(format("syntax error at %c", op)); // TODO Disallow mixing of ! and =/^ if(is_logic(op) && !var_stack.empty()) value_stack.push_back(pop_value()); diff --git a/source/gnucompiler.cpp b/source/gnucompiler.cpp index 2928cbf..26570c7 100644 --- a/source/gnucompiler.cpp +++ b/source/gnucompiler.cpp @@ -162,7 +162,7 @@ void GnuCompiler::prepare_syspath() else if(architecture->is_native()) system_path.push_back("/usr/include"); else - system_path.push_back("/usr/"+architecture->get_cross_prefix()+"/include"); + system_path.push_back(format("/usr/%s/include", architecture->get_cross_prefix())); } } diff --git a/source/gnulinker.cpp b/source/gnulinker.cpp index 7a29016..61332b2 100644 --- a/source/gnulinker.cpp +++ b/source/gnulinker.cpp @@ -174,7 +174,7 @@ void GnuLinker::do_prepare() } } else - system_path.push_back("/usr/"+architecture->get_cross_prefix()+"/lib"); + system_path.push_back(format("/usr/%s/lib", architecture->get_cross_prefix())); } }