Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20140727172308.GH10402@port70.net>
Date: Sun, 27 Jul 2014 19:23:09 +0200
From: Szabolcs Nagy <nsz@...t70.net>
To: musl@...ts.openwall.com
Subject: Re: Non-stub gettext API functions committed, ready for
 testing

* Rich Felker <dalias@...c.org> [2014-07-27 12:49:21 -0400]:
> On Sun, Jul 27, 2014 at 04:14:18PM +0200, Szabolcs Nagy wrote:
> > it shows that a c arithmetic expression parser is needed to handle plurals
> > (and the expression has to be evaluated every time dcngettext is invoked)
> 
> Not necessarily. You could cache results. Or (this is likely the more
> reasonable implementation) just hard-code the expression strings that
> are actually used for real languages and implement them in C when a
> match is found.
> 

hardcoding the strings will fail if .mo files are updated to
use different expressions

with caching the expr has to be evaluated for every uncached n

> >   Plural-Forms: nplurals=2; plural=n == 1 ? 0 : 1;
> > 
> >   The nplurals value must be a decimal number which specifies how many
> >   different plural forms exist for this language. The string following
> >   plural is an expression which is using the C language syntax.
> >   Exceptions are that no negative numbers are allowed, numbers must be
> >   decimal, and the only variable allowed is n.
> 
> This is a very poor description. Does it allow casts? Compound
> literals? Floating point? Function calls? ...?
> 

the parser in gnu gettext:
http://git.savannah.gnu.org/cgit/gettext.git/tree/gettext-runtime/intl/plural.y

so they implement
 conditional (?:)
 logic (&&, ||, !)
 relational (==, !=, <, >, <=, >=)
 and arithmetic (+, -, *, /, %)
operators with unsigned long args only

but in practice the only arithmetic operator used is %
and operators are not combined arbitrarily

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.