[beast/devel: 33/35] BST: bst_msg_bit_printf: use string_format() which is type-safe and locale-stable
- From: Tim Janik <timj src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [beast/devel: 33/35] BST: bst_msg_bit_printf: use string_format() which is type-safe and locale-stable
- Date: Tue, 14 May 2013 19:40:41 +0000 (UTC)
commit 8d759d1b51f298bcef1d36e0bda1ce5d65b19851
Author: Tim Janik <timj gnu org>
Date: Tue May 14 21:08:45 2013 +0200
BST: bst_msg_bit_printf: use string_format() which is type-safe and locale-stable
beast-gtk/bstusermessage.cc | 11 ++---------
beast-gtk/bstusermessage.hh | 5 ++---
2 files changed, 4 insertions(+), 12 deletions(-)
---
diff --git a/beast-gtk/bstusermessage.cc b/beast-gtk/bstusermessage.cc
index eeb7027..af3cfa3 100644
--- a/beast-gtk/bstusermessage.cc
+++ b/beast-gtk/bstusermessage.cc
@@ -302,20 +302,13 @@ bst_msg_bit_free (BstMsgBit *mbit)
}
BstMsgBit*
-bst_msg_bit_printf (guint8 msg_part_id,
- const char *format,
- ...)
+bst_msg_bit_create (guint8 msg_part_id, const std::string &text)
{
int saved_errno = errno;
/* construct message */
- va_list args;
- va_start (args, format);
- char *text = g_strdup_vprintf (format, args);
- va_end (args);
BstMsgBit *mbit = g_new0 (BstMsgBit, 1);
mbit->id = msg_part_id;
- mbit->text = g_strdup (text);
- g_free (text);
+ mbit->text = g_strdup (text.c_str());
mbit->stock_icon = NULL;
mbit->options = NULL;
errno = saved_errno;
diff --git a/beast-gtk/bstusermessage.hh b/beast-gtk/bstusermessage.hh
index 02a8557..350a350 100644
--- a/beast-gtk/bstusermessage.hh
+++ b/beast-gtk/bstusermessage.hh
@@ -52,9 +52,8 @@ guint bst_message_dialog_display (const char *log_dom
guint n_bits,
BstMsgBit **bits);
void bst_msg_bit_free (BstMsgBit *mbit);
-BstMsgBit* bst_msg_bit_printf (guint8 msg_part_id,
- const char *format,
- ...) G_GNUC_PRINTF (2, 3);
+#define bst_msg_bit_printf(msg_part_id, ...) bst_msg_bit_create (msg_part_id,
Rapicorn::string_format (__VA_ARGS__))
+BstMsgBit* bst_msg_bit_create (guint8 msg_part_id, const std::string &text);
BstMsgBit* bst_msg_bit_create_choice (guint id,
const gchar *name,
const gchar *stock_icon,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]