Bug 28072 - Hard coded plural in readelf.c
Summary: Hard coded plural in readelf.c
Status: UNCONFIRMED
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: 2.38 (HEAD)
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-07-10 15:33 UTC by Frederic Marchal
Modified: 2021-07-12 13:18 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Frederic Marchal 2021-07-10 15:33:46 UTC
Readelf.c at line 10946 contains a rule to display a message with singular/plural.

The rule is hard coded. It assumes 1 is singular and everything else is plural. This is valid for English but not for other languages. That construct can't be translated accurately.

````
  if (do_dynamic && filedata->dynamic_addr)
    {
      if (filedata->dynamic_nent == 1)
	{
	  if (filedata->is_separate)
	    printf (_("\nIn linked file '%s' the dynamic section at offset 0x%lx contains 1 entry:\n"),
		    filedata->file_name,
		    filedata->dynamic_addr);
	  else
	    printf (_("\nDynamic section at offset 0x%lx contains 1 entry:\n"),
		    filedata->dynamic_addr);
	}
      else
	{
	  if (filedata->is_separate)
	    printf (_("\nIn linked file '%s' the dynamic section at offset 0x%lx contains %lu entries:\n"),
		    filedata->file_name,
		    filedata->dynamic_addr,
		    (unsigned long) filedata->dynamic_nent);
	  else
	    printf (_("\nDynamic section at offset 0x%lx contains %lu entries:\n"),
		    filedata->dynamic_addr,
		    (unsigned long) filedata->dynamic_nent);
	}
    }
````

See gettext documentation for more information about the issue with plural: https://www.gnu.org/software/gettext/manual/html_node/Plural-forms.html
Comment 1 cvs-commit@gcc.gnu.org 2021-07-12 13:17:15 UTC
The master branch has been updated by Nick Clifton <nickc@sourceware.org>:

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

commit f253158fafd213c209a5b2a56e22b53760a7132d
Author: Nick Clifton <nickc@redhat.com>
Date:   Mon Jul 12 14:14:33 2021 +0100

    Fix a translation problem for the text generated by readelf at the start of a dump of a dynamic section.
    
            PR 28072
    binutils * readelf.c (process_dynamic_section): Use ngettext to help with translation of header text.
Comment 2 Nick Clifton 2021-07-12 13:18:36 UTC
Hi Frederic,

  Thank you for alerting us to this problem.  I have checked in a small
  patch to replace the conditional printf()s with a single printf using
  ngettext.

Cheers
  Nick