mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-03-28 18:40:03 +01:00
goption: Treat an empty option context parameter string as NULL
Otherwise the code ends up calling `gettext ("")`, which returns the current translation’s header. The caller should really have provided a NULL, parameter string, but the empty string is clear enough. See https://gitlab.freedesktop.org/accountsservice/accountsservice/-/merge_requests/56. Signed-off-by: Philip Withnall <withnall@endlessm.com>
This commit is contained in:
parent
123e8c9bf6
commit
40a64131d1
@ -241,7 +241,7 @@ struct _GOptionContext
|
||||
{
|
||||
GList *groups;
|
||||
|
||||
gchar *parameter_string;
|
||||
gchar *parameter_string; /* (nullable) */
|
||||
gchar *summary;
|
||||
gchar *description;
|
||||
|
||||
@ -364,6 +364,11 @@ g_option_context_new (const gchar *parameter_string)
|
||||
|
||||
context = g_new0 (GOptionContext, 1);
|
||||
|
||||
/* Clear the empty string to NULL, otherwise we end up calling gettext(""),
|
||||
* which returns the translation header. */
|
||||
if (parameter_string != NULL && *parameter_string == '\0')
|
||||
parameter_string = NULL;
|
||||
|
||||
context->parameter_string = g_strdup (parameter_string);
|
||||
context->strict_posix = FALSE;
|
||||
context->help_enabled = TRUE;
|
||||
|
Loading…
x
Reference in New Issue
Block a user