Fixed ngettext for large numbers and added better support for non-GNU systems #1

merged 3 commits into from Jan 16, 2012

2 participants


I've made two small changes in this library.

1) The functions ngettext and dngettext would not work for large integers that do not fit unsigned long type. Here is what Gettext manual says about this:

"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."

2) I created better support for non-GNU systems.


Gustavo Henr... added some commits Jan 16, 2012

Thank you for the fixes, sir. Merged.

@krzysz00 krzysz00 merged commit 85d5dce into krzysz00:master Jan 16, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment