| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/corelib/kernel/qtranslator.cpp | 
| Switch to Source code | Preprocessed file | 
| Line | Source | Count | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||
| 2 | - | |||||||||||||||||||
| 3 | - | |||||||||||||||||||
| 4 | - | |||||||||||||||||||
| 5 | - | |||||||||||||||||||
| 6 | - | |||||||||||||||||||
| 7 | - | |||||||||||||||||||
| 8 | - | |||||||||||||||||||
| 9 | - | |||||||||||||||||||
| 10 | - | |||||||||||||||||||
| 11 | - | |||||||||||||||||||
| 12 | - | |||||||||||||||||||
| 13 | - | |||||||||||||||||||
| 14 | - | |||||||||||||||||||
| 15 | - | |||||||||||||||||||
| 16 | - | |||||||||||||||||||
| 17 | - | |||||||||||||||||||
| 18 | - | |||||||||||||||||||
| 19 | - | |||||||||||||||||||
| 20 | - | |||||||||||||||||||
| 21 | enum Tag { Tag_End = 1, Tag_SourceText16, Tag_Translation, Tag_Context16, Tag_Obsolete1, | - | ||||||||||||||||||
| 22 | Tag_SourceText, Tag_Context, Tag_Comment, Tag_Obsolete2 }; | - | ||||||||||||||||||
| 23 | - | |||||||||||||||||||
| 24 | - | |||||||||||||||||||
| 25 | - | |||||||||||||||||||
| 26 | - | |||||||||||||||||||
| 27 | - | |||||||||||||||||||
| 28 | - | |||||||||||||||||||
| 29 | - | |||||||||||||||||||
| 30 | static const int MagicLength = 16; | - | ||||||||||||||||||
| 31 | static const uchar magic[MagicLength] = { | - | ||||||||||||||||||
| 32 | 0x3c, 0xb8, 0x64, 0x18, 0xca, 0xef, 0x9c, 0x95, | - | ||||||||||||||||||
| 33 | 0xcd, 0x21, 0x1c, 0xbf, 0x60, 0xa1, 0xbd, 0xdd | - | ||||||||||||||||||
| 34 | }; | - | ||||||||||||||||||
| 35 | - | |||||||||||||||||||
| 36 | static inline QString dotQmLiteral() { return executed 18 times by 2 tests:   ([]() -> QString { enum { Size = sizeof(u"" ".qm")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" ".qm" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); returnreturn ([]() -> QString { enum { Size = sizeof(u"" ".qm")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" ".qm" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());Executed by: 
 executed 18 times by 2 tests:   qstring_literal_temp;return qstring_literal_temp;Executed by: 
 executed 18 times by 2 tests:   }());return qstring_literal_temp;Executed by: 
 executed 18 times by 2 tests:   }return ([]() -> QString { enum { Size = sizeof(u"" ".qm")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" ".qm" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());Executed by: 
  | 18 | ||||||||||||||||||
| 37 | - | |||||||||||||||||||
| 38 | static bool match(const uchar *found, uint foundLen, const char *target, uint targetLen) | - | ||||||||||||||||||
| 39 | { | - | ||||||||||||||||||
| 40 | - | |||||||||||||||||||
| 41 | - | |||||||||||||||||||
| 42 |     if (foundLen > 0
 
  | 12-346 | ||||||||||||||||||
| 43 |         -- executed 12 times by 1 test:  foundLen;--foundLen;Executed by: 
 executed 12 times by 1 test:  --foundLen;Executed by: 
  | 12 | ||||||||||||||||||
| 44 |     return executed 513 times by 2 tests:   ((targetLen == foundLen) && memcmp(found, target, foundLen) == 0);return ((targetLen == foundLen) && memcmp(found, target, foundLen) == 0);Executed by: 
 executed 513 times by 2 tests:  return ((targetLen == foundLen) && memcmp(found, target, foundLen) == 0);Executed by: 
  | 513 | ||||||||||||||||||
| 45 | } | - | ||||||||||||||||||
| 46 | - | |||||||||||||||||||
| 47 | static void elfHash_continue(const char *name, uint &h) | - | ||||||||||||||||||
| 48 | { | - | ||||||||||||||||||
| 49 | const uchar *k; | - | ||||||||||||||||||
| 50 | uint g; | - | ||||||||||||||||||
| 51 | - | |||||||||||||||||||
| 52 | k = (const uchar *) name; | - | ||||||||||||||||||
| 53 |     while (*
 
  | 624-11634 | ||||||||||||||||||
| 54 | h = (h << 4) + *k++; | - | ||||||||||||||||||
| 55 |         if ((
 
  | 2080-9554 | ||||||||||||||||||
| 56 |             h ^= g >> 24; executed 9554 times by 2 tests:  h ^= g >> 24;Executed by: 
  | 9554 | ||||||||||||||||||
| 57 | h &= ~g; | - | ||||||||||||||||||
| 58 |     } executed 11634 times by 2 tests:  end of blockExecuted by: 
  | 11634 | ||||||||||||||||||
| 59 | } executed 624 times by 2 tests:  end of blockExecuted by: 
  | 624 | ||||||||||||||||||
| 60 | - | |||||||||||||||||||
| 61 | static void elfHash_finish(uint &h) | - | ||||||||||||||||||
| 62 | { | - | ||||||||||||||||||
| 63 |     if (!h
  | 0-312 | ||||||||||||||||||
| 64 |         h = 1; never executed:  h = 1; | 0 | ||||||||||||||||||
| 65 | } executed 312 times by 2 tests:  end of blockExecuted by: 
  | 312 | ||||||||||||||||||
| 66 | - | |||||||||||||||||||
| 67 | static uint elfHash(const char *name) | - | ||||||||||||||||||
| 68 | { | - | ||||||||||||||||||
| 69 | uint hash = 0; | - | ||||||||||||||||||
| 70 | elfHash_continue(name, hash); | - | ||||||||||||||||||
| 71 | elfHash_finish(hash); | - | ||||||||||||||||||
| 72 |     return never executed:   hash;return hash;never executed:  return hash; | 0 | ||||||||||||||||||
| 73 | } | - | ||||||||||||||||||
| 74 | - | |||||||||||||||||||
| 75 | - | |||||||||||||||||||
| 76 | - | |||||||||||||||||||
| 77 | - | |||||||||||||||||||
| 78 | - | |||||||||||||||||||
| 79 | - | |||||||||||||||||||
| 80 | - | |||||||||||||||||||
| 81 | static bool isValidNumerusRules(const uchar *rules, uint rulesSize) | - | ||||||||||||||||||
| 82 | { | - | ||||||||||||||||||
| 83 | - | |||||||||||||||||||
| 84 | - | |||||||||||||||||||
| 85 | - | |||||||||||||||||||
| 86 |     if (rulesSize == 0
  | 1-15 | ||||||||||||||||||
| 87 |         return executed 1 time by 1 test:   true;return true;Executed by: 
 executed 1 time by 1 test:  return true;Executed by: 
  | 1 | ||||||||||||||||||
| 88 | - | |||||||||||||||||||
| 89 | quint32 offset = 0; | - | ||||||||||||||||||
| 90 | do { | - | ||||||||||||||||||
| 91 | uchar opcode = rules[offset]; | - | ||||||||||||||||||
| 92 | uchar op = opcode & Q_OP_MASK; | - | ||||||||||||||||||
| 93 | - | |||||||||||||||||||
| 94 |         if (opcode & 0x80
  | 0-15 | ||||||||||||||||||
| 95 |             return never executed:   false;return false;never executed:  return false; | 0 | ||||||||||||||||||
| 96 | - | |||||||||||||||||||
| 97 |         if (++
 
  | 0-15 | ||||||||||||||||||
| 98 |             return never executed:   false;return false;never executed:  return false; | 0 | ||||||||||||||||||
| 99 | - | |||||||||||||||||||
| 100 | - | |||||||||||||||||||
| 101 | ++offset; | - | ||||||||||||||||||
| 102 | - | |||||||||||||||||||
| 103 | switch (op) | - | ||||||||||||||||||
| 104 | { | - | ||||||||||||||||||
| 105 |         case executed 15 times by 2 tests:   Q_EQ:case Q_EQ:Executed by: 
 executed 15 times by 2 tests:  case Q_EQ:Executed by: 
  | 15 | ||||||||||||||||||
| 106 |         case never executed:   Q_LT:case Q_LT:never executed:  case Q_LT: | 0 | ||||||||||||||||||
| 107 |         case never executed:   Q_LEQ:case Q_LEQ:never executed:  case Q_LEQ: | 0 | ||||||||||||||||||
| 108 |             break; executed 15 times by 2 tests:  break;Executed by: 
  | 15 | ||||||||||||||||||
| 109 | - | |||||||||||||||||||
| 110 |         case never executed:   Q_BETWEEN:case Q_BETWEEN:never executed:  case Q_BETWEEN: | 0 | ||||||||||||||||||
| 111 |             if (offset != rulesSize
  | 0 | ||||||||||||||||||
| 112 | - | |||||||||||||||||||
| 113 | ++offset; | - | ||||||||||||||||||
| 114 |                 break; never executed:  break; | 0 | ||||||||||||||||||
| 115 | } | - | ||||||||||||||||||
| 116 |             return never executed:   false;return false;never executed:  return false; | 0 | ||||||||||||||||||
| 117 | - | |||||||||||||||||||
| 118 |         default never executed:  :default:never executed:  default: | 0 | ||||||||||||||||||
| 119 |             return never executed:   false;return false;never executed:  return false; | 0 | ||||||||||||||||||
| 120 | } | - | ||||||||||||||||||
| 121 | - | |||||||||||||||||||
| 122 | - | |||||||||||||||||||
| 123 |         if (offset == rulesSize
  | 0-15 | ||||||||||||||||||
| 124 |             return executed 15 times by 2 tests:   true;return true;Executed by: 
 executed 15 times by 2 tests:  return true;Executed by: 
  | 15 | ||||||||||||||||||
| 125 | - | |||||||||||||||||||
| 126 |     } never executed:   while (((end of block
 
  | 0 | ||||||||||||||||||
| 127 |                 || (
 
  | 0 | ||||||||||||||||||
| 128 |                 || (
 
  | 0 | ||||||||||||||||||
| 129 |             && ++
 
  | 0 | ||||||||||||||||||
| 130 | - | |||||||||||||||||||
| 131 | - | |||||||||||||||||||
| 132 |     return never executed:   false;return false;never executed:  return false; | 0 | ||||||||||||||||||
| 133 | } | - | ||||||||||||||||||
| 134 | static uint numerusHelper(int n, const uchar *rules, uint rulesSize) | - | ||||||||||||||||||
| 135 | { | - | ||||||||||||||||||
| 136 | uint result = 0; | - | ||||||||||||||||||
| 137 | uint i = 0; | - | ||||||||||||||||||
| 138 | - | |||||||||||||||||||
| 139 |     if (rulesSize == 0
  | 0-9 | ||||||||||||||||||
| 140 |         return never executed:   0;return 0;never executed:  return 0; | 0 | ||||||||||||||||||
| 141 | - | |||||||||||||||||||
| 142 | for (;;) { | - | ||||||||||||||||||
| 143 | bool orExprTruthValue = false; | - | ||||||||||||||||||
| 144 | - | |||||||||||||||||||
| 145 | for (;;) { | - | ||||||||||||||||||
| 146 | bool andExprTruthValue = true; | - | ||||||||||||||||||
| 147 | - | |||||||||||||||||||
| 148 | for (;;) { | - | ||||||||||||||||||
| 149 | bool truthValue = true; | - | ||||||||||||||||||
| 150 | int opcode = rules[i++]; | - | ||||||||||||||||||
| 151 | - | |||||||||||||||||||
| 152 | int leftOperand = n; | - | ||||||||||||||||||
| 153 |                 if (opcode & Q_MOD_10
  | 0-9 | ||||||||||||||||||
| 154 | leftOperand %= 10; | - | ||||||||||||||||||
| 155 |                 } never executed:   else if (opcode & Q_MOD_100end of block
  | 0-9 | ||||||||||||||||||
| 156 | leftOperand %= 100; | - | ||||||||||||||||||
| 157 |                 } never executed:   else if (opcode & Q_LEAD_1000end of block
  | 0-9 | ||||||||||||||||||
| 158 |                     while (leftOperand >= 1000
  | 0 | ||||||||||||||||||
| 159 |                         leftOperand /= 1000; never executed:  leftOperand /= 1000; | 0 | ||||||||||||||||||
| 160 |                 } never executed:  end of block | 0 | ||||||||||||||||||
| 161 | - | |||||||||||||||||||
| 162 | int op = opcode & Q_OP_MASK; | - | ||||||||||||||||||
| 163 | int rightOperand = rules[i++]; | - | ||||||||||||||||||
| 164 | - | |||||||||||||||||||
| 165 | switch (op) { | - | ||||||||||||||||||
| 166 |                 case executed 9 times by 1 test:   Q_EQ:case Q_EQ:Executed by: 
 executed 9 times by 1 test:  case Q_EQ:Executed by: 
  | 9 | ||||||||||||||||||
| 167 | truthValue = (leftOperand == rightOperand); | - | ||||||||||||||||||
| 168 |                     break; executed 9 times by 1 test:  break;Executed by: 
  | 9 | ||||||||||||||||||
| 169 |                 case never executed:   Q_LT:case Q_LT:never executed:  case Q_LT: | 0 | ||||||||||||||||||
| 170 | truthValue = (leftOperand < rightOperand); | - | ||||||||||||||||||
| 171 |                     break; never executed:  break; | 0 | ||||||||||||||||||
| 172 |                 case never executed:   Q_LEQ:case Q_LEQ:never executed:  case Q_LEQ: | 0 | ||||||||||||||||||
| 173 | truthValue = (leftOperand <= rightOperand); | - | ||||||||||||||||||
| 174 |                     break; never executed:  break; | 0 | ||||||||||||||||||
| 175 |                 case never executed:   Q_BETWEEN:case Q_BETWEEN:never executed:  case Q_BETWEEN: | 0 | ||||||||||||||||||
| 176 | int bottom = rightOperand; | - | ||||||||||||||||||
| 177 | int top = rules[i++]; | - | ||||||||||||||||||
| 178 |                     truthValue = (leftOperand >= bottom
 
  | 0 | ||||||||||||||||||
| 179 |                 } never executed:  end of block | 0 | ||||||||||||||||||
| 180 | - | |||||||||||||||||||
| 181 |                 if (opcode & Q_NOT
  | 0-9 | ||||||||||||||||||
| 182 |                     truthValue = !truthValue; never executed:  truthValue = !truthValue; | 0 | ||||||||||||||||||
| 183 | - | |||||||||||||||||||
| 184 |                 andExprTruthValue = andExprTruthValue
 
  | 0-9 | ||||||||||||||||||
| 185 | - | |||||||||||||||||||
| 186 |                 if (i == rulesSize
 
  | 0-9 | ||||||||||||||||||
| 187 |                     break; executed 9 times by 1 test:  break;Executed by: 
  | 9 | ||||||||||||||||||
| 188 | ++i; | - | ||||||||||||||||||
| 189 |             } never executed:  end of block | 0 | ||||||||||||||||||
| 190 | - | |||||||||||||||||||
| 191 |             orExprTruthValue = orExprTruthValue
 
  | 0-9 | ||||||||||||||||||
| 192 | - | |||||||||||||||||||
| 193 |             if (i == rulesSize
 
  | 0-9 | ||||||||||||||||||
| 194 |                 break; executed 9 times by 1 test:  break;Executed by: 
  | 9 | ||||||||||||||||||
| 195 | ++i; | - | ||||||||||||||||||
| 196 |         } never executed:  end of block | 0 | ||||||||||||||||||
| 197 | - | |||||||||||||||||||
| 198 |         if (orExprTruthValue
  | 3-6 | ||||||||||||||||||
| 199 |             return executed 3 times by 1 test:   result;return result;Executed by: 
 executed 3 times by 1 test:  return result;Executed by: 
  | 3 | ||||||||||||||||||
| 200 | - | |||||||||||||||||||
| 201 | ++result; | - | ||||||||||||||||||
| 202 | - | |||||||||||||||||||
| 203 |         if (i == rulesSize
  | 0-6 | ||||||||||||||||||
| 204 |             return executed 6 times by 1 test:   result;return result;Executed by: 
 executed 6 times by 1 test:  return result;Executed by: 
  | 6 | ||||||||||||||||||
| 205 | - | |||||||||||||||||||
| 206 | i++; | - | ||||||||||||||||||
| 207 |     } never executed:  end of block | 0 | ||||||||||||||||||
| 208 | - | |||||||||||||||||||
| 209 | ((!(false)) ? qt_assert("false",__FILE__,282) : qt_noop()); | - | ||||||||||||||||||
| 210 |     return never executed:   0;return 0;never executed:  return 0; | 0 | ||||||||||||||||||
| 211 | } | - | ||||||||||||||||||
| 212 | - | |||||||||||||||||||
| 213 | class QTranslatorPrivate : public QObjectPrivate | - | ||||||||||||||||||
| 214 | { | - | ||||||||||||||||||
| 215 | inline QTranslator* q_func() { return static_cast<QTranslator *>(q_ptr); } inline const QTranslator* q_func() const { return static_cast<const QTranslator *>(q_ptr); } friend class QTranslator; | - | ||||||||||||||||||
| 216 | public: | - | ||||||||||||||||||
| 217 | enum { Contexts = 0x2f, Hashes = 0x42, Messages = 0x69, NumerusRules = 0x88, Dependencies = 0x96 }; | - | ||||||||||||||||||
| 218 | - | |||||||||||||||||||
| 219 | QTranslatorPrivate() : | - | ||||||||||||||||||
| 220 | - | |||||||||||||||||||
| 221 | used_mmap(0), | - | ||||||||||||||||||
| 222 | - | |||||||||||||||||||
| 223 | unmapPointer(0), unmapLength(0), resource(0), | - | ||||||||||||||||||
| 224 | messageArray(0), offsetArray(0), contextArray(0), numerusRulesArray(0), | - | ||||||||||||||||||
| 225 |           messageLength(0), offsetLength(0), contextLength(0), numerusRulesLength(0) {} executed 18 times by 4 tests:  end of blockExecuted by: 
  | 18 | ||||||||||||||||||
| 226 | - | |||||||||||||||||||
| 227 | - | |||||||||||||||||||
| 228 | bool used_mmap : 1; | - | ||||||||||||||||||
| 229 | - | |||||||||||||||||||
| 230 | char *unmapPointer; | - | ||||||||||||||||||
| 231 | quint32 unmapLength; | - | ||||||||||||||||||
| 232 | - | |||||||||||||||||||
| 233 | - | |||||||||||||||||||
| 234 | QResource *resource; | - | ||||||||||||||||||
| 235 | - | |||||||||||||||||||
| 236 | - | |||||||||||||||||||
| 237 | QList<QTranslator*> subTranslators; | - | ||||||||||||||||||
| 238 | - | |||||||||||||||||||
| 239 | - | |||||||||||||||||||
| 240 | - | |||||||||||||||||||
| 241 | const uchar *messageArray; | - | ||||||||||||||||||
| 242 | const uchar *offsetArray; | - | ||||||||||||||||||
| 243 | const uchar *contextArray; | - | ||||||||||||||||||
| 244 | const uchar *numerusRulesArray; | - | ||||||||||||||||||
| 245 | uint messageLength; | - | ||||||||||||||||||
| 246 | uint offsetLength; | - | ||||||||||||||||||
| 247 | uint contextLength; | - | ||||||||||||||||||
| 248 | uint numerusRulesLength; | - | ||||||||||||||||||
| 249 | - | |||||||||||||||||||
| 250 | bool do_load(const QString &filename, const QString &directory); | - | ||||||||||||||||||
| 251 | bool do_load(const uchar *data, int len, const QString &directory); | - | ||||||||||||||||||
| 252 | QString do_translate(const char *context, const char *sourceText, const char *comment, | - | ||||||||||||||||||
| 253 | int n) const; | - | ||||||||||||||||||
| 254 | void clear(); | - | ||||||||||||||||||
| 255 | }; | - | ||||||||||||||||||
| 256 | QTranslator::QTranslator(QObject * parent) | - | ||||||||||||||||||
| 257 | : QObject(*new QTranslatorPrivate, parent) | - | ||||||||||||||||||
| 258 | { | - | ||||||||||||||||||
| 259 | } executed 18 times by 4 tests:  end of blockExecuted by: 
  | 18 | ||||||||||||||||||
| 260 | - | |||||||||||||||||||
| 261 | - | |||||||||||||||||||
| 262 | - | |||||||||||||||||||
| 263 | - | |||||||||||||||||||
| 264 | - | |||||||||||||||||||
| 265 | QTranslator::~QTranslator() | - | ||||||||||||||||||
| 266 | { | - | ||||||||||||||||||
| 267 |     if (QCoreApplication::instance()
  | 0-18 | ||||||||||||||||||
| 268 |         QCoreApplication::removeTranslator(this); executed 18 times by 4 tests:  QCoreApplication::removeTranslator(this);Executed by: 
  | 18 | ||||||||||||||||||
| 269 | QTranslatorPrivate * const d = d_func(); | - | ||||||||||||||||||
| 270 | d->clear(); | - | ||||||||||||||||||
| 271 | } executed 18 times by 4 tests:  end of blockExecuted by: 
  | 18 | ||||||||||||||||||
| 272 | bool QTranslator::load(const QString & filename, const QString & directory, | - | ||||||||||||||||||
| 273 | const QString & search_delimiters, | - | ||||||||||||||||||
| 274 | const QString & suffix) | - | ||||||||||||||||||
| 275 | { | - | ||||||||||||||||||
| 276 | QTranslatorPrivate * const d = d_func(); | - | ||||||||||||||||||
| 277 | d->clear(); | - | ||||||||||||||||||
| 278 | - | |||||||||||||||||||
| 279 | QString prefix; | - | ||||||||||||||||||
| 280 |     if (QFileInfo(filename).isRelative()
  | 3-15 | ||||||||||||||||||
| 281 | prefix = directory; | - | ||||||||||||||||||
| 282 |         if (prefix.length()
 
  | 0-14 | ||||||||||||||||||
| 283 |             prefix += QLatin1Char('/'); executed 1 time by 1 test:  prefix += QLatin1Char('/');Executed by: 
  | 1 | ||||||||||||||||||
| 284 |     } executed 15 times by 1 test:  end of blockExecuted by: 
  | 15 | ||||||||||||||||||
| 285 | - | |||||||||||||||||||
| 286 |     const QString suffixOrDotQM = suffix.isNull()
  | 0-18 | ||||||||||||||||||
| 287 | QString fname = filename; | - | ||||||||||||||||||
| 288 | QString realname; | - | ||||||||||||||||||
| 289 | QString delims; | - | ||||||||||||||||||
| 290 |     delims = search_delimiters.isNull()
 executed 18 times by 2 tests:   qstring_literal_temp;return qstring_literal_temp;Executed by: 
 executed 18 times by 2 tests:   }()) : search_delimiters;return qstring_literal_temp;Executed by: 
  | 0-18 | ||||||||||||||||||
| 291 | - | |||||||||||||||||||
| 292 | for (;;) { | - | ||||||||||||||||||
| 293 | QFileInfo fi; | - | ||||||||||||||||||
| 294 | - | |||||||||||||||||||
| 295 | realname = prefix + fname + suffixOrDotQM; | - | ||||||||||||||||||
| 296 | fi.setFile(realname); | - | ||||||||||||||||||
| 297 |         if (fi.isReadable()
 
  | 0-9 | ||||||||||||||||||
| 298 |             break; executed 9 times by 2 tests:  break;Executed by: 
  | 9 | ||||||||||||||||||
| 299 | - | |||||||||||||||||||
| 300 | realname = prefix + fname; | - | ||||||||||||||||||
| 301 | fi.setFile(realname); | - | ||||||||||||||||||
| 302 |         if (fi.isReadable()
 
  | 1-6 | ||||||||||||||||||
| 303 |             break; executed 5 times by 1 test:  break;Executed by: 
  | 5 | ||||||||||||||||||
| 304 | - | |||||||||||||||||||
| 305 | int rightmost = 0; | - | ||||||||||||||||||
| 306 |         for (int i = 0; i < (int)delims.length()
  | 4-8 | ||||||||||||||||||
| 307 | int k = fname.lastIndexOf(delims[i]); | - | ||||||||||||||||||
| 308 |             if (k > rightmost
  | 0-8 | ||||||||||||||||||
| 309 |                 rightmost = k; never executed:  rightmost = k; | 0 | ||||||||||||||||||
| 310 |         } executed 8 times by 1 test:  end of blockExecuted by: 
  | 8 | ||||||||||||||||||
| 311 | - | |||||||||||||||||||
| 312 | - | |||||||||||||||||||
| 313 |         if (rightmost == 0
  | 0-4 | ||||||||||||||||||
| 314 |             return executed 4 times by 1 test:   false;return false;Executed by: 
 executed 4 times by 1 test:  return false;Executed by: 
  | 4 | ||||||||||||||||||
| 315 | - | |||||||||||||||||||
| 316 | fname.truncate(rightmost); | - | ||||||||||||||||||
| 317 |     } never executed:  end of block | 0 | ||||||||||||||||||
| 318 | - | |||||||||||||||||||
| 319 | - | |||||||||||||||||||
| 320 |     return executed 14 times by 2 tests:   d->do_load(realname, directory);return d->do_load(realname, directory);Executed by: 
 executed 14 times by 2 tests:  return d->do_load(realname, directory);Executed by: 
  | 14 | ||||||||||||||||||
| 321 | } | - | ||||||||||||||||||
| 322 | - | |||||||||||||||||||
| 323 | bool QTranslatorPrivate::do_load(const QString &realname, const QString &directory) | - | ||||||||||||||||||
| 324 | { | - | ||||||||||||||||||
| 325 | QTranslatorPrivate *d = this; | - | ||||||||||||||||||
| 326 | bool ok = false; | - | ||||||||||||||||||
| 327 | - | |||||||||||||||||||
| 328 |     if (realname.startsWith(QLatin1Char(':'))
  | 3-11 | ||||||||||||||||||
| 329 | - | |||||||||||||||||||
| 330 | - | |||||||||||||||||||
| 331 | ((!(!d->resource)) ? qt_assert("!d->resource",__FILE__,534) : qt_noop()); | - | ||||||||||||||||||
| 332 | d->resource = new QResource(realname); | - | ||||||||||||||||||
| 333 |         if (resource->isValid()
 
 
  | 0-3 | ||||||||||||||||||
| 334 |                 && !memcmp(resource->data(), magic, MagicLength)
  | 0-2 | ||||||||||||||||||
| 335 | d->unmapLength = resource->size(); | - | ||||||||||||||||||
| 336 | d->unmapPointer = reinterpret_cast<char *>(const_cast<uchar *>(resource->data())); | - | ||||||||||||||||||
| 337 | - | |||||||||||||||||||
| 338 | d->used_mmap = false; | - | ||||||||||||||||||
| 339 | - | |||||||||||||||||||
| 340 | ok = true; | - | ||||||||||||||||||
| 341 |         } executed 2 times by 2 tests:   else {end of blockExecuted by: 
  | 2 | ||||||||||||||||||
| 342 | delete resource; | - | ||||||||||||||||||
| 343 | resource = 0; | - | ||||||||||||||||||
| 344 |         } executed 1 time by 1 test:  end of blockExecuted by: 
  | 1 | ||||||||||||||||||
| 345 | } | - | ||||||||||||||||||
| 346 | - | |||||||||||||||||||
| 347 |     if (!ok
  | 2-12 | ||||||||||||||||||
| 348 | QFile file(realname); | - | ||||||||||||||||||
| 349 |         if (!file.open(QIODevice::ReadOnly | QIODevice::Unbuffered)
  | 0-12 | ||||||||||||||||||
| 350 |             return never executed:   false;return false;never executed:  return false; | 0 | ||||||||||||||||||
| 351 | - | |||||||||||||||||||
| 352 | qint64 fileSize = file.size(); | - | ||||||||||||||||||
| 353 |         if (fileSize <= MagicLength
 
  | 0-12 | ||||||||||||||||||
| 354 |             return never executed:   false;return false;never executed:  return false; | 0 | ||||||||||||||||||
| 355 | - | |||||||||||||||||||
| 356 | { | - | ||||||||||||||||||
| 357 | char magicBuffer[MagicLength]; | - | ||||||||||||||||||
| 358 |             if (MagicLength != file.read(magicBuffer, MagicLength)
  | 0-12 | ||||||||||||||||||
| 359 |                     || memcmp(magicBuffer, magic, MagicLength)
  | 0-12 | ||||||||||||||||||
| 360 |                 return never executed:   false;return false;never executed:  return false; | 0 | ||||||||||||||||||
| 361 | } | - | ||||||||||||||||||
| 362 | - | |||||||||||||||||||
| 363 | d->unmapLength = quint32(fileSize); | - | ||||||||||||||||||
| 364 | int fd = file.handle(); | - | ||||||||||||||||||
| 365 |         if (fd >= 0
  | 1-11 | ||||||||||||||||||
| 366 | char *ptr; | - | ||||||||||||||||||
| 367 | ptr = reinterpret_cast<char *>( | - | ||||||||||||||||||
| 368 | mmap(0, d->unmapLength, | - | ||||||||||||||||||
| 369 | 0x1, | - | ||||||||||||||||||
| 370 | 0 | 0x02, | - | ||||||||||||||||||
| 371 | fd, 0)); | - | ||||||||||||||||||
| 372 |             if (ptr
 
  | 0-11 | ||||||||||||||||||
| 373 | file.close(); | - | ||||||||||||||||||
| 374 | d->used_mmap = true; | - | ||||||||||||||||||
| 375 | d->unmapPointer = ptr; | - | ||||||||||||||||||
| 376 | ok = true; | - | ||||||||||||||||||
| 377 |             } executed 11 times by 1 test:  end of blockExecuted by: 
  | 11 | ||||||||||||||||||
| 378 |         } executed 11 times by 1 test:  end of blockExecuted by: 
  | 11 | ||||||||||||||||||
| 379 | - | |||||||||||||||||||
| 380 | - | |||||||||||||||||||
| 381 |         if (!ok
  | 1-11 | ||||||||||||||||||
| 382 | d->unmapPointer = new char[d->unmapLength]; | - | ||||||||||||||||||
| 383 |             if (d->unmapPointer
  | 0-1 | ||||||||||||||||||
| 384 | file.seek(0); | - | ||||||||||||||||||
| 385 | qint64 readResult = file.read(d->unmapPointer, d->unmapLength); | - | ||||||||||||||||||
| 386 |                 if (readResult == qint64(unmapLength)
  | 0-1 | ||||||||||||||||||
| 387 |                     ok = true; executed 1 time by 1 test:  ok = true;Executed by: 
  | 1 | ||||||||||||||||||
| 388 |             } executed 1 time by 1 test:  end of blockExecuted by: 
  | 1 | ||||||||||||||||||
| 389 |         } executed 1 time by 1 test:  end of blockExecuted by: 
  | 1 | ||||||||||||||||||
| 390 |     } executed 12 times by 2 tests:  end of blockExecuted by: 
  | 12 | ||||||||||||||||||
| 391 | - | |||||||||||||||||||
| 392 |     if (ok
 
  | 0-14 | ||||||||||||||||||
| 393 |         return executed 14 times by 2 tests:   true;return true;Executed by: 
 executed 14 times by 2 tests:  return true;Executed by: 
  | 14 | ||||||||||||||||||
| 394 | - | |||||||||||||||||||
| 395 | - | |||||||||||||||||||
| 396 |     if (used_mmap
  | 0 | ||||||||||||||||||
| 397 | used_mmap = false; | - | ||||||||||||||||||
| 398 | munmap(unmapPointer, unmapLength); | - | ||||||||||||||||||
| 399 |     } never executed:   elseend of block | 0 | ||||||||||||||||||
| 400 | - | |||||||||||||||||||
| 401 |     if (!d->resource
  | 0 | ||||||||||||||||||
| 402 |         delete [] unmapPointer; never executed:  delete [] unmapPointer; | 0 | ||||||||||||||||||
| 403 | - | |||||||||||||||||||
| 404 | delete d->resource; | - | ||||||||||||||||||
| 405 | d->resource = 0; | - | ||||||||||||||||||
| 406 | d->unmapPointer = 0; | - | ||||||||||||||||||
| 407 | d->unmapLength = 0; | - | ||||||||||||||||||
| 408 | - | |||||||||||||||||||
| 409 |     return never executed:   false;return false;never executed:  return false; | 0 | ||||||||||||||||||
| 410 | } | - | ||||||||||||||||||
| 411 | - | |||||||||||||||||||
| 412 | __attribute__((noinline)) | - | ||||||||||||||||||
| 413 | static bool is_readable_file(const QString &name) | - | ||||||||||||||||||
| 414 | { | - | ||||||||||||||||||
| 415 | const QFileInfo fi(name); | - | ||||||||||||||||||
| 416 |     return never executed:   fi.isReadable() && fi.isFile();return fi.isReadable() && fi.isFile();never executed:  return fi.isReadable() && fi.isFile(); | 0 | ||||||||||||||||||
| 417 | } | - | ||||||||||||||||||
| 418 | - | |||||||||||||||||||
| 419 | static QString find_translation(const QLocale & locale, | - | ||||||||||||||||||
| 420 | const QString & filename, | - | ||||||||||||||||||
| 421 | const QString & prefix, | - | ||||||||||||||||||
| 422 | const QString & directory, | - | ||||||||||||||||||
| 423 | const QString & suffix) | - | ||||||||||||||||||
| 424 | { | - | ||||||||||||||||||
| 425 | QString path; | - | ||||||||||||||||||
| 426 |     if (QFileInfo(filename).isRelative()
  | 0 | ||||||||||||||||||
| 427 | path = directory; | - | ||||||||||||||||||
| 428 |         if (!path.isEmpty()
 
  | 0 | ||||||||||||||||||
| 429 |             path += QLatin1Char('/'); never executed:  path += QLatin1Char('/'); | 0 | ||||||||||||||||||
| 430 |     } never executed:  end of block | 0 | ||||||||||||||||||
| 431 |     const QString suffixOrDotQM = suffix.isNull()
  | 0 | ||||||||||||||||||
| 432 | - | |||||||||||||||||||
| 433 | QString realname; | - | ||||||||||||||||||
| 434 | realname += path + filename + prefix; | - | ||||||||||||||||||
| 435 | const int realNameBaseSize = realname.size(); | - | ||||||||||||||||||
| 436 | QStringList fuzzyLocales; | - | ||||||||||||||||||
| 437 | - | |||||||||||||||||||
| 438 | - | |||||||||||||||||||
| 439 | - | |||||||||||||||||||
| 440 | QStringList languages = locale.uiLanguages(); | - | ||||||||||||||||||
| 441 | - | |||||||||||||||||||
| 442 |     for (int i = languages.size()-1; i >= 0
  | 0 | ||||||||||||||||||
| 443 | QString lang = languages.at(i); | - | ||||||||||||||||||
| 444 | QString lowerLang = lang.toLower(); | - | ||||||||||||||||||
| 445 |         if (lang != lowerLang
  | 0 | ||||||||||||||||||
| 446 |             languages.insert(i+1, lowerLang); never executed:  languages.insert(i+1, lowerLang); | 0 | ||||||||||||||||||
| 447 |     } never executed:  end of block | 0 | ||||||||||||||||||
| 448 | - | |||||||||||||||||||
| 449 | - | |||||||||||||||||||
| 450 | - | |||||||||||||||||||
| 451 | for (QString localeName : qAsConst(languages)) { | - | ||||||||||||||||||
| 452 | localeName.replace(QLatin1Char('-'), QLatin1Char('_')); | - | ||||||||||||||||||
| 453 | - | |||||||||||||||||||
| 454 | realname += localeName + suffixOrDotQM; | - | ||||||||||||||||||
| 455 |         if (is_readable_file(realname)
  | 0 | ||||||||||||||||||
| 456 |             return never executed:   realname;return realname;never executed:  return realname; | 0 | ||||||||||||||||||
| 457 | - | |||||||||||||||||||
| 458 | realname.truncate(realNameBaseSize + localeName.size()); | - | ||||||||||||||||||
| 459 |         if (is_readable_file(realname)
  | 0 | ||||||||||||||||||
| 460 |             return never executed:   realname;return realname;never executed:  return realname; | 0 | ||||||||||||||||||
| 461 | - | |||||||||||||||||||
| 462 | realname.truncate(realNameBaseSize); | - | ||||||||||||||||||
| 463 | fuzzyLocales.append(localeName); | - | ||||||||||||||||||
| 464 |     } never executed:  end of block | 0 | ||||||||||||||||||
| 465 | - | |||||||||||||||||||
| 466 | - | |||||||||||||||||||
| 467 | for (const QString &fuzzyLocale : qAsConst(fuzzyLocales)) { | - | ||||||||||||||||||
| 468 | QStringRef localeName(&fuzzyLocale); | - | ||||||||||||||||||
| 469 | for (;;) { | - | ||||||||||||||||||
| 470 | int rightmost = localeName.lastIndexOf(QLatin1Char('_')); | - | ||||||||||||||||||
| 471 | - | |||||||||||||||||||
| 472 |             if (rightmost <= 0
  | 0 | ||||||||||||||||||
| 473 |                 break; never executed:  break; | 0 | ||||||||||||||||||
| 474 | localeName.truncate(rightmost); | - | ||||||||||||||||||
| 475 | - | |||||||||||||||||||
| 476 | realname += localeName + suffixOrDotQM; | - | ||||||||||||||||||
| 477 |             if (is_readable_file(realname)
  | 0 | ||||||||||||||||||
| 478 |                 return never executed:   realname;return realname;never executed:  return realname; | 0 | ||||||||||||||||||
| 479 | - | |||||||||||||||||||
| 480 | realname.truncate(realNameBaseSize + localeName.size()); | - | ||||||||||||||||||
| 481 |             if (is_readable_file(realname)
  | 0 | ||||||||||||||||||
| 482 |                 return never executed:   realname;return realname;never executed:  return realname; | 0 | ||||||||||||||||||
| 483 | - | |||||||||||||||||||
| 484 | realname.truncate(realNameBaseSize); | - | ||||||||||||||||||
| 485 |         } never executed:  end of block | 0 | ||||||||||||||||||
| 486 |     } never executed:  end of block | 0 | ||||||||||||||||||
| 487 | - | |||||||||||||||||||
| 488 | const int realNameBaseSizeFallbacks = path.size() + filename.size(); | - | ||||||||||||||||||
| 489 | - | |||||||||||||||||||
| 490 | - | |||||||||||||||||||
| 491 |     if (!suffix.isNull()
  | 0 | ||||||||||||||||||
| 492 | realname.replace(realNameBaseSizeFallbacks, prefix.size(), suffix); | - | ||||||||||||||||||
| 493 | - | |||||||||||||||||||
| 494 |         if (is_readable_file(realname)
  | 0 | ||||||||||||||||||
| 495 |             return never executed:   realname;return realname;never executed:  return realname; | 0 | ||||||||||||||||||
| 496 | realname.replace(realNameBaseSizeFallbacks, suffix.size(), prefix); | - | ||||||||||||||||||
| 497 |     } never executed:  end of block | 0 | ||||||||||||||||||
| 498 | - | |||||||||||||||||||
| 499 | - | |||||||||||||||||||
| 500 |     if (is_readable_file(realname)
  | 0 | ||||||||||||||||||
| 501 |         return never executed:   realname;return realname;never executed:  return realname; | 0 | ||||||||||||||||||
| 502 | - | |||||||||||||||||||
| 503 | realname.truncate(realNameBaseSizeFallbacks); | - | ||||||||||||||||||
| 504 | - | |||||||||||||||||||
| 505 |     if (is_readable_file(realname)
  | 0 | ||||||||||||||||||
| 506 |         return never executed:   realname;return realname;never executed:  return realname; | 0 | ||||||||||||||||||
| 507 | - | |||||||||||||||||||
| 508 | realname.truncate(0); | - | ||||||||||||||||||
| 509 |     return never executed:   realname;return realname;never executed:  return realname; | 0 | ||||||||||||||||||
| 510 | } | - | ||||||||||||||||||
| 511 | bool QTranslator::load(const QLocale & locale, | - | ||||||||||||||||||
| 512 | const QString & filename, | - | ||||||||||||||||||
| 513 | const QString & prefix, | - | ||||||||||||||||||
| 514 | const QString & directory, | - | ||||||||||||||||||
| 515 | const QString & suffix) | - | ||||||||||||||||||
| 516 | { | - | ||||||||||||||||||
| 517 | QTranslatorPrivate * const d = d_func(); | - | ||||||||||||||||||
| 518 | d->clear(); | - | ||||||||||||||||||
| 519 | QString fname = find_translation(locale, filename, prefix, directory, suffix); | - | ||||||||||||||||||
| 520 |     return never executed:   !fname.isEmpty() && d->do_load(fname, directory);return !fname.isEmpty() && d->do_load(fname, directory);never executed:  return !fname.isEmpty() && d->do_load(fname, directory); | 0 | ||||||||||||||||||
| 521 | } | - | ||||||||||||||||||
| 522 | bool QTranslator::load(const uchar *data, int len, const QString &directory) | - | ||||||||||||||||||
| 523 | { | - | ||||||||||||||||||
| 524 | QTranslatorPrivate * const d = d_func(); | - | ||||||||||||||||||
| 525 | d->clear(); | - | ||||||||||||||||||
| 526 | - | |||||||||||||||||||
| 527 |     if (!data
 
 
  | 0-2 | ||||||||||||||||||
| 528 |         return never executed:   false;return false;never executed:  return false; | 0 | ||||||||||||||||||
| 529 | - | |||||||||||||||||||
| 530 |     return executed 2 times by 1 test:   d->do_load(data, len, directory);return d->do_load(data, len, directory);Executed by: 
 executed 2 times by 1 test:  return d->do_load(data, len, directory);Executed by: 
  | 2 | ||||||||||||||||||
| 531 | } | - | ||||||||||||||||||
| 532 | - | |||||||||||||||||||
| 533 | static quint8 read8(const uchar *data) | - | ||||||||||||||||||
| 534 | { | - | ||||||||||||||||||
| 535 |     return executed 902 times by 2 tests:   qFromBigEndian<quint8>(data);return qFromBigEndian<quint8>(data);Executed by: 
 executed 902 times by 2 tests:  return qFromBigEndian<quint8>(data);Executed by: 
  | 902 | ||||||||||||||||||
| 536 | } | - | ||||||||||||||||||
| 537 | - | |||||||||||||||||||
| 538 | static quint16 read16(const uchar *data) | - | ||||||||||||||||||
| 539 | { | - | ||||||||||||||||||
| 540 |     return never executed:   qFromBigEndian<quint16>(data);return qFromBigEndian<quint16>(data);never executed:  return qFromBigEndian<quint16>(data); | 0 | ||||||||||||||||||
| 541 | } | - | ||||||||||||||||||
| 542 | - | |||||||||||||||||||
| 543 | static quint32 read32(const uchar *data) | - | ||||||||||||||||||
| 544 | { | - | ||||||||||||||||||
| 545 |     return executed 3591 times by 2 tests:   qFromBigEndian<quint32>(data);return qFromBigEndian<quint32>(data);Executed by: 
 executed 3591 times by 2 tests:  return qFromBigEndian<quint32>(data);Executed by: 
  | 3591 | ||||||||||||||||||
| 546 | } | - | ||||||||||||||||||
| 547 | - | |||||||||||||||||||
| 548 | bool QTranslatorPrivate::do_load(const uchar *data, int len, const QString &directory) | - | ||||||||||||||||||
| 549 | { | - | ||||||||||||||||||
| 550 | bool ok = true; | - | ||||||||||||||||||
| 551 | const uchar *end = data + len; | - | ||||||||||||||||||
| 552 | - | |||||||||||||||||||
| 553 | data += MagicLength; | - | ||||||||||||||||||
| 554 | - | |||||||||||||||||||
| 555 | QStringList dependencies; | - | ||||||||||||||||||
| 556 |     while (data < end - 4
  | 16-49 | ||||||||||||||||||
| 557 | quint8 tag = read8(data++); | - | ||||||||||||||||||
| 558 | quint32 blockLen = read32(data); | - | ||||||||||||||||||
| 559 | data += 4; | - | ||||||||||||||||||
| 560 |         if (!tag
 
  | 0-49 | ||||||||||||||||||
| 561 |             break; never executed:  break; | 0 | ||||||||||||||||||
| 562 |         if (quint32(end - data) < blockLen
  | 0-49 | ||||||||||||||||||
| 563 | ok = false; | - | ||||||||||||||||||
| 564 |             break; never executed:  break; | 0 | ||||||||||||||||||
| 565 | } | - | ||||||||||||||||||
| 566 | - | |||||||||||||||||||
| 567 |         if (tag == QTranslatorPrivate::Contexts
  | 0-49 | ||||||||||||||||||
| 568 | contextArray = data; | - | ||||||||||||||||||
| 569 | contextLength = blockLen; | - | ||||||||||||||||||
| 570 |         } never executed:   else if (tag == QTranslatorPrivate::Hashesend of block
  | 0-33 | ||||||||||||||||||
| 571 | offsetArray = data; | - | ||||||||||||||||||
| 572 | offsetLength = blockLen; | - | ||||||||||||||||||
| 573 |         } executed 16 times by 2 tests:   else if (tag == QTranslatorPrivate::Messagesend of blockExecuted by: 
 
  | 16-17 | ||||||||||||||||||
| 574 | messageArray = data; | - | ||||||||||||||||||
| 575 | messageLength = blockLen; | - | ||||||||||||||||||
| 576 |         } executed 16 times by 2 tests:   else if (tag == QTranslatorPrivate::NumerusRulesend of blockExecuted by: 
 
  | 2-16 | ||||||||||||||||||
| 577 | numerusRulesArray = data; | - | ||||||||||||||||||
| 578 | numerusRulesLength = blockLen; | - | ||||||||||||||||||
| 579 |         } executed 15 times by 2 tests:   else if (tag == QTranslatorPrivate::Dependenciesend of blockExecuted by: 
 
  | 0-15 | ||||||||||||||||||
| 580 | QDataStream stream(QByteArray::fromRawData((const char*)data, blockLen)); | - | ||||||||||||||||||
| 581 | QString dep; | - | ||||||||||||||||||
| 582 |             while (!stream.atEnd()
  | 2 | ||||||||||||||||||
| 583 | stream >> dep; | - | ||||||||||||||||||
| 584 | dependencies.append(dep); | - | ||||||||||||||||||
| 585 |             } executed 2 times by 1 test:  end of blockExecuted by: 
  | 2 | ||||||||||||||||||
| 586 |         } executed 2 times by 1 test:  end of blockExecuted by: 
  | 2 | ||||||||||||||||||
| 587 | - | |||||||||||||||||||
| 588 | data += blockLen; | - | ||||||||||||||||||
| 589 |     } executed 49 times by 2 tests:  end of blockExecuted by: 
  | 49 | ||||||||||||||||||
| 590 | - | |||||||||||||||||||
| 591 |     if (dependencies.isEmpty()
 
 
  | 0-14 | ||||||||||||||||||
| 592 |         ok = false; never executed:  ok = false; | 0 | ||||||||||||||||||
| 593 |     if (ok
 
  | 0-16 | ||||||||||||||||||
| 594 |         ok = false; never executed:  ok = false; | 0 | ||||||||||||||||||
| 595 |     if (ok
  | 0-16 | ||||||||||||||||||
| 596 | const int dependenciesCount = dependencies.count(); | - | ||||||||||||||||||
| 597 | subTranslators.reserve(dependenciesCount); | - | ||||||||||||||||||
| 598 |         for (int i = 0 ; i < dependenciesCount
  | 2-16 | ||||||||||||||||||
| 599 | QTranslator *translator = new QTranslator; | - | ||||||||||||||||||
| 600 | subTranslators.append(translator); | - | ||||||||||||||||||
| 601 | ok = translator->load(dependencies.at(i), directory); | - | ||||||||||||||||||
| 602 |             if (!ok
  | 0-2 | ||||||||||||||||||
| 603 |                 break; never executed:  break; | 0 | ||||||||||||||||||
| 604 |         } executed 2 times by 1 test:  end of blockExecuted by: 
  | 2 | ||||||||||||||||||
| 605 | - | |||||||||||||||||||
| 606 | - | |||||||||||||||||||
| 607 |         if (!ok
  | 0-16 | ||||||||||||||||||
| 608 | qDeleteAll(subTranslators); | - | ||||||||||||||||||
| 609 | subTranslators.clear(); | - | ||||||||||||||||||
| 610 |         } never executed:  end of block | 0 | ||||||||||||||||||
| 611 |     } executed 16 times by 2 tests:  end of blockExecuted by: 
  | 16 | ||||||||||||||||||
| 612 | - | |||||||||||||||||||
| 613 |     if (!ok
  | 0-16 | ||||||||||||||||||
| 614 | messageArray = 0; | - | ||||||||||||||||||
| 615 | contextArray = 0; | - | ||||||||||||||||||
| 616 | offsetArray = 0; | - | ||||||||||||||||||
| 617 | numerusRulesArray = 0; | - | ||||||||||||||||||
| 618 | messageLength = 0; | - | ||||||||||||||||||
| 619 | contextLength = 0; | - | ||||||||||||||||||
| 620 | offsetLength = 0; | - | ||||||||||||||||||
| 621 | numerusRulesLength = 0; | - | ||||||||||||||||||
| 622 |     } never executed:  end of block | 0 | ||||||||||||||||||
| 623 | - | |||||||||||||||||||
| 624 |     return executed 16 times by 2 tests:   ok;return ok;Executed by: 
 executed 16 times by 2 tests:  return ok;Executed by: 
  | 16 | ||||||||||||||||||
| 625 | } | - | ||||||||||||||||||
| 626 | - | |||||||||||||||||||
| 627 | static QString getMessage(const uchar *m, const uchar *end, const char *context, | - | ||||||||||||||||||
| 628 | const char *sourceText, const char *comment, uint numerus) | - | ||||||||||||||||||
| 629 | { | - | ||||||||||||||||||
| 630 | const uchar *tn = 0; | - | ||||||||||||||||||
| 631 | uint tn_length = 0; | - | ||||||||||||||||||
| 632 | const uint sourceTextLen = uint(strlen(sourceText)); | - | ||||||||||||||||||
| 633 | const uint contextLen = uint(strlen(context)); | - | ||||||||||||||||||
| 634 | const uint commentLen = uint(strlen(comment)); | - | ||||||||||||||||||
| 635 | - | |||||||||||||||||||
| 636 | for (;;) { | - | ||||||||||||||||||
| 637 | uchar tag = 0; | - | ||||||||||||||||||
| 638 |         if (m < end
  | 0-853 | ||||||||||||||||||
| 639 |             tag = read8(m++); executed 853 times by 2 tests:  tag = read8(m++);Executed by: 
  | 853 | ||||||||||||||||||
| 640 | switch((Tag)tag) { | - | ||||||||||||||||||
| 641 |         case executed 144 times by 2 tests:   Tag_End:case Tag_End:Executed by: 
 executed 144 times by 2 tests:  case Tag_End:Executed by: 
  | 144 | ||||||||||||||||||
| 642 |             goto executed 144 times by 2 tests:   end;goto end;Executed by: 
 executed 144 times by 2 tests:  goto end;Executed by: 
  | 144 | ||||||||||||||||||
| 643 |         case executed 187 times by 2 tests:   Tag_Translation:case Tag_Translation:Executed by: 
 executed 187 times by 2 tests:   {case Tag_Translation:Executed by: 
  | 187 | ||||||||||||||||||
| 644 | int len = read32(m); | - | ||||||||||||||||||
| 645 |             if (len % 1
  | 0-187 | ||||||||||||||||||
| 646 |                 return never executed:   QString();return QString();never executed:  return QString(); | 0 | ||||||||||||||||||
| 647 | m += 4; | - | ||||||||||||||||||
| 648 |             if (!numerus--
  | 14-173 | ||||||||||||||||||
| 649 | tn_length = len; | - | ||||||||||||||||||
| 650 | tn = m; | - | ||||||||||||||||||
| 651 |             } executed 173 times by 2 tests:  end of blockExecuted by: 
  | 173 | ||||||||||||||||||
| 652 | m += len; | - | ||||||||||||||||||
| 653 |             break; executed 187 times by 2 tests:  break;Executed by: 
  | 187 | ||||||||||||||||||
| 654 | } | - | ||||||||||||||||||
| 655 |         case executed 3 times by 1 test:   Tag_Obsolete1:case Tag_Obsolete1:Executed by: 
 executed 3 times by 1 test:  case Tag_Obsolete1:Executed by: 
  | 3 | ||||||||||||||||||
| 656 | m += 4; | - | ||||||||||||||||||
| 657 |             break; executed 3 times by 1 test:  break;Executed by: 
  | 3 | ||||||||||||||||||
| 658 |         case executed 173 times by 2 tests:   Tag_SourceText:case Tag_SourceText:Executed by: 
 executed 173 times by 2 tests:   {case Tag_SourceText:Executed by: 
  | 173 | ||||||||||||||||||
| 659 | quint32 len = read32(m); | - | ||||||||||||||||||
| 660 | m += 4; | - | ||||||||||||||||||
| 661 |             if (!match(m, len, sourceText, sourceTextLen)
  | 0-173 | ||||||||||||||||||
| 662 |                 return never executed:   QString();return QString();never executed:  return QString(); | 0 | ||||||||||||||||||
| 663 | m += len; | - | ||||||||||||||||||
| 664 | } | - | ||||||||||||||||||
| 665 |             break; executed 173 times by 2 tests:  break;Executed by: 
  | 173 | ||||||||||||||||||
| 666 |         case executed 173 times by 2 tests:   Tag_Context:case Tag_Context:Executed by: 
 executed 173 times by 2 tests:   {case Tag_Context:Executed by: 
  | 173 | ||||||||||||||||||
| 667 | quint32 len = read32(m); | - | ||||||||||||||||||
| 668 | m += 4; | - | ||||||||||||||||||
| 669 |             if (!match(m, len, context, contextLen)
  | 29-144 | ||||||||||||||||||
| 670 |                 return executed 29 times by 2 tests:   QString();return QString();Executed by: 
 executed 29 times by 2 tests:  return QString();Executed by: 
  | 29 | ||||||||||||||||||
| 671 | m += len; | - | ||||||||||||||||||
| 672 | } | - | ||||||||||||||||||
| 673 |             break; executed 144 times by 2 tests:  break;Executed by: 
  | 144 | ||||||||||||||||||
| 674 |         case executed 173 times by 2 tests:   Tag_Comment:case Tag_Comment:Executed by: 
 executed 173 times by 2 tests:   {case Tag_Comment:Executed by: 
  | 173 | ||||||||||||||||||
| 675 | quint32 len = read32(m); | - | ||||||||||||||||||
| 676 | m += 4; | - | ||||||||||||||||||
| 677 |             if (*
 
 
  | 0-167 | ||||||||||||||||||
| 678 |                 return never executed:   QString();return QString();never executed:  return QString(); | 0 | ||||||||||||||||||
| 679 | m += len; | - | ||||||||||||||||||
| 680 | } | - | ||||||||||||||||||
| 681 |             break; executed 173 times by 2 tests:  break;Executed by: 
  | 173 | ||||||||||||||||||
| 682 |         default never executed:  :default:never executed:  default: | 0 | ||||||||||||||||||
| 683 |             return never executed:   QString();return QString();never executed:  return QString(); | 0 | ||||||||||||||||||
| 684 | } | - | ||||||||||||||||||
| 685 | } | - | ||||||||||||||||||
| 686 | end: code before this statement never executed:  end: | 0 | ||||||||||||||||||
| 687 |     if (!tn
  | 0-144 | ||||||||||||||||||
| 688 |         return never executed:   QString();return QString();never executed:  return QString(); | 0 | ||||||||||||||||||
| 689 | QString str = QString((const QChar *)tn, tn_length/2); | - | ||||||||||||||||||
| 690 |     if (QSysInfo::ByteOrder == QSysInfo::LittleEndian
  | 0-144 | ||||||||||||||||||
| 691 |         for (int i = 0; i < str.length()
  | 144-818 | ||||||||||||||||||
| 692 |             str[i] = QChar((str.at(i).unicode() >> 8) + ((str.at(i).unicode() << 8) & 0xff00)); executed 818 times by 2 tests:  str[i] = QChar((str.at(i).unicode() >> 8) + ((str.at(i).unicode() << 8) & 0xff00));Executed by: 
  | 818 | ||||||||||||||||||
| 693 |     } executed 144 times by 2 tests:  end of blockExecuted by: 
  | 144 | ||||||||||||||||||
| 694 |     return executed 144 times by 2 tests:   str;return str;Executed by: 
 executed 144 times by 2 tests:  return str;Executed by: 
  | 144 | ||||||||||||||||||
| 695 | } | - | ||||||||||||||||||
| 696 | - | |||||||||||||||||||
| 697 | QString QTranslatorPrivate::do_translate(const char *context, const char *sourceText, | - | ||||||||||||||||||
| 698 | const char *comment, int n) const | - | ||||||||||||||||||
| 699 | { | - | ||||||||||||||||||
| 700 |     if (context == 0
  | 0-260 | ||||||||||||||||||
| 701 |         context = ""; never executed:  context = ""; | 0 | ||||||||||||||||||
| 702 |     if (sourceText == 0
  | 0-260 | ||||||||||||||||||
| 703 |         sourceText = ""; never executed:  sourceText = ""; | 0 | ||||||||||||||||||
| 704 |     if (comment == 0
  | 57-203 | ||||||||||||||||||
| 705 |         comment = ""; executed 203 times by 2 tests:  comment = "";Executed by: 
  | 203 | ||||||||||||||||||
| 706 | - | |||||||||||||||||||
| 707 | uint numerus = 0; | - | ||||||||||||||||||
| 708 | size_t numItems = 0; | - | ||||||||||||||||||
| 709 | - | |||||||||||||||||||
| 710 |     if (!offsetLength
  | 0-260 | ||||||||||||||||||
| 711 |         goto never executed:   searchDependencies;goto searchDependencies;never executed:  goto searchDependencies; | 0 | ||||||||||||||||||
| 712 | - | |||||||||||||||||||
| 713 | - | |||||||||||||||||||
| 714 | - | |||||||||||||||||||
| 715 | - | |||||||||||||||||||
| 716 | - | |||||||||||||||||||
| 717 |     if (contextLength
  | 0-260 | ||||||||||||||||||
| 718 | quint16 hTableSize = read16(contextArray); | - | ||||||||||||||||||
| 719 | uint g = elfHash(context) % hTableSize; | - | ||||||||||||||||||
| 720 | const uchar *c = contextArray + 2 + (g << 1); | - | ||||||||||||||||||
| 721 | quint16 off = read16(c); | - | ||||||||||||||||||
| 722 | c += 2; | - | ||||||||||||||||||
| 723 |         if (off == 0
  | 0 | ||||||||||||||||||
| 724 |             return never executed:   QString();return QString();never executed:  return QString(); | 0 | ||||||||||||||||||
| 725 | c = contextArray + (2 + (hTableSize << 1) + (off << 1)); | - | ||||||||||||||||||
| 726 | - | |||||||||||||||||||
| 727 | const uint contextLen = uint(strlen(context)); | - | ||||||||||||||||||
| 728 | for (;;) { | - | ||||||||||||||||||
| 729 | quint8 len = read8(c++); | - | ||||||||||||||||||
| 730 |             if (len == 0
  | 0 | ||||||||||||||||||
| 731 |                 return never executed:   QString();return QString();never executed:  return QString(); | 0 | ||||||||||||||||||
| 732 |             if (match(c, len, context, contextLen)
  | 0 | ||||||||||||||||||
| 733 |                 break; never executed:  break; | 0 | ||||||||||||||||||
| 734 | c += len; | - | ||||||||||||||||||
| 735 |         } never executed:  end of block | 0 | ||||||||||||||||||
| 736 |     } never executed:  end of block | 0 | ||||||||||||||||||
| 737 | - | |||||||||||||||||||
| 738 | numItems = offsetLength / (2 * sizeof(quint32)); | - | ||||||||||||||||||
| 739 |     if (!numItems
  | 0-260 | ||||||||||||||||||
| 740 |         goto never executed:   searchDependencies;goto searchDependencies;never executed:  goto searchDependencies; | 0 | ||||||||||||||||||
| 741 | - | |||||||||||||||||||
| 742 |     if (n >= 0
  | 9-251 | ||||||||||||||||||
| 743 |         numerus = numerusHelper(n, numerusRulesArray, numerusRulesLength); executed 9 times by 1 test:  numerus = numerusHelper(n, numerusRulesArray, numerusRulesLength);Executed by: 
  | 9 | ||||||||||||||||||
| 744 | - | |||||||||||||||||||
| 745 | for (;;) { | - | ||||||||||||||||||
| 746 | quint32 h = 0; | - | ||||||||||||||||||
| 747 | elfHash_continue(sourceText, h); | - | ||||||||||||||||||
| 748 | elfHash_continue(comment, h); | - | ||||||||||||||||||
| 749 | elfHash_finish(h); | - | ||||||||||||||||||
| 750 | - | |||||||||||||||||||
| 751 | const uchar *start = offsetArray; | - | ||||||||||||||||||
| 752 | const uchar *end = start + ((numItems-1) << 3); | - | ||||||||||||||||||
| 753 |         while (start <= end
  | 139-2131 | ||||||||||||||||||
| 754 | const uchar *middle = start + (((end - start) >> 4) << 3); | - | ||||||||||||||||||
| 755 | uint hash = read32(middle); | - | ||||||||||||||||||
| 756 |             if (h == hash
  | 173-1958 | ||||||||||||||||||
| 757 | start = middle; | - | ||||||||||||||||||
| 758 |                 break; executed 173 times by 2 tests:  break;Executed by: 
  | 173 | ||||||||||||||||||
| 759 |             } else if (hash < h
  | 745-1213 | ||||||||||||||||||
| 760 | start = middle + 8; | - | ||||||||||||||||||
| 761 |             } executed 745 times by 2 tests:   else {end of blockExecuted by: 
  | 745 | ||||||||||||||||||
| 762 | end = middle - 8; | - | ||||||||||||||||||
| 763 |             } executed 1213 times by 2 tests:  end of blockExecuted by: 
  | 1213 | ||||||||||||||||||
| 764 | } | - | ||||||||||||||||||
| 765 | - | |||||||||||||||||||
| 766 |         if (start <= end
  | 139-173 | ||||||||||||||||||
| 767 | - | |||||||||||||||||||
| 768 |             while (start != offsetArray
 
  | 0-165 | ||||||||||||||||||
| 769 |                 start -= 8; never executed:  start -= 8; | 0 | ||||||||||||||||||
| 770 | - | |||||||||||||||||||
| 771 |             while (start < offsetArray + offsetLength
  | 0-202 | ||||||||||||||||||
| 772 | quint32 rh = read32(start); | - | ||||||||||||||||||
| 773 | start += 4; | - | ||||||||||||||||||
| 774 |                 if (rh != h
  | 29-173 | ||||||||||||||||||
| 775 |                     break; executed 29 times by 2 tests:  break;Executed by: 
  | 29 | ||||||||||||||||||
| 776 | quint32 ro = read32(start); | - | ||||||||||||||||||
| 777 | start += 4; | - | ||||||||||||||||||
| 778 | QString tn = getMessage(messageArray + ro, messageArray + messageLength, context, | - | ||||||||||||||||||
| 779 | sourceText, comment, numerus); | - | ||||||||||||||||||
| 780 |                 if (!tn.isNull()
  | 29-144 | ||||||||||||||||||
| 781 |                     return executed 144 times by 2 tests:   tn;return tn;Executed by: 
 executed 144 times by 2 tests:  return tn;Executed by: 
  | 144 | ||||||||||||||||||
| 782 |             } executed 29 times by 2 tests:  end of blockExecuted by: 
  | 29 | ||||||||||||||||||
| 783 |         } executed 29 times by 2 tests:  end of blockExecuted by: 
  | 29 | ||||||||||||||||||
| 784 |         if (!comment[0]
  | 52-116 | ||||||||||||||||||
| 785 |             break; executed 116 times by 2 tests:  break;Executed by: 
  | 116 | ||||||||||||||||||
| 786 | comment = ""; | - | ||||||||||||||||||
| 787 |     } executed 52 times by 1 test:  end of blockExecuted by: 
  | 52 | ||||||||||||||||||
| 788 | - | |||||||||||||||||||
| 789 | searchDependencies: code before this statement executed 116 times by 2 tests:  searchDependencies:Executed by: 
  | 116 | ||||||||||||||||||
| 790 | for (QTranslator *translator : subTranslators) { | - | ||||||||||||||||||
| 791 | QString tn = translator->translate(context, sourceText, comment, n); | - | ||||||||||||||||||
| 792 |         if (!tn.isNull()
  | 0-5 | ||||||||||||||||||
| 793 |             return executed 5 times by 1 test:   tn;return tn;Executed by: 
 executed 5 times by 1 test:  return tn;Executed by: 
  | 5 | ||||||||||||||||||
| 794 |     } never executed:  end of block | 0 | ||||||||||||||||||
| 795 |     return executed 111 times by 2 tests:   QString();return QString();Executed by: 
 executed 111 times by 2 tests:  return QString();Executed by: 
  | 111 | ||||||||||||||||||
| 796 | } | - | ||||||||||||||||||
| 797 | - | |||||||||||||||||||
| 798 | - | |||||||||||||||||||
| 799 | - | |||||||||||||||||||
| 800 | - | |||||||||||||||||||
| 801 | - | |||||||||||||||||||
| 802 | - | |||||||||||||||||||
| 803 | - | |||||||||||||||||||
| 804 | void QTranslatorPrivate::clear() | - | ||||||||||||||||||
| 805 | { | - | ||||||||||||||||||
| 806 | QTranslator * const q = q_func(); | - | ||||||||||||||||||
| 807 |     if (unmapPointer
 
  | 0-24 | ||||||||||||||||||
| 808 | - | |||||||||||||||||||
| 809 |         if (used_mmap
  | 3-11 | ||||||||||||||||||
| 810 | used_mmap = false; | - | ||||||||||||||||||
| 811 | munmap(unmapPointer, unmapLength); | - | ||||||||||||||||||
| 812 |         } executed 11 times by 1 test:   elseend of blockExecuted by: 
  | 11 | ||||||||||||||||||
| 813 | - | |||||||||||||||||||
| 814 |         if (!resource
  | 1-2 | ||||||||||||||||||
| 815 |             delete [] unmapPointer; executed 1 time by 1 test:  delete [] unmapPointer;Executed by: 
  | 1 | ||||||||||||||||||
| 816 |     } executed 14 times by 2 tests:  end of blockExecuted by: 
  | 14 | ||||||||||||||||||
| 817 | - | |||||||||||||||||||
| 818 | delete resource; | - | ||||||||||||||||||
| 819 | resource = 0; | - | ||||||||||||||||||
| 820 | unmapPointer = 0; | - | ||||||||||||||||||
| 821 | unmapLength = 0; | - | ||||||||||||||||||
| 822 | messageArray = 0; | - | ||||||||||||||||||
| 823 | contextArray = 0; | - | ||||||||||||||||||
| 824 | offsetArray = 0; | - | ||||||||||||||||||
| 825 | numerusRulesArray = 0; | - | ||||||||||||||||||
| 826 | messageLength = 0; | - | ||||||||||||||||||
| 827 | contextLength = 0; | - | ||||||||||||||||||
| 828 | offsetLength = 0; | - | ||||||||||||||||||
| 829 | numerusRulesLength = 0; | - | ||||||||||||||||||
| 830 | - | |||||||||||||||||||
| 831 | qDeleteAll(subTranslators); | - | ||||||||||||||||||
| 832 | subTranslators.clear(); | - | ||||||||||||||||||
| 833 | - | |||||||||||||||||||
| 834 |     if (QCoreApplicationPrivate::isTranslatorInstalled(q)
  | 3-35 | ||||||||||||||||||
| 835 |         QCoreApplication::postEvent(QCoreApplication::instance(), executed 3 times by 1 test:  QCoreApplication::postEvent(QCoreApplication::instance(), new QEvent(QEvent::LanguageChange));Executed by: 
  | 3 | ||||||||||||||||||
| 836 |                                     new QEvent(QEvent::LanguageChange)); executed 3 times by 1 test:  QCoreApplication::postEvent(QCoreApplication::instance(), new QEvent(QEvent::LanguageChange));Executed by: 
  | 3 | ||||||||||||||||||
| 837 | } executed 38 times by 5 tests:  end of blockExecuted by: 
  | 38 | ||||||||||||||||||
| 838 | QString QTranslator::translate(const char *context, const char *sourceText, const char *disambiguation, | - | ||||||||||||||||||
| 839 | int n) const | - | ||||||||||||||||||
| 840 | { | - | ||||||||||||||||||
| 841 | const QTranslatorPrivate * const d = d_func(); | - | ||||||||||||||||||
| 842 |     return executed 260 times by 2 tests:   d->do_translate(context, sourceText, disambiguation, n);return d->do_translate(context, sourceText, disambiguation, n);Executed by: 
 executed 260 times by 2 tests:  return d->do_translate(context, sourceText, disambiguation, n);Executed by: 
  | 260 | ||||||||||||||||||
| 843 | } | - | ||||||||||||||||||
| 844 | - | |||||||||||||||||||
| 845 | - | |||||||||||||||||||
| 846 | - | |||||||||||||||||||
| 847 | - | |||||||||||||||||||
| 848 | - | |||||||||||||||||||
| 849 | bool QTranslator::isEmpty() const | - | ||||||||||||||||||
| 850 | { | - | ||||||||||||||||||
| 851 | const QTranslatorPrivate * const d = d_func(); | - | ||||||||||||||||||
| 852 |     return executed 39 times by 2 tests:   !d->unmapPointer && !d->unmapLength && !d->messageArray &&return !d->unmapPointer && !d->unmapLength && !d->messageArray && !d->offsetArray && !d->contextArray && d->subTranslators.isEmpty();Executed by: 
 executed 39 times by 2 tests:  return !d->unmapPointer && !d->unmapLength && !d->messageArray && !d->offsetArray && !d->contextArray && d->subTranslators.isEmpty();Executed by: 
  | 39 | ||||||||||||||||||
| 853 |            !d->offsetArray && !d->contextArray && d->subTranslators.isEmpty(); executed 39 times by 2 tests:  return !d->unmapPointer && !d->unmapLength && !d->messageArray && !d->offsetArray && !d->contextArray && d->subTranslators.isEmpty();Executed by: 
  | 39 | ||||||||||||||||||
| 854 | } | - | ||||||||||||||||||
| 855 | - | |||||||||||||||||||
| 856 | - | |||||||||||||||||||
| Switch to Source code | Preprocessed file |