diff options
Diffstat (limited to 'src/corelib/text/qstring.cpp')
-rw-r--r-- | src/corelib/text/qstring.cpp | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp index 3779b90d6f..3e88ab4859 100644 --- a/src/corelib/text/qstring.cpp +++ b/src/corelib/text/qstring.cpp @@ -4562,13 +4562,13 @@ int QString::lastIndexOf(const QRegularExpression &re, int from, QRegularExpress return -1; } - int endpos = (from < 0) ? (size() + from + 1) : (from); + int endpos = (from < 0) ? (size() + from + 1) : (from + 1); QRegularExpressionMatchIterator iterator = re.globalMatch(*this); int lastIndex = -1; while (iterator.hasNext()) { QRegularExpressionMatch match = iterator.next(); int start = match.capturedStart(); - if (start <= endpos) { + if (start < endpos) { lastIndex = start; if (rmatch) *rmatch = std::move(match); @@ -7184,13 +7184,17 @@ QString QString::vasprintf(const char *cformat, va_list ap) if (length_mod == lm_l) { const ushort *buff = va_arg(ap, const ushort*); const ushort *ch = buff; - while (*ch != 0) + while (precision != 0 && *ch != 0) { ++ch; + --precision; + } subst.setUtf16(buff, ch - buff); - } else + } else if (precision == -1) { subst = QString::fromUtf8(va_arg(ap, const char*)); - if (precision != -1) - subst.truncate(precision); + } else { + const char *buff = va_arg(ap, const char*); + subst = QString::fromUtf8(buff, qstrnlen(buff, precision)); + } ++c; break; } @@ -8231,7 +8235,7 @@ QVector<QStringRef> QString::splitRef(const QRegularExpression &re, SplitBehavio \value NormalizationForm_KC Compatibility Decomposition followed by Canonical Composition \sa normalized(), - {http://www.unicode.org/reports/tr15/}{Unicode Standard Annex #15} + {https://www.unicode.org/reports/tr15/}{Unicode Standard Annex #15} */ /*! |