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.
This commit is contained in:
Jehan 2023-04-19 14:23:11 +02:00
parent e3074df900
commit b0916fe701
1 changed files with 6 additions and 3 deletions

View File

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