| 267 | |
| 268 | |
| 269 | static const char *classend(MatchState *ms, const char *p) { |
| 270 | switch (*p++) { |
| 271 | case L_ESC: { |
| 272 | if (p == ms->p_end) |
| 273 | luaL_error(ms->L, "malformed pattern (ends with '%%')"); |
| 274 | return p + 1; |
| 275 | } |
| 276 | case '[': { |
| 277 | if (*p == '^') p++; |
| 278 | do { /* look for a ']' */ |
| 279 | if (p == ms->p_end) |
| 280 | luaL_error(ms->L, "malformed pattern (missing ']')"); |
| 281 | if (*(p++) == L_ESC && p < ms->p_end) |
| 282 | p++; /* skip escapes (e.g. '%]') */ |
| 283 | } while (*p != ']'); |
| 284 | return p + 1; |
| 285 | } |
| 286 | default: { |
| 287 | return p; |
| 288 | } |
| 289 | } |
| 290 | } |
| 291 | |
| 292 | |
| 293 | static int match_class(int c, int cl) { |