Findadv: Initialize the position of first unprocessed open parentheses

Not initializing caused some wrong matches.
This commit is contained in:
Kornel Benko 2018-11-06 15:28:43 +01:00
parent e487274ff4
commit 4f1cd00b02

View File

@ -951,7 +951,7 @@ class Border {
class Intervall {
bool isPatternString;
public:
Intervall(bool isPattern) : isPatternString(isPattern), ignoreidx(-1), actualdeptindex(0) {};
Intervall(bool isPattern) : isPatternString(isPattern), ignoreidx(-1), actualdeptindex(0) { depts[0] = 0;};
string par;
int ignoreidx;
int depts[MAXOPENED];
@ -1266,7 +1266,6 @@ class LatexInfo {
return entries[keyinfo];
};
void setForDefaultLang(int upTo) {interval.setForDefaultLang(upTo);};
};
@ -1795,9 +1794,9 @@ int LatexInfo::dispatch(ostringstream &os, int previousStart, KeyInfo &actual)
}
int blk = interval.nextNotIgnored(actual._dataEnd+1);
if (blk > posdown) {
// Discard spaces after empty item
// Discard at most 1 space after empty item
int count;
for (count = 0; count < 10; count++) {
for (count = 0; count < 1; count++) {
if (interval.par[blk+count] != ' ')
break;
}
@ -2484,7 +2483,6 @@ int findAdvFinalize(DocIterator & cur, MatchStringAdv const & match)
int new_len;
// Greedy behaviour while matching regexps
bool examining = true;
int lastvalidlen = -1;
while (examining) {
examining = false;
// Kornel: The loop is needed, since it looks like
@ -2501,16 +2499,8 @@ int findAdvFinalize(DocIterator & cur, MatchStringAdv const & match)
examining = true;
break;
}
else if (new_len == old_len)
lastvalidlen = len+count;
}
}
if (lastvalidlen == len + 1) {
// Kornel: Don't know, why this is important
// All I can see, is that sometimes the last char
// is outside of a match although it should be inside
len++;
}
return len;
}