This commit is contained in:
Julian Daube 2017-10-08 03:53:03 +02:00
parent 25cb4747b8
commit 72e80721e8

View File

@ -149,18 +149,21 @@ Substring readBrackets(Substring &input, const char * brackets) {
return Substring(); return Substring();
} }
input.start++;
int depth = 1; int depth = 1;
Substring result(input.start, input.start); Substring result(input.start, input.start);
while(depth > 0 && input.size() > 0) { while(depth > 0 && input.size() > 0) {
result.end = ++input.start;
if (*input.start == brackets[0]) { if (*input.start == brackets[0]) {
depth++; depth++;
} }
if (*input.start == brackets[1]) { if (*input.start == brackets[1]) {
depth--; depth--;
if(depth==0) break;
} }
result.end = ++input.start;
} }
// advance beyond last bracket // advance beyond last bracket
if (input.size()) if (input.size())