diff options
author | Simon Hausmann <simon.hausmann@theqtcompany.com> | 2014-12-10 07:58:06 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@theqtcompany.com> | 2014-12-10 07:58:06 +0100 |
commit | 015002fec9abff6a4c1bb3fa4b9de87279a079c3 (patch) | |
tree | ad93af535a503d0a49d6c6367e990a8fbca163d3 /src/corelib/kernel/qtranslator.cpp | |
parent | f1e00262321cc8daa3c7506153653453e2779886 (diff) | |
parent | b9547af45ea2bbbc634722c1ef41afdb54216ce2 (diff) |
Merge remote-tracking branch 'origin/5.4' into dev
Conflicts:
doc/global/template/style/online.css
mkspecs/android-g++/qmake.conf
Change-Id: Ib39ea7bd42f5ae12e82a3bc59a66787a16bdfc61
Diffstat (limited to 'src/corelib/kernel/qtranslator.cpp')
-rw-r--r-- | src/corelib/kernel/qtranslator.cpp | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/corelib/kernel/qtranslator.cpp b/src/corelib/kernel/qtranslator.cpp index a2cf4a7813..a9c608384a 100644 --- a/src/corelib/kernel/qtranslator.cpp +++ b/src/corelib/kernel/qtranslator.cpp @@ -86,13 +86,13 @@ static const uchar magic[MagicLength] = { 0xcd, 0x21, 0x1c, 0xbf, 0x60, 0xa1, 0xbd, 0xdd }; -static bool match(const uchar* found, const char* target, uint len) +static bool match(const uchar *found, uint foundLen, const char *target, uint targetLen) { // catch the case if \a found has a zero-terminating symbol and \a len includes it. // (normalize it to be without the zero-terminating symbol) - if (len > 0 && found[len-1] == '\0') - --len; - return (memcmp(found, target, len) == 0 && target[len] == '\0'); + if (foundLen > 0 && found[foundLen-1] == '\0') + --foundLen; + return ((targetLen == foundLen) && memcmp(found, target, foundLen) == 0); } static void elfHash_continue(const char *name, uint &h) @@ -878,6 +878,9 @@ static QString getMessage(const uchar *m, const uchar *end, const char *context, { const uchar *tn = 0; uint tn_length = 0; + const uint sourceTextLen = uint(strlen(sourceText)); + const uint contextLen = uint(strlen(context)); + const uint commentLen = uint(strlen(comment)); for (;;) { uchar tag = 0; @@ -904,7 +907,7 @@ static QString getMessage(const uchar *m, const uchar *end, const char *context, case Tag_SourceText: { quint32 len = read32(m); m += 4; - if (!match(m, sourceText, len)) + if (!match(m, len, sourceText, sourceTextLen)) return QString(); m += len; } @@ -912,7 +915,7 @@ static QString getMessage(const uchar *m, const uchar *end, const char *context, case Tag_Context: { quint32 len = read32(m); m += 4; - if (!match(m, context, len)) + if (!match(m, len, context, contextLen)) return QString(); m += len; } @@ -920,7 +923,7 @@ static QString getMessage(const uchar *m, const uchar *end, const char *context, case Tag_Comment: { quint32 len = read32(m); m += 4; - if (*m && !match(m, comment, len)) + if (*m && !match(m, len, comment, commentLen)) return QString(); m += len; } @@ -970,11 +973,12 @@ QString QTranslatorPrivate::do_translate(const char *context, const char *source return QString(); c = contextArray + (2 + (hTableSize << 1) + (off << 1)); + const uint contextLen = uint(strlen(context)); for (;;) { quint8 len = read8(c++); if (len == 0) return QString(); - if (match(c, context, len)) + if (match(c, len, context, contextLen)) break; c += len; } |