| 13877 | |
| 13878 | |
| 13879 | static const char *classend (MatchState *ms, const char *p) { |
| 13880 | switch (*p++) { |
| 13881 | case L_ESC: { |
| 13882 | if (*p == '\0') |
| 13883 | luaL_error(ms->L, "malformed pattern (ends with " LUA_QL("%%") ")"); |
| 13884 | return p+1; |
| 13885 | } |
| 13886 | case '[': { |
| 13887 | if (*p == '^') p++; |
| 13888 | do { /* look for a `]' */ |
| 13889 | if (*p == '\0') |
| 13890 | luaL_error(ms->L, "malformed pattern (missing " LUA_QL("]") ")"); |
| 13891 | if (*(p++) == L_ESC && *p != '\0') |
| 13892 | p++; /* skip escapes (e.g. `%]') */ |
| 13893 | } while (*p != ']'); |
| 13894 | return p+1; |
| 13895 | } |
| 13896 | default: { |
| 13897 | return p; |
| 13898 | } |
| 13899 | } |
| 13900 | } |
| 13901 | |
| 13902 | |
| 13903 | static int match_class (int c, int cl) { |