From b0916fe7011546ca91454c7921e3728509df5628 Mon Sep 17 00:00:00 2001 From: Jehan Date: Wed, 19 Apr 2023 14:23:11 +0200 Subject: [PATCH] Issue #9362: ordered argument format in printf requires no argument "holes". Though it actually worked in some cases, and failed in others (I have not figured out which build option exactly makes the format with hole work anyway), printf manual actually explicitly says: > There may be no gaps in the numbers of arguments specified using '$'; for > example, if arguments 1 and 3 are specified, argument 2 must also be specified > somewhere in the format string. This explained while it was crashing GIMP (again, only with some build options, or lack of build options): > *** invalid %N$ use detected *** There were 2 possible solutions for this: either ensure that the order number is always used, but that defeats the purpose of plural localization. Instead I reorder the argument so that the file name (which must always be shown for sure) is first in arguments. This way, even if the order number is sometimes omitted (be it in English or in any language), we avoid the crash. --- app/actions/windows-actions.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/actions/windows-actions.c b/app/actions/windows-actions.c index f6c3876564..f58edb6a2f 100644 --- a/app/actions/windows-actions.c +++ b/app/actions/windows-actions.c @@ -468,10 +468,13 @@ windows_actions_update_display_accels (GimpActionGroup *group) gimp_action_set_accels (action, (const gchar*[]) { accel, NULL }); g_free (accel); - ntooltip = ngettext ("Switch to the first image view: %2$s", - "Switch to image view %d: %s", + /* TRANSLATORS: the first argument (%1$s) is the image name, the + * second (%2$d) is its tab order in the graphical interface. + */ + ntooltip = ngettext ("Switch to the first image view: %1$s", + "Switch to image view %2$d: %1$s", i + 1); - tooltip = g_strdup_printf (ntooltip, i + 1, gimp_image_get_display_path (image)); + tooltip = g_strdup_printf (ntooltip, gimp_image_get_display_path (image), i + 1); gimp_action_set_tooltip (action, tooltip); g_free (tooltip); }