On Thu, Nov 30, 2017 at 06:55:08AM -0500, Nathan Sidwell wrote: > > --- gcc/cp/decl.c.jj 2017-11-30 09:44:19.000000000 +0100 > > +++ gcc/cp/decl.c 2017-11-30 09:57:44.539504854 +0100 > > @@ -7445,11 +7445,18 @@ cp_finish_decomp (tree decl, tree first, > > > + inform_n (loc, eltscnt != (unsigned long) eltscnt > > + ? (eltscnt % 1000000) + 1000000 : eltscnt, > > Is such elaboration with the modulo operator necessary? wouldn;t an > arbitrary non-unity constant do. (It took me a while to figure out what > this was trying to do. At least a comment?)
For english it isn't needed of course. I just followed: https://www.gnu.org/savannah-checkouts/gnu/gettext/manual/html_node/Plural-forms.html "About larger integer types, such as ‘uintmax_t’ or ‘unsigned long long’: they can be handled by reducing the value to a range that fits in an ‘unsigned long’. Simply casting the value to ‘unsigned long’ would not do the right thing, since it would treat ULONG_MAX + 1 like zero, ULONG_MAX + 2 like singular, and the like. Here you can exploit the fact that all mentioned plural form formulas eventually become periodic, with a period that is a divisor of 100 (or 1000 or 1000000). So, when you reduce a large value to another one in the range [1000000, 1999999] that ends in the same 6 decimal digits, you can assume that it will lead to the same plural form selection. This code does this: #include <inttypes.h> uintmax_t nbytes = ...; printf (ngettext ("The file has %"PRIuMAX" byte.", "The file has %"PRIuMAX" bytes.", (nbytes > ULONG_MAX ? (nbytes % 1000000) + 1000000 : nbytes)), nbytes);" I can surely add a comment about that. Note the patch depends on the https://gcc.gnu.org/ml/gcc-patches/2017-11/msg02521.html patch. Jakub