mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-14 16:26:17 +01:00
Add g_prefix_error_literal()
Because sometimes you don't want a lone "%s", and you don't want the compiler yelling at you about format strings that don't have any format in them. Closes #663
This commit is contained in:
parent
0c8740dc83
commit
9cb1bb0fb2
@ -786,6 +786,7 @@ g_set_error_literal
|
|||||||
g_propagate_error
|
g_propagate_error
|
||||||
g_clear_error
|
g_clear_error
|
||||||
g_prefix_error
|
g_prefix_error
|
||||||
|
g_prefix_error_literal
|
||||||
g_propagate_prefixed_error
|
g_propagate_prefixed_error
|
||||||
<SUBSECTION>
|
<SUBSECTION>
|
||||||
GErrorInitFunc
|
GErrorInitFunc
|
||||||
|
@ -1100,6 +1100,30 @@ g_prefix_error (GError **err,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* g_prefix_error_literal:
|
||||||
|
* @err: (allow-none): a return location for a #GError, or %NULL
|
||||||
|
* @prefix: string to prefix @err with
|
||||||
|
*
|
||||||
|
* Prefixes @prefix to an existing error message. If @err or *@err is
|
||||||
|
* %NULL (i.e.: no error variable) then do nothing.
|
||||||
|
*
|
||||||
|
* Since: 2.70
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
g_prefix_error_literal (GError **err,
|
||||||
|
const gchar *prefix)
|
||||||
|
{
|
||||||
|
if (err && *err)
|
||||||
|
{
|
||||||
|
gchar *oldstring;
|
||||||
|
|
||||||
|
oldstring = (*err)->message;
|
||||||
|
(*err)->message = g_strconcat (prefix, oldstring, NULL);
|
||||||
|
g_free (oldstring);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* g_propagate_prefixed_error:
|
* g_propagate_prefixed_error:
|
||||||
* @dest: error return location
|
* @dest: error return location
|
||||||
|
@ -244,6 +244,11 @@ void g_prefix_error (GError **err,
|
|||||||
const gchar *format,
|
const gchar *format,
|
||||||
...) G_GNUC_PRINTF (2, 3);
|
...) G_GNUC_PRINTF (2, 3);
|
||||||
|
|
||||||
|
/* if (err) prefix the string to the ->message */
|
||||||
|
GLIB_AVAILABLE_IN_2_70
|
||||||
|
void g_prefix_error_literal (GError **err,
|
||||||
|
const gchar *prefix);
|
||||||
|
|
||||||
/* g_propagate_error then g_error_prefix on dest */
|
/* g_propagate_error then g_error_prefix on dest */
|
||||||
GLIB_AVAILABLE_IN_ALL
|
GLIB_AVAILABLE_IN_ALL
|
||||||
void g_propagate_prefixed_error (GError **dest,
|
void g_propagate_prefixed_error (GError **dest,
|
||||||
|
Loading…
Reference in New Issue
Block a user