summaryrefslogtreecommitdiffstats
path: root/kate/part/katehighlight.cpp
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-05-05 14:50:18 -0500
committerSlávek Banko <slavek.banko@axis.cz>2013-05-06 01:22:43 +0200
commit9977a7c43cab59bcf09382f930ea5897a10e16fc (patch)
treec4d00ace6438679e13f98dbc0970f08754781df4 /kate/part/katehighlight.cpp
parente80d466d7e4fd7b08fba2edd36aab8af27706e9c (diff)
downloadtdelibs-9977a7c43cab59bcf09382f930ea5897a10e16fc.tar.gz
tdelibs-9977a7c43cab59bcf09382f930ea5897a10e16fc.zip
Fix Kate syntax highlighting stall
This resolves Bug 1279 (cherry picked from commit 86cf9b58635149405cb5600b65c16fdf2ddc732d)
Diffstat (limited to 'kate/part/katehighlight.cpp')
-rw-r--r--kate/part/katehighlight.cpp39
1 files changed, 19 insertions, 20 deletions
diff --git a/kate/part/katehighlight.cpp b/kate/part/katehighlight.cpp
index d5eec4c27..49972cce1 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<const char>(text.at(offset)) >= '0' && static_cast<const char>(text.at(offset)) <= '9' || (text[offset] & 0xdf) >= 'A' && (text[offset] & 0xdf) <= 'F'); i++)
+ for (i = 0; (len > 0) && (i < 2) && (((static_cast<const char>(text.at(offset)) >= '0') && (static_cast<const char>(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)<<TQString("Region mark 2 detected: %1").arg(item->region2)<<endl;
- if ( !foldingList->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))
{