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