Make numerus unsigned
authorJoão Abecasis <joao.abecasis@nokia.com>
Wed, 28 Mar 2012 13:49:46 +0000 (15:49 +0200)
committerQt by Nokia <qt-info@nokia.com>
Fri, 30 Mar 2012 11:24:20 +0000 (13:24 +0200)
It's the index number of the translation to be used.

Change-Id: I959c6aaa1aad09e74286d201ea356bfc4409f02a
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
src/corelib/kernel/qtranslator.cpp

index 4af932a..892883b 100644 (file)
@@ -204,9 +204,9 @@ static bool isValidNumerusRules(const uchar *rules, uint rulesSize)
 
    This function has O(1) space and O(rulesSize) time complexity.
  */
-static int numerusHelper(int n, const uchar *rules, uint rulesSize)
+static uint numerusHelper(int n, const uchar *rules, uint rulesSize)
 {
-    int result = 0;
+    uint result = 0;
     uint i = 0;
 
     if (rulesSize == 0)
@@ -817,11 +817,10 @@ bool QTranslatorPrivate::do_load(const uchar *data, int len)
 }
 
 static QString getMessage(const uchar *m, const uchar *end, const char *context,
-                          const char *sourceText, const char *comment, int numerus)
+                          const char *sourceText, const char *comment, uint numerus)
 {
     const uchar *tn = 0;
     uint tn_length = 0;
-    int currentNumerus = -1;
 
     for (;;) {
         uchar tag = 0;
@@ -835,7 +834,7 @@ static QString getMessage(const uchar *m, const uchar *end, const char *context,
             if (len % 1)
                 return QString();
             m += 4;
-            if (++currentNumerus == numerus) {
+            if (!numerus--) {
                 tn_length = len;
                 tn = m;
             }
@@ -925,7 +924,7 @@ QString QTranslatorPrivate::do_translate(const char *context, const char *source
     if (!numItems)
         return QString();
 
-    int numerus = 0;
+    uint numerus = 0;
     if (n >= 0)
         numerus = numerusHelper(n, numerusRulesArray, numerusRulesLength);