summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormaedhros <maedhros@openttd.org>2008-03-25 19:56:16 +0000
committermaedhros <maedhros@openttd.org>2008-03-25 19:56:16 +0000
commit97fb7fb8d9de58786722b350b6a25090baf8fb94 (patch)
tree3f389f8652124b23615fd46b5448962f764b3064 /src
parent82eebc20c02422cc5e3cb5ec9d7a5c7898208b79 (diff)
downloadopenttd-97fb7fb8d9de58786722b350b6a25090baf8fb94.tar.xz
(svn r12420) -Cleanup: Fix the indentation, improve a variable name, and add a NOT_REACHED to DeterminePluralForm.
Diffstat (limited to 'src')
-rw-r--r--src/strings.cpp129
1 files changed, 65 insertions, 64 deletions
diff --git a/src/strings.cpp b/src/strings.cpp
index 32f2a297c..0608fc12e 100644
--- a/src/strings.cpp
+++ b/src/strings.cpp
@@ -400,74 +400,75 @@ static char *FormatGenericCurrency(char *buff, const CurrencySpec *spec, Money n
return buff;
}
-static int DeterminePluralForm(int64 cnt)
+static int DeterminePluralForm(int64 count)
{
- uint64 n = cnt;
/* The absolute value determines plurality */
- if (cnt < 0) n = -cnt;
+ uint64 n = abs(count);
switch (_langpack->plural_form) {
- /* Two forms, singular used for one only
- * Used in:
- * Danish, Dutch, English, German, Norwegian, Swedish, Estonian, Finnish,
- * Greek, Hebrew, Italian, Portuguese, Spanish, Esperanto */
- case 0:
- default:
- return n != 1;
-
- /* Only one form
- * Used in:
- * Hungarian, Japanese, Korean, Turkish */
- case 1:
- return 0;
-
- /* Two forms, singular used for zero and one
- * Used in:
- * French, Brazilian Portuguese */
- case 2:
- return n > 1;
-
- /* Three forms, special case for zero
- * Used in:
- * Latvian */
- case 3:
- return n % 10 == 1 && n % 100 != 11 ? 0 : n != 0 ? 1 : 2;
-
- /* Three forms, special case for one and two
- * Used in:
- * Gaelige (Irish) */
- case 4:
- return n == 1 ? 0 : n == 2 ? 1 : 2;
-
- /* Three forms, special case for numbers ending in 1[2-9]
- * Used in:
- * Lithuanian */
- case 5:
- return n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2;
-
- /* Three forms, special cases for numbers ending in 1 and 2, 3, 4, except those ending in 1[1-4]
- * Used in:
- * Croatian, Czech, Russian, Slovak, Ukrainian */
- case 6:
- return n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2;
-
- /* Three forms, special case for one and some numbers ending in 2, 3, or 4
- * Used in:
- * Polish */
- case 7:
- return n == 1 ? 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
- * Used in:
- * Slovenian */
- case 8:
- 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;
+ default:
+ NOT_REACHED();
+
+ /* Two forms, singular used for one only
+ * Used in:
+ * Danish, Dutch, English, German, Norwegian, Swedish, Estonian, Finnish,
+ * Greek, Hebrew, Italian, Portuguese, Spanish, Esperanto */
+ case 0:
+ return n != 1;
+
+ /* Only one form
+ * Used in:
+ * Hungarian, Japanese, Korean, Turkish */
+ case 1:
+ return 0;
+
+ /* Two forms, singular used for zero and one
+ * Used in:
+ * French, Brazilian Portuguese */
+ case 2:
+ return n > 1;
+
+ /* Three forms, special case for zero
+ * Used in:
+ * Latvian */
+ case 3:
+ return n % 10 == 1 && n % 100 != 11 ? 0 : n != 0 ? 1 : 2;
+
+ /* Three forms, special case for one and two
+ * Used in:
+ * Gaelige (Irish) */
+ case 4:
+ return n == 1 ? 0 : n == 2 ? 1 : 2;
+
+ /* Three forms, special case for numbers ending in 1[2-9]
+ * Used in:
+ * Lithuanian */
+ case 5:
+ return n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2;
+
+ /* Three forms, special cases for numbers ending in 1 and 2, 3, 4, except those ending in 1[1-4]
+ * Used in:
+ * Croatian, Czech, Russian, Slovak, Ukrainian */
+ case 6:
+ return n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2;
+
+ /* Three forms, special case for one and some numbers ending in 2, 3, or 4
+ * Used in:
+ * Polish */
+ case 7:
+ return n == 1 ? 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
+ * Used in:
+ * Slovenian */
+ case 8:
+ 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;
}
}