Merge branch 'option-context-translations' into 'master'

goption: Treat an empty option context parameter string as NULL

See merge request GNOME/glib!1469
This commit is contained in:
Michael Catanzaro 2020-05-08 20:26:33 +00:00
commit 493b01c305

View File

@ -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;