[beast/devel: 18/35] SFI: WStore & RStore: eliminate printf-variants
- From: Tim Janik <timj src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [beast/devel: 18/35] SFI: WStore & RStore: eliminate printf-variants
- Date: Tue, 14 May 2013 19:39:25 +0000 (UTC)
commit d21a0a63e72d8bdecef53a10f2bc0b8eced06ada
Author: Tim Janik <timj gnu org>
Date: Mon May 13 01:06:07 2013 +0200
SFI: WStore & RStore: eliminate printf-variants
bse/bsestorage.cc | 6 ++--
sfi/sfistore.cc | 87 ++++++++++------------------------------------------
sfi/sfistore.hh | 20 ++----------
3 files changed, 24 insertions(+), 89 deletions(-)
---
diff --git a/bse/bsestorage.cc b/bse/bsestorage.cc
index d016688..417c377 100644
--- a/bse/bsestorage.cc
+++ b/bse/bsestorage.cc
@@ -981,7 +981,7 @@ bse_storage_warn (BseStorage *self,
string = g_strdup_vprintf (format, args);
va_end (args);
if (self->rstore)
- sfi_rstore_warn (self->rstore, "%s", string);
+ sfi_rstore_warn (self->rstore, string);
else
g_printerr ("BseStorage: while storing: %s", string);
g_free (string);
@@ -999,7 +999,7 @@ bse_storage_warn_skip (BseStorage *self,
va_start (args, format);
string = g_strdup_vprintf (format, args);
va_end (args);
- token = sfi_rstore_warn_skip (self->rstore, "%s", string);
+ token = sfi_rstore_warn_skip (self->rstore, string);
g_free (string);
return token;
}
@@ -1015,7 +1015,7 @@ bse_storage_error (BseStorage *self,
string = g_strdup_vprintf (format, args);
va_end (args);
if (self->rstore)
- sfi_rstore_error (self->rstore, "%s", string);
+ sfi_rstore_error (self->rstore, string);
else
g_printerr ("BseStorage: ERROR: while storing: %s\n", string);
g_free (string);
diff --git a/sfi/sfistore.cc b/sfi/sfistore.cc
index 838ccdd..9fcfcac 100644
--- a/sfi/sfistore.cc
+++ b/sfi/sfistore.cc
@@ -115,30 +115,6 @@ sfi_wstore_putc (SfiWStore *wstore,
}
void
-sfi_wstore_printf (SfiWStore *wstore,
- const gchar *format,
- ...)
-{
- gchar *buffer;
- va_list args;
-
- g_return_if_fail (wstore != NULL);
-
- const gchar *ldir = g_printf_find_localised_directive (format);
- if (ldir)
- g_warning ("%s: encountered localised directive \"%s\" in format string: \"%s\"", G_STRFUNC, ldir,
format);
-
- va_start (args, format);
- buffer = g_strdup_vprintf (format, args);
- va_end (args);
-
- g_string_append (wstore->text, buffer);
- if (buffer[0])
- sfi_wstore_text_changed (wstore);
- g_free (buffer);
-}
-
-void
sfi_wstore_putf (SfiWStore *wstore,
gfloat vfloat)
{
@@ -479,23 +455,12 @@ sfi_rstore_eof (SfiRStore *rstore)
}
void
-sfi_rstore_error (SfiRStore *rstore,
- const gchar *format,
- ...)
+sfi_rstore_error (SfiRStore *rstore, const std::string &msg)
{
- va_list args;
-
g_return_if_fail (rstore);
- g_return_if_fail (format != NULL);
- va_start (args, format);
if (rstore->scanner->parse_errors < rstore->scanner->max_parse_errors)
- {
- gchar *string = g_strdup_vprintf (format, args);
- g_scanner_error (rstore->scanner, "%s", string);
- g_free (string);
- }
- va_end (args);
+ g_scanner_error (rstore->scanner, "%s", msg.c_str());
}
void
@@ -520,23 +485,12 @@ sfi_rstore_unexp_token (SfiRStore *rstore,
}
void
-sfi_rstore_warn (SfiRStore *rstore,
- const gchar *format,
- ...)
+sfi_rstore_warn (SfiRStore *rstore, const std::string &msg)
{
- va_list args;
-
g_return_if_fail (rstore);
- g_return_if_fail (format != NULL);
- va_start (args, format);
if (rstore->scanner->parse_errors < rstore->scanner->max_parse_errors)
- {
- gchar *string = g_strdup_vprintf (format, args);
- g_scanner_warn (rstore->scanner, "%s", string);
- g_free (string);
- }
- va_end (args);
+ g_scanner_warn (rstore->scanner, "%s", msg.c_str());
}
static GTokenType
@@ -569,24 +523,13 @@ scanner_skip_statement (GScanner *scanner,
}
GTokenType
-sfi_rstore_warn_skip (SfiRStore *rstore,
- const gchar *format,
- ...)
+sfi_rstore_warn_skip (SfiRStore *rstore, const std::string &msg)
{
- va_list args;
-
g_return_val_if_fail (rstore, G_TOKEN_ERROR);
- g_return_val_if_fail (format != NULL, G_TOKEN_ERROR);
- va_start (args, format);
if (rstore->scanner->parse_errors < rstore->scanner->max_parse_errors)
- {
- gchar *string = g_strdup_vprintf (format, args);
- /* construct warning *before* modifying scanner state */
- g_scanner_warn (rstore->scanner, "%s - skipping...", string);
- g_free (string);
- }
- va_end (args);
+ /* construct warning *before* modifying scanner state */
+ g_scanner_warn (rstore->scanner, "%s - skipping...", msg.c_str());
return scanner_skip_statement (rstore->scanner, 1);
}
@@ -641,12 +584,14 @@ sfi_rstore_parse_param (SfiRStore *rstore,
if (g_param_value_validate (pspec, value))
{
if (G_VALUE_TYPE (&pvalue) != G_VALUE_TYPE (value))
- sfi_rstore_warn (rstore, "fixing up value for \"%s\" of type `%s' (converted from `%s')",
- pspec->name, g_type_name (G_VALUE_TYPE (value)),
- g_type_name (G_VALUE_TYPE (&pvalue)));
+ sfi_rstore_warn (rstore,
+ Rapicorn::string_format ("fixing up value for \"%s\" of type `%s'
(converted from `%s')",
+ pspec->name, g_type_name (G_VALUE_TYPE (value)),
+ g_type_name (G_VALUE_TYPE (&pvalue))));
else
- sfi_rstore_warn (rstore, "fixing up value for \"%s\" of type `%s'",
- pspec->name, g_type_name (G_VALUE_TYPE (value)));
+ sfi_rstore_warn (rstore,
+ Rapicorn::string_format ("fixing up value for \"%s\" of type `%s'",
+ pspec->name, g_type_name (G_VALUE_TYPE (value))));
}
}
else
@@ -822,7 +767,9 @@ sfi_rstore_parse_until (SfiRStore *rstore,
g_warning ("((SfiStoreParser)%p) advanced scanner for unmatched token", try_statement);
return G_TOKEN_ERROR;
}
- expected_token = sfi_rstore_warn_skip (rstore, "unknown identifier: %s",
scanner->next_value.v_identifier);
+ expected_token = sfi_rstore_warn_skip (rstore,
+ Rapicorn::string_format ("unknown identifier: %s",
+ scanner->next_value.v_identifier));
}
/* bail out on errors */
if (expected_token != G_TOKEN_NONE)
diff --git a/sfi/sfistore.hh b/sfi/sfistore.hh
index 6cb114c..4d94766 100644
--- a/sfi/sfistore.hh
+++ b/sfi/sfistore.hh
@@ -7,7 +7,6 @@
G_BEGIN_DECLS
-
/* --- typedefs and structures --- */
typedef gint /* -errno || length */ (*SfiStoreReadBin) (gpointer data,
void *buffer,
@@ -48,9 +47,7 @@ void sfi_wstore_puts (SfiWStore *wstore,
const gchar *string);
void sfi_wstore_putc (SfiWStore *wstore,
gchar character);
-void sfi_wstore_printf (SfiWStore *wstore,
- const gchar *format,
- ...) G_GNUC_PRINTF (2, 3);
+#define sfi_wstore_printf(wstore, ...) sfi_wstore_puts (wstore, Rapicorn::string_format
(__VA_ARGS__).c_str())
void sfi_wstore_putf (SfiWStore *wstore,
gfloat vfloat);
void sfi_wstore_putd (SfiWStore *wstore,
@@ -101,17 +98,11 @@ guint sfi_rstore_parse_all (SfiRStore *rstore,
gpointer context_data,
SfiStoreParser try_statement,
gpointer user_data);
-void sfi_rstore_error (SfiRStore *rstore,
- const gchar *format,
- ...) G_GNUC_PRINTF (2,3);
+void sfi_rstore_error (SfiRStore *rstore, const std::string &msg);
void sfi_rstore_unexp_token (SfiRStore *rstore,
GTokenType expected_token);
-void sfi_rstore_warn (SfiRStore *rstore,
- const gchar *format,
- ...) G_GNUC_PRINTF (2,3);
-GTokenType sfi_rstore_warn_skip (SfiRStore *rstore,
- const gchar *format,
- ...) G_GNUC_PRINTF (2,3);
+void sfi_rstore_warn (SfiRStore *rstore, const std::string &msg);
+GTokenType sfi_rstore_warn_skip (SfiRStore *rstore, const std::string &msg);
typedef gboolean (SfiRStoreQuickScan) (SfiRStore *rstore,
gpointer data);
void sfi_rstore_quick_scan (SfiRStore *rstore,
@@ -136,9 +127,6 @@ void sfi_rstore_quick_scan (SfiRStore *rstore,
} \
} G_STMT_END
-
G_END_DECLS
#endif /* __SFI_STORE_H__ */
-
-/* vim:set ts=8 sts=2 sw=2: */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]