seperate Mu::format and Mu::vformat
This commit is contained in:
@ -67,7 +67,7 @@ struct Error final: public std::exception {
|
||||
Error(Code codearg, const char *frm, ...): code_{codearg} {
|
||||
va_list args;
|
||||
va_start(args, frm);
|
||||
what_ = format(frm, args);
|
||||
what_ = vformat(frm, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
@ -89,7 +89,7 @@ struct Error final: public std::exception {
|
||||
|
||||
va_list args;
|
||||
va_start(args, frm);
|
||||
what_ = format(frm, args);
|
||||
what_ = vformat(frm, args);
|
||||
va_end(args);
|
||||
|
||||
if (err && *err)
|
||||
|
||||
@ -32,7 +32,7 @@ parsing_error(size_t pos, const char* frm, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, frm);
|
||||
auto msg = format(frm, args);
|
||||
auto msg = vformat(frm, args);
|
||||
va_end(args);
|
||||
|
||||
if (pos == 0)
|
||||
|
||||
@ -204,14 +204,14 @@ Mu::quote (const std::string& str)
|
||||
va_list args;
|
||||
|
||||
va_start (args, frm);
|
||||
auto str = format(frm, args);
|
||||
auto str = vformat(frm, args);
|
||||
va_end (args);
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
std::string
|
||||
Mu::format (const char *frm, va_list args)
|
||||
Mu::vformat (const char *frm, va_list args)
|
||||
{
|
||||
char *s{};
|
||||
const auto res = g_vasprintf (&s, frm, args);
|
||||
|
||||
@ -104,7 +104,7 @@ std::string format (const char *frm, ...) __attribute__((format(printf, 1, 2)));
|
||||
*
|
||||
* @return a formatted string
|
||||
*/
|
||||
std::string format (const char *frm, va_list args) __attribute__((format(printf, 1, 0)));
|
||||
std::string vformat (const char *frm, va_list args) __attribute__((format(printf, 1, 0)));
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@ -168,6 +168,8 @@ test_clean ()
|
||||
static void
|
||||
test_format ()
|
||||
{
|
||||
g_assert_true (format ("hello %s", "world") ==
|
||||
"hello world");
|
||||
g_assert_true (format ("hello %s, %u", "world", 123) ==
|
||||
"hello world, 123");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user