From 86cf9b58635149405cb5600b65c16fdf2ddc732d Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Sun, 5 May 2013 14:50:18 -0500 Subject: Fix Kate syntax highlighting stall This resolves Bug 1279 --- kate/part/katehighlight.cpp | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) (limited to 'kate/part') diff --git a/kate/part/katehighlight.cpp b/kate/part/katehighlight.cpp index 119b718fb..8c6ce36e5 100644 --- a/kate/part/katehighlight.cpp +++ b/kate/part/katehighlight.cpp @@ -439,24 +439,23 @@ KateHlItem::~KateHlItem() void KateHlItem::dynamicSubstitute(TQString &str, const TQStringList *args) { - for (uint i = 0; i < str.length() - 1; ++i) - { - if (str[i] == '%') - { - char c = str[i + 1].latin1(); - if (c == '%') - str.replace(i, 1, ""); - else if (c >= '0' && c <= '9') - { - if ((uint)(c - '0') < args->size()) - { - str.replace(i, 2, (*args)[c - '0']); - i += ((*args)[c - '0']).length() - 1; + uint strLength = str.length(); + if (strLength > 0) { + for (uint i = 0; i < strLength - 1; ++i) { + if (str[i] == '%') { + char c = str[i + 1].latin1(); + if (c == '%') { + str.replace(i, 1, ""); } - else - { - str.replace(i, 2, ""); - --i; + else if (c >= '0' && c <= '9') { + if ((uint)(c - '0') < args->size()) { + str.replace(i, 2, (*args)[c - '0']); + i += ((*args)[c - '0']).length() - 1; + } + else { + str.replace(i, 2, ""); + --i; + } } } } @@ -1038,7 +1037,7 @@ static int checkEscapedChar(const TQString& text, int offset, int& len) // replaced with something else but // for right now they work // check for hexdigits - for (i = 0; (len > 0) && (i < 2) && (static_cast(text.at(offset)) >= '0' && static_cast(text.at(offset)) <= '9' || (text[offset] & 0xdf) >= 'A' && (text[offset] & 0xdf) <= 'F'); i++) + for (i = 0; (len > 0) && (i < 2) && (((static_cast(text.at(offset)) >= '0') && (static_cast(text.at(offset)) <= '9')) || ((text[offset] & 0xdf) >= 'A' && (text[offset] & 0xdf) <= 'F')); i++) { offset++; len--; @@ -1460,7 +1459,7 @@ void KateHighlighting::doHighlight ( KateTextLine *prevLine, if (item->region2) { // kdDebug(13010)<region2)<isEmpty() && ((item->region2 < 0) && (*foldingList)[foldingList->size()-2] == -item->region2 ) ) + if ( !foldingList->isEmpty() && ((item->region2 < 0) && ((int)((*foldingList)[foldingList->size()-2]) == -item->region2) ) ) { foldingList->resize (foldingList->size()-2, TQGArray::SpeedOptim); } @@ -2826,7 +2825,7 @@ int KateHighlighting::addToContextList(const TQString &ident, int ctx0) // to be matched to at once) datasub=KateHlManager::self()->syntax->getSubItems(data); bool tmpbool; - if (tmpbool=KateHlManager::self()->syntax->nextItem(datasub)) + if ((tmpbool = KateHlManager::self()->syntax->nextItem(datasub))) { for (;tmpbool;tmpbool=KateHlManager::self()->syntax->nextItem(datasub)) { -- cgit v1.2.3