Bug 29972 - inconsistent format specification in singular form
Summary: inconsistent format specification in singular form
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: 2.40
: P2 critical
Target Milestone: ---
Assignee: Alan Modra
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-01-07 14:26 UTC by Roumen Petrov
Modified: 2023-01-08 03:47 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed: 2023-01-08 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Roumen Petrov 2023-01-07 14:26:11 UTC
Translation of string "Dynamic section at offset %#<PRIx64> contains %<PRId64> entry:" cannot be updated as used format does not match plural from "Dynamic section at offset %#<PRIx64> contains %<PRIu64> entries:".
Comment 1 Roumen Petrov 2023-01-07 14:41:44 UTC
Let see code
	printf (ngettext ("\nDynamic section at offset %#" PRIx64 " contains %" PRId64 " entry:\n",
			  "\nDynamic section at offset %#" PRIx64 " contains %" PRIu64 " entries:\n",
			  filedata->dynamic_nent),

Singular form uses PRId64 while in plural is used PRIu64. As result update of existing "fuzzy" translation fail:
binutils-2.39.90.bg.po: binutils-2.39.90.bg.po:9352: format specifications in 'msgid_plural' and 'msgstr[0]' for argument 2 are not the same
msgfmt: found 1 fatal error.

Work-around: to update translated text to use PRIu64 format.
Comment 2 Bruno Haible 2023-01-07 15:18:36 UTC
> Work-around: to update translated text to use PRIu64 format.

I don't know what you mean. The bug is not the translation; the bug is in the source code that led to the POT file with this contents:

#: readelf.c:11554
#, c-format
msgid ""
"\n"
"Dynamic section at offset %#<PRIx64> contains %<PRId64> entry:\n"
msgid_plural ""
"\n"
"Dynamic section at offset %#<PRIx64> contains %<PRIu64> entries:\n"
msgstr[0] ""
msgstr[1] ""

The second argument to the C format string can be EITHER signed OR unsigned, not both. It makes no sense for the programmer to specify that it is signed in one case and unsigned in the other case.
Comment 3 Roumen Petrov 2023-01-07 16:14:47 UTC
Hi Bruno,

I would like to inform you about such kind of errors in gettext use. Definitely it is developer error, not gettext!

As gettext enhancement could be added check on extract time. But this is feature request, with very low severity and zero priority.
May be some one would like to work on such enhancements.
Comment 4 Roumen Petrov 2023-01-07 16:24:59 UTC
Work-around means in translated singular form, i.e., msgstr[0] to use PRIu64 instead PRId64.
Comment 5 Bruno Haible 2023-01-07 16:58:07 UTC
> As gettext enhancement could be added check on extract time. But this is
> feature request, with very low severity and zero priority.

Registered at https://savannah.gnu.org/bugs/?63630 .
Comment 6 Sourceware Commits 2023-01-08 02:42:12 UTC
The master branch has been updated by Alan Modra <amodra@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=02da71ee20ec71f7b3be85cf2266e09c124983bf

commit 02da71ee20ec71f7b3be85cf2266e09c124983bf
Author: Alan Modra <amodra@gmail.com>
Date:   Sun Jan 8 13:08:46 2023 +1030

    PR29972, inconsistent format specification in singular form
    
            PR 29972
            * readelf.c (process_dynamic_section): Correct format string.
Comment 7 Sourceware Commits 2023-01-08 03:47:08 UTC
The binutils-2_40-branch branch has been updated by Alan Modra <amodra@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=48d455786ce177ed8f8ebe4a868581f591ad81b5

commit 48d455786ce177ed8f8ebe4a868581f591ad81b5
Author: Alan Modra <amodra@gmail.com>
Date:   Sun Jan 8 13:08:46 2023 +1030

    PR29972, inconsistent format specification in singular form
    
            PR 29972
            * readelf.c (process_dynamic_section): Correct format string.
    
    (cherry picked from commit 02da71ee20ec71f7b3be85cf2266e09c124983bf)
Comment 8 Alan Modra 2023-01-08 03:47:49 UTC
Fixed both mainline and branch