| 200 | |
| 201 | |
| 202 | static const char *classend (MatchState *ms, const char *p) { |
| 203 | switch (*p++) { |
| 204 | case L_ESC: { |
| 205 | if (*p == '\0') |
| 206 | luaL_error(ms->L, "malformed pattern (ends with " LUA_QL("%%") ")"); |
| 207 | return p+1; |
| 208 | } |
| 209 | case '[': { |
| 210 | if (*p == '^') p++; |
| 211 | do { /* look for a `]' */ |
| 212 | if (*p == '\0') |
| 213 | luaL_error(ms->L, "malformed pattern (missing " LUA_QL("]") ")"); |
| 214 | if (*(p++) == L_ESC && *p != '\0') |
| 215 | p++; /* skip escapes (e.g. `%]') */ |
| 216 | } while (*p != ']'); |
| 217 | return p+1; |
| 218 | } |
| 219 | default: { |
| 220 | return p; |
| 221 | } |
| 222 | } |
| 223 | } |
| 224 | |
| 225 | |
| 226 | static int match_class (int c, int cl) { |