static int wsinglematch (lua_WChar c, const lua_WChar *p, const lua_WChar *ep) { switch (*p) { case '.': return 1; /* matches any char */ case WL_ESC: return wmatch_class(c, *(p+1)); case '[': return wmatchbracketclass(c, p, ep-1); default: return (*p == c); } }
static int wmatchbracketclass (lua_WChar c, const lua_WChar *p, const lua_WChar *ec) { int sig = 1; if (*(p+1) == '^') { sig = 0; p++; /* skip the `^' */ } while (++p < ec) { if (*p == WL_ESC) { p++; if (wmatch_class(c, *p)) return sig; } else if ((*(p+1) == '-') && (p+2 < ec)) { p+=2; if (*(p-2) <= c && c <= *p) return sig; } else if (*p == c) return sig; } return !sig; }