| 401 | |
| 402 | |
| 403 | static const char *classend (MatchState *ms, const char *p) { |
| 404 | switch (*p++) { |
| 405 | case L_ESC: { |
| 406 | if (l_unlikely(p == ms->p_end)) |
| 407 | luaL_error(ms->L, "malformed pattern (ends with '%%')"); |
| 408 | return p+1; |
| 409 | } |
| 410 | case '[': { |
| 411 | if (*p == '^') p++; |
| 412 | do { /* look for a ']' */ |
| 413 | if (l_unlikely(p == ms->p_end)) |
| 414 | luaL_error(ms->L, "malformed pattern (missing ']')"); |
| 415 | if (*(p++) == L_ESC && p < ms->p_end) |
| 416 | p++; /* skip escapes (e.g. '%]') */ |
| 417 | } while (*p != ']'); |
| 418 | return p+1; |
| 419 | } |
| 420 | default: { |
| 421 | return p; |
| 422 | } |
| 423 | } |
| 424 | } |
| 425 | |
| 426 | |
| 427 | static int match_class (int c, int cl) { |