From a8ca33a33ad9d927a28334d8e4c45d5c40d16168 Mon Sep 17 00:00:00 2001
From: Clifford Wolf <clifford@clifford.at>
Date: Sat, 18 Aug 2018 14:13:27 +0200
Subject: Add stringf() helper function

Signed-off-by: Clifford Wolf <clifford@clifford.at>
---
 common/log.cc | 12 ++++++++++++
 common/log.h  |  3 +++
 2 files changed, 15 insertions(+)

diff --git a/common/log.cc b/common/log.cc
index df5430bb..e30449ad 100644
--- a/common/log.cc
+++ b/common/log.cc
@@ -46,6 +46,18 @@ void (*log_error_atexit)() = NULL;
 // static bool next_print_log = false;
 static int log_newline_count = 0;
 
+std::string stringf(const char *fmt, ...)
+{
+    std::string string;
+    va_list ap;
+
+    va_start(ap, fmt);
+    string = vstringf(fmt, ap);
+    va_end(ap);
+
+    return string;
+}
+
 std::string vstringf(const char *fmt, va_list ap)
 {
     std::string string;
diff --git a/common/log.h b/common/log.h
index 74b9f0f5..b5fddf53 100644
--- a/common/log.h
+++ b/common/log.h
@@ -51,6 +51,9 @@ extern bool log_quiet_warnings;
 extern std::string log_last_error;
 extern void (*log_error_atexit)();
 
+std::string stringf(const char *fmt, ...);
+std::string vstringf(const char *fmt, va_list ap);
+
 extern std::ostream clog;
 void log(const char *format, ...) NPNR_ATTRIBUTE(format(printf, 1, 2));
 void log_always(const char *format, ...) NPNR_ATTRIBUTE(format(printf, 1, 2));
-- 
cgit v1.2.3