ms                186 lib/lua/lstrlib.c static int check_capture (MatchState *ms, int l) {
ms                188 lib/lua/lstrlib.c   if (l < 0 || l >= ms->level || ms->capture[l].len == CAP_UNFINISHED)
ms                189 lib/lua/lstrlib.c     return luaL_error(ms->L, "invalid capture index");
ms                194 lib/lua/lstrlib.c static int capture_to_close (MatchState *ms) {
ms                195 lib/lua/lstrlib.c   int level = ms->level;
ms                197 lib/lua/lstrlib.c     if (ms->capture[level].len == CAP_UNFINISHED) return level;
ms                198 lib/lua/lstrlib.c   return luaL_error(ms->L, "invalid pattern capture");
ms                202 lib/lua/lstrlib.c static const char *classend (MatchState *ms, const char *p) {
ms                206 lib/lua/lstrlib.c         luaL_error(ms->L, "malformed pattern (ends with " LUA_QL("%%") ")");
ms                213 lib/lua/lstrlib.c           luaL_error(ms->L, "malformed pattern (missing " LUA_QL("]") ")");
ms                278 lib/lua/lstrlib.c static const char *match (MatchState *ms, const char *s, const char *p);
ms                281 lib/lua/lstrlib.c static const char *matchbalance (MatchState *ms, const char *s,
ms                284 lib/lua/lstrlib.c     luaL_error(ms->L, "unbalanced pattern");
ms                290 lib/lua/lstrlib.c     while (++s < ms->src_end) {
ms                301 lib/lua/lstrlib.c static const char *max_expand (MatchState *ms, const char *s,
ms                304 lib/lua/lstrlib.c   while ((s+i)<ms->src_end && singlematch(uchar(*(s+i)), p, ep))
ms                308 lib/lua/lstrlib.c     const char *res = match(ms, (s+i), ep+1);
ms                316 lib/lua/lstrlib.c static const char *min_expand (MatchState *ms, const char *s,
ms                319 lib/lua/lstrlib.c     const char *res = match(ms, s, ep+1);
ms                322 lib/lua/lstrlib.c     else if (s<ms->src_end && singlematch(uchar(*s), p, ep))
ms                329 lib/lua/lstrlib.c static const char *start_capture (MatchState *ms, const char *s,
ms                332 lib/lua/lstrlib.c   int level = ms->level;
ms                333 lib/lua/lstrlib.c   if (level >= LUA_MAXCAPTURES) luaL_error(ms->L, "too many captures");
ms                334 lib/lua/lstrlib.c   ms->capture[level].init = s;
ms                335 lib/lua/lstrlib.c   ms->capture[level].len = what;
ms                336 lib/lua/lstrlib.c   ms->level = level+1;
ms                337 lib/lua/lstrlib.c   if ((res=match(ms, s, p)) == NULL)  /* match failed? */
ms                338 lib/lua/lstrlib.c     ms->level--;  /* undo capture */
ms                343 lib/lua/lstrlib.c static const char *end_capture (MatchState *ms, const char *s,
ms                345 lib/lua/lstrlib.c   int l = capture_to_close(ms);
ms                347 lib/lua/lstrlib.c   ms->capture[l].len = s - ms->capture[l].init;  /* close capture */
ms                348 lib/lua/lstrlib.c   if ((res = match(ms, s, p)) == NULL)  /* match failed? */
ms                349 lib/lua/lstrlib.c     ms->capture[l].len = CAP_UNFINISHED;  /* undo capture */
ms                354 lib/lua/lstrlib.c static const char *match_capture (MatchState *ms, const char *s, int l) {
ms                356 lib/lua/lstrlib.c   l = check_capture(ms, l);
ms                357 lib/lua/lstrlib.c   len = ms->capture[l].len;
ms                358 lib/lua/lstrlib.c   if ((size_t)(ms->src_end-s) >= len &&
ms                359 lib/lua/lstrlib.c       memcmp(ms->capture[l].init, s, len) == 0)
ms                365 lib/lua/lstrlib.c static const char *match (MatchState *ms, const char *s, const char *p) {
ms                370 lib/lua/lstrlib.c         return start_capture(ms, s, p+2, CAP_POSITION);
ms                372 lib/lua/lstrlib.c         return start_capture(ms, s, p+1, CAP_UNFINISHED);
ms                375 lib/lua/lstrlib.c       return end_capture(ms, s, p+1);
ms                380 lib/lua/lstrlib.c           s = matchbalance(ms, s, p+2);
ms                388 lib/lua/lstrlib.c             luaL_error(ms->L, "missing " LUA_QL("[") " after "
ms                390 lib/lua/lstrlib.c           ep = classend(ms, p);  /* points to what is next */
ms                391 lib/lua/lstrlib.c           previous = (s == ms->src_init) ? '\0' : *(s-1);
ms                398 lib/lua/lstrlib.c             s = match_capture(ms, s, uchar(*(p+1)));
ms                411 lib/lua/lstrlib.c         return (s == ms->src_end) ? s : NULL;  /* check end of string */
ms                415 lib/lua/lstrlib.c       const char *ep = classend(ms, p);  /* points to what is next */
ms                416 lib/lua/lstrlib.c       int m = s<ms->src_end && singlematch(uchar(*s), p, ep);
ms                420 lib/lua/lstrlib.c           if (m && ((res=match(ms, s+1, ep+1)) != NULL))
ms                425 lib/lua/lstrlib.c           return max_expand(ms, s, p, ep);
ms                428 lib/lua/lstrlib.c           return (m ? max_expand(ms, s+1, p, ep) : NULL);
ms                431 lib/lua/lstrlib.c           return min_expand(ms, s, p, ep);
ms                466 lib/lua/lstrlib.c static void push_onecapture (MatchState *ms, int i, const char *s,
ms                468 lib/lua/lstrlib.c   if (i >= ms->level) {
ms                470 lib/lua/lstrlib.c       lua_pushlstring(ms->L, s, e - s);  /* add whole match */
ms                472 lib/lua/lstrlib.c       luaL_error(ms->L, "invalid capture index");
ms                475 lib/lua/lstrlib.c     ptrdiff_t l = ms->capture[i].len;
ms                476 lib/lua/lstrlib.c     if (l == CAP_UNFINISHED) luaL_error(ms->L, "unfinished capture");
ms                478 lib/lua/lstrlib.c       lua_pushinteger(ms->L, ms->capture[i].init - ms->src_init + 1);
ms                480 lib/lua/lstrlib.c       lua_pushlstring(ms->L, ms->capture[i].init, l);
ms                485 lib/lua/lstrlib.c static int push_captures (MatchState *ms, const char *s, const char *e) {
ms                487 lib/lua/lstrlib.c   int nlevels = (ms->level == 0 && s) ? 1 : ms->level;
ms                488 lib/lua/lstrlib.c   luaL_checkstack(ms->L, nlevels, "too many captures");
ms                490 lib/lua/lstrlib.c     push_onecapture(ms, i, s, e);
ms                513 lib/lua/lstrlib.c     MatchState ms;
ms                516 lib/lua/lstrlib.c     ms.L = L;
ms                517 lib/lua/lstrlib.c     ms.src_init = s;
ms                518 lib/lua/lstrlib.c     ms.src_end = s+l1;
ms                521 lib/lua/lstrlib.c       ms.level = 0;
ms                522 lib/lua/lstrlib.c       if ((res=match(&ms, s1, p)) != NULL) {
ms                526 lib/lua/lstrlib.c           return push_captures(&ms, NULL, 0) + 2;
ms                529 lib/lua/lstrlib.c           return push_captures(&ms, s1, res);
ms                531 lib/lua/lstrlib.c     } while (s1++ < ms.src_end && !anchor);
ms                549 lib/lua/lstrlib.c   MatchState ms;
ms                554 lib/lua/lstrlib.c   ms.L = L;
ms                555 lib/lua/lstrlib.c   ms.src_init = s;
ms                556 lib/lua/lstrlib.c   ms.src_end = s+ls;
ms                558 lib/lua/lstrlib.c        src <= ms.src_end;
ms                561 lib/lua/lstrlib.c     ms.level = 0;
ms                562 lib/lua/lstrlib.c     if ((e = match(&ms, src, p)) != NULL) {
ms                567 lib/lua/lstrlib.c       return push_captures(&ms, src, e);
ms                590 lib/lua/lstrlib.c static void add_s (MatchState *ms, luaL_Buffer *b, const char *s,
ms                593 lib/lua/lstrlib.c   const char *news = lua_tolstring(ms->L, 3, &l);
ms                604 lib/lua/lstrlib.c         push_onecapture(ms, news[i] - '1', s, e);
ms                612 lib/lua/lstrlib.c static void add_value (MatchState *ms, luaL_Buffer *b, const char *s,
ms                614 lib/lua/lstrlib.c   lua_State *L = ms->L;
ms                618 lib/lua/lstrlib.c       add_s(ms, b, s, e);
ms                624 lib/lua/lstrlib.c       n = push_captures(ms, s, e);
ms                629 lib/lua/lstrlib.c       push_onecapture(ms, 0, s, e);
ms                652 lib/lua/lstrlib.c   MatchState ms;
ms                658 lib/lua/lstrlib.c   ms.L = L;
ms                659 lib/lua/lstrlib.c   ms.src_init = src;
ms                660 lib/lua/lstrlib.c   ms.src_end = src+srcl;
ms                663 lib/lua/lstrlib.c     ms.level = 0;
ms                664 lib/lua/lstrlib.c     e = match(&ms, src, p);
ms                667 lib/lua/lstrlib.c       add_value(&ms, &b, src, e);
ms                671 lib/lua/lstrlib.c     else if (src < ms.src_end)
ms                676 lib/lua/lstrlib.c   luaL_addlstring(&b, src, ms.src_end-src);