This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: xtensa message pluralization
- From: Alan Modra <amodra at gmail dot com>
- To: translation-i18n at lists dot sourceforge dot net
- Cc: "augustine dot sterling at gmail dot com" <augustine dot sterling at gmail dot com>, binutils at sourceware dot org
- Date: Wed, 8 Nov 2017 20:46:29 +1030
- Subject: Re: xtensa message pluralization
- Authentication-results: sourceware.org; auth=none
- References: <20171107082716.GY10905@bubble.grove.modra.org> <CAGSvup9PD8-HHADP2=YVMLyK59bkLOr7-QbvhU6CAbziDacLFg@mail.gmail.com>
On Tue, Nov 07, 2017 at 06:47:18PM -0800, augustine.sterling@gmail.com wrote:
> On Tue, Nov 7, 2017 at 12:27 AM, Alan Modra <amodra@gmail.com> wrote:
> > I'm not too certain whether this is needed, ie. whether any of the slot
> > and opcode counts can be one. Please review.
> >
> > * config/tc-xtensa.c (finish_vinsn): Properly pluralize error message.
>
> Thanks for the fix. Approved.
Committed. A question for the translation project: I'm wondering if
I should allow translators to change sentence construction order with
something like the following patch? Is the added flexibility
desirable when weighed against a little more complexity in .pot files?
(The issue of translators wanting to reorder sentences came to light
recently with binutils PR22397. A patch of mine inadvertently removed
that capability from bfd messages in binutils-2.29.)
diff --git a/gas/config/tc-xtensa.c b/gas/config/tc-xtensa.c
index 3fe85d2..523a6ef 100644
--- a/gas/config/tc-xtensa.c
+++ b/gas/config/tc-xtensa.c
@@ -6358,20 +6358,24 @@ finish_vinsn (vliw_insn *vinsn)
if (vinsn->num_slots
!= xtensa_format_num_slots (xtensa_default_isa, vinsn->format))
{
- char *msg;
+ char *phrase1, *phrase2;
int slots = xtensa_format_num_slots (xtensa_default_isa, vinsn->format);
- msg = concat (ngettext ("format '%s' allows %d slot, ",
- "format '%s' allows %d slots, ",
- slots),
- ngettext ("but there is %d opcode",
- "but there are %d opcodes",
- vinsn->num_slots),
- (const char *) 0);
-
- as_bad (msg, xtensa_format_name (xtensa_default_isa, vinsn->format),
- slots, vinsn->num_slots);
- free (msg);
+ if (asprintf (&phrase1, ngettext ("allows %d slot",
+ "allows %d slots",
+ slots),
+ slots) == -1
+ || asprintf (&phrase2, ngettext ("there is %d opcode",
+ "there are %d opcodes",
+ vinsn->num_slots),
+ vinsn->num_slots) == -1)
+ as_fatal ("%s", xstrerror (errno));
+
+ as_bad (_("format '%s' %s, but %s"),
+ xtensa_format_name (xtensa_default_isa, vinsn->format),
+ phrase1, phrase2);
+ free (phrase1);
+ free (phrase2);
xg_clear_vinsn (vinsn);
return;
}
--
Alan Modra
Australia Development Lab, IBM