Fixed indentation in Stream.cpp, no code change
This commit is contained in:
parent
9e2fdcc8f4
commit
ad7ede5647
|
@ -254,11 +254,12 @@ String Stream::readStringUntil(char terminator)
|
||||||
int Stream::findMulti( struct Stream::MultiTarget *targets, int tCount) {
|
int Stream::findMulti( struct Stream::MultiTarget *targets, int tCount) {
|
||||||
// any zero length target string automatically matches and would make
|
// any zero length target string automatically matches and would make
|
||||||
// a mess of the rest of the algorithm.
|
// a mess of the rest of the algorithm.
|
||||||
for (struct MultiTarget *t = targets; t < targets+tCount; ++t)
|
for (struct MultiTarget *t = targets; t < targets+tCount; ++t) {
|
||||||
if (t->len <= 0)
|
if (t->len <= 0)
|
||||||
return t - targets;
|
return t - targets;
|
||||||
|
}
|
||||||
|
|
||||||
while(1) {
|
while (1) {
|
||||||
int c = timedRead();
|
int c = timedRead();
|
||||||
if (c < 0)
|
if (c < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -277,37 +278,40 @@ int Stream::findMulti( struct Stream::MultiTarget *targets, int tCount) {
|
||||||
// but it will match the second position so we can't just reset the current
|
// but it will match the second position so we can't just reset the current
|
||||||
// index to 0 when we find a mismatch.
|
// index to 0 when we find a mismatch.
|
||||||
if (t->index == 0)
|
if (t->index == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
int origIndex = t->index;
|
int origIndex = t->index;
|
||||||
do {
|
do {
|
||||||
--t->index;
|
--t->index;
|
||||||
// first check if current char works against the new current index
|
// first check if current char works against the new current index
|
||||||
if (c != t->str[t->index])
|
if (c != t->str[t->index])
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// if it's the only char then we're good, nothing more to check
|
// if it's the only char then we're good, nothing more to check
|
||||||
if (t->index == 0) {
|
if (t->index == 0) {
|
||||||
t->index++;
|
t->index++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// otherwise we need to check the rest of the found string
|
// otherwise we need to check the rest of the found string
|
||||||
int diff = origIndex - t->index;
|
int diff = origIndex - t->index;
|
||||||
size_t i;
|
size_t i;
|
||||||
for (i = 0; i < t->index; ++i)
|
for (i = 0; i < t->index; ++i) {
|
||||||
if (t->str[i] != t->str[i + diff])
|
if (t->str[i] != t->str[i + diff])
|
||||||
break;
|
break;
|
||||||
// if we successfully got through the previous loop then our current
|
}
|
||||||
// index is good.
|
|
||||||
if (i == t->index) {
|
// if we successfully got through the previous loop then our current
|
||||||
t->index++;
|
// index is good.
|
||||||
break;
|
if (i == t->index) {
|
||||||
}
|
t->index++;
|
||||||
// otherwise we just try the next index
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// otherwise we just try the next index
|
||||||
} while (t->index);
|
} while (t->index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// unreachable
|
// unreachable
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue