* @brief If line[i:] closes a Lua long-bracket form at the given level, returns the length. */
| 156 | * @brief If line[i:] closes a Lua long-bracket form at the given level, returns the length. |
| 157 | */ |
| 158 | static bool tryLuaLongClose(QStringView line, int i, int level, int& outConsume) |
| 159 | { |
| 160 | if (i >= line.size() || line[i] != QLatin1Char(']')) |
| 161 | return false; |
| 162 | |
| 163 | int j = i + 1; |
| 164 | int seen = 0; |
| 165 | while (seen < level && j < line.size() && line[j] == QLatin1Char('=')) { |
| 166 | ++seen; |
| 167 | ++j; |
| 168 | } |
| 169 | |
| 170 | if (seen != level) |
| 171 | return false; |
| 172 | |
| 173 | if (j >= line.size() || line[j] != QLatin1Char(']')) |
| 174 | return false; |
| 175 | |
| 176 | outConsume = (j - i) + 1; |
| 177 | return true; |
| 178 | } |
| 179 | |
| 180 | /** |
| 181 | * @brief Skips a quoted string literal starting at line[i] (assumes line[i] is the open quote). |