(svn r12420) -Cleanup: Fix the indentation, improve a variable name, and add a NOT_REACHED to DeterminePluralForm.

This commit is contained in:
maedhros 2008-03-25 19:56:16 +00:00
parent 82eebc20c0
commit 97fb7fb8d9

View File

@ -400,74 +400,75 @@ static char *FormatGenericCurrency(char *buff, const CurrencySpec *spec, Money n
return buff; return buff;
} }
static int DeterminePluralForm(int64 cnt) static int DeterminePluralForm(int64 count)
{ {
uint64 n = cnt;
/* The absolute value determines plurality */ /* The absolute value determines plurality */
if (cnt < 0) n = -cnt; uint64 n = abs(count);
switch (_langpack->plural_form) { switch (_langpack->plural_form) {
/* Two forms, singular used for one only default:
* Used in: NOT_REACHED();
* Danish, Dutch, English, German, Norwegian, Swedish, Estonian, Finnish,
* Greek, Hebrew, Italian, Portuguese, Spanish, Esperanto */
case 0:
default:
return n != 1;
/* Only one form /* Two forms, singular used for one only
* Used in: * Used in:
* Hungarian, Japanese, Korean, Turkish */ * Danish, Dutch, English, German, Norwegian, Swedish, Estonian, Finnish,
case 1: * Greek, Hebrew, Italian, Portuguese, Spanish, Esperanto */
return 0; case 0:
return n != 1;
/* Two forms, singular used for zero and one /* Only one form
* Used in: * Used in:
* French, Brazilian Portuguese */ * Hungarian, Japanese, Korean, Turkish */
case 2: case 1:
return n > 1; return 0;
/* Three forms, special case for zero /* Two forms, singular used for zero and one
* Used in: * Used in:
* Latvian */ * French, Brazilian Portuguese */
case 3: case 2:
return n % 10 == 1 && n % 100 != 11 ? 0 : n != 0 ? 1 : 2; return n > 1;
/* Three forms, special case for one and two /* Three forms, special case for zero
* Used in: * Used in:
* Gaelige (Irish) */ * Latvian */
case 4: case 3:
return n == 1 ? 0 : n == 2 ? 1 : 2; return n % 10 == 1 && n % 100 != 11 ? 0 : n != 0 ? 1 : 2;
/* Three forms, special case for numbers ending in 1[2-9] /* Three forms, special case for one and two
* Used in: * Used in:
* Lithuanian */ * Gaelige (Irish) */
case 5: case 4:
return n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2; return n == 1 ? 0 : n == 2 ? 1 : 2;
/* Three forms, special cases for numbers ending in 1 and 2, 3, 4, except those ending in 1[1-4] /* Three forms, special case for numbers ending in 1[2-9]
* Used in: * Used in:
* Croatian, Czech, Russian, Slovak, Ukrainian */ * Lithuanian */
case 6: case 5:
return n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2; return n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2;
/* Three forms, special case for one and some numbers ending in 2, 3, or 4 /* Three forms, special cases for numbers ending in 1 and 2, 3, 4, except those ending in 1[1-4]
* Used in: * Used in:
* Polish */ * Croatian, Czech, Russian, Slovak, Ukrainian */
case 7: case 6:
return n == 1 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2; return n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2;
/* Four forms, special case for one and all numbers ending in 02, 03, or 04 /* Three forms, special case for one and some numbers ending in 2, 3, or 4
* Used in: * Used in:
* Slovenian */ * Polish */
case 8: case 7:
return n % 100 == 1 ? 0 : n % 100 == 2 ? 1 : n % 100 == 3 || n % 100 == 4 ? 2 : 3; return n == 1 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2;
/* Two forms; singular used for everything ending in 1 but not in 11. /* Four forms, special case for one and all numbers ending in 02, 03, or 04
* Used in: * Used in:
* Icelandic */ * Slovenian */
case 9: case 8:
return n % 10 == 1 && n % 100 != 11 ? 0 : 1; return n % 100 == 1 ? 0 : n % 100 == 2 ? 1 : n % 100 == 3 || n % 100 == 4 ? 2 : 3;
/* Two forms; singular used for everything ending in 1 but not in 11.
* Used in:
* Icelandic */
case 9:
return n % 10 == 1 && n % 100 != 11 ? 0 : 1;
} }
} }