]> git.tdb.fi Git - builder.git/commitdiff
Use format() when creating strings from more than two parts
authorMikko Rasa <tdb@tdb.fi>
Mon, 19 Dec 2022 19:11:40 +0000 (21:11 +0200)
committerMikko Rasa <tdb@tdb.fi>
Mon, 19 Dec 2022 19:13:46 +0000 (21:13 +0200)
source/androidapplicationcomponent.cpp
source/booleanevaluator.cpp
source/gnucompiler.cpp
source/gnulinker.cpp

index 26277c8c02450fd8c75c065cc4f1e0a3ec090e0e..95eb9447dc3fe8bd88e684d1e86a6c876ef3f9a7 100644 (file)
@@ -1,4 +1,5 @@
 #include <msp/fs/utils.h>
+#include <msp/strings/format.h>
 #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;
index 6891abceff9a8088db506c6ea1388664830fb4f1..58a6fcf1a682b53aa0c6ef54627a9f7729f7eecd 100644 (file)
@@ -1,7 +1,9 @@
 #include <stdexcept>
+#include <msp/strings/format.h>
 #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());
index 2928cbfe21b30c88ea0b1d8a538ade7449b2f443..26570c702602978a286d9c146a689b5fe515d9e8 100644 (file)
@@ -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()));
        }
 }
 
index 7a2901679deed67df744220b87e1cb84f5aa4c50..61332b2452a3e39069d2f1084008fb199b838c7c 100644 (file)
@@ -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()));
        }
 }