Changeset - r8735:54d170351a85
[Not reviewed]
master
0 1 0
maedhros - 16 years ago 2008-03-25 19:56:16
maedhros@openttd.org
(svn r12420) -Cleanup: Fix the indentation, improve a variable name, and add a NOT_REACHED to DeterminePluralForm.
1 file changed with 56 insertions and 55 deletions:
0 comments (0 inline, 0 general)
src/strings.cpp
Show inline comments
 
@@ -400,74 +400,75 @@ static char *FormatGenericCurrency(char 
 
	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;
 
		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;
 
		/* 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;
 
		/* 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 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 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 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 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;
 
		/* 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;
 
		/* 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;
 
		/* 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;
 
	}
 
}
 

	
0 comments (0 inline, 0 general)