| 251 | |
| 252 | |
| 253 | static const char *classend (MatchState *ms, const char *p) { |
| 254 | switch (*p++) { |
| 255 | case L_ESC: { |
| 256 | if (p == ms->p_end) |
| 257 | luaL_error(ms->L, "malformed pattern (ends with " LUA_QL("%%") ")"); |
| 258 | return p+1; |
| 259 | } |
| 260 | case '[': { |
| 261 | if (*p == '^') p++; |
| 262 | do { /* look for a `]' */ |
| 263 | if (p == ms->p_end) |
| 264 | luaL_error(ms->L, "malformed pattern (missing " LUA_QL("]") ")"); |
| 265 | if (*(p++) == L_ESC && p < ms->p_end) |
| 266 | p++; /* skip escapes (e.g. `%]') */ |
| 267 | } while (*p != ']'); |
| 268 | return p+1; |
| 269 | } |
| 270 | default: { |
| 271 | return p; |
| 272 | } |
| 273 | } |
| 274 | } |
| 275 | |
| 276 | |
| 277 | static int match_class (int c, int cl) { |