| 252 | } |
| 253 | |
| 254 | static tp_chain_t tp_parse_sequence(tp_expander_t *exp, unsigned depth, bool in_group) { |
| 255 | tp_chain_t result = {0}; |
| 256 | size_t literal = exp->pos; |
| 257 | while (exp->pos < exp->len && exp->valid) { |
| 258 | char ch = exp->text[exp->pos]; |
| 259 | if (ch == '\\' && exp->pos + 1 < exp->len) { |
| 260 | exp->pos += 2; |
| 261 | continue; |
| 262 | } |
| 263 | if (ch == '[') { |
| 264 | exp->pos = tp_class_end(exp->text, exp->len, exp->pos); |
| 265 | continue; |
| 266 | } |
| 267 | if (ch == '}' || (in_group && ch == ',')) { |
| 268 | if (!in_group) |
| 269 | exp->valid = false; |
| 270 | break; |
| 271 | } |
| 272 | if (ch == '{') { |
| 273 | if (exp->pos > literal) |
| 274 | tp_chain_literal(exp, &result, exp->text + literal, exp->pos - literal); |
| 275 | tp_chain_t group = tp_parse_group(exp, depth); |
| 276 | tp_chain_append(&result, group); |
| 277 | literal = exp->pos; |
| 278 | } else { |
| 279 | exp->pos++; |
| 280 | } |
| 281 | } |
| 282 | if (exp->valid && exp->pos > literal) |
| 283 | tp_chain_literal(exp, &result, exp->text + literal, exp->pos - literal); |
| 284 | return result; |
| 285 | } |
| 286 | |
| 287 | static unsigned char tp_class_char(const char *text, size_t end, size_t *pos) { |
| 288 | if (text[*pos] == '\\' && *pos + 1 < end) |
no test coverage detected