Commit bb6556d0 authored by jan.koester's avatar jan.koester
Browse files

bugfix flex

parent a35a529d
Loading
Loading
Loading
Loading
+11 −1
Changes for lib/flex/flex.cpp: 11 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -294,7 +294,17 @@ void LexReader::applyConditionBlock(const std::vector<int> &conditions) {
                while (q < src_.size() && (src_[q] == ' ' || src_[q] == '\t')) ++q;
                if (q < src_.size() && src_[q] == '}') {
                    size_t q2 = q + 1; bool onlyWs = true;
                    while (q2 < src_.size() && src_[q2] != '\n') { if (!isspace((unsigned char)src_[q2])) { onlyWs = false; break; } ++q2; }
                    while (q2 < src_.size() && src_[q2] != '\n') {
                        // "} /* <xc> */": a comment may follow the closing brace
                        if (src_[q2] == '/' && q2 + 1 < src_.size() && src_[q2 + 1] == '*') {
                            size_t end = src_.find("*/", q2 + 2);
                            if (end == std::string::npos) { onlyWs = false; break; }
                            q2 = end + 2;
                            continue;
                        }
                        if (!isspace((unsigned char)src_[q2])) { onlyWs = false; break; }
                        ++q2;
                    }
                    if (onlyWs) { pos_ = q; advance(); skipToNextLine(); return; }
                }
            }