MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / matchbalance

Function matchbalance

third-party/lua-5.5.0/src/lstrlib.c:488–505  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

486
487
488static const char *matchbalance (MatchState *ms, const char *s,
489 const char *p) {
490 if (l_unlikely(p >= ms->p_end - 1))
491 luaL_error(ms->L, "malformed pattern (missing arguments to '%%b')");
492 if (*s != *p) return NULL;
493 else {
494 int b = *p;
495 int e = *(p+1);
496 int cont = 1;
497 while (++s < ms->src_end) {
498 if (*s == e) {
499 if (--cont == 0) return s+1;
500 }
501 else if (*s == b) cont++;
502 }
503 }
504 return NULL; /* string ends out of balance */
505}
506
507
508static const char *max_expand (MatchState *ms, const char *s,

Callers 1

matchFunction · 0.70

Calls 1

luaL_errorFunction · 0.70

Tested by

no test coverage detected