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

Function matchbalance

third-party/lua-5.2.4/src/lstrlib.c:325–343  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

323
324
325static const char *matchbalance (MatchState *ms, const char *s,
326 const char *p) {
327 if (p >= ms->p_end - 1)
328 luaL_error(ms->L, "malformed pattern "
329 "(missing arguments to " LUA_QL("%%b") ")");
330 if (*s != *p) return NULL;
331 else {
332 int b = *p;
333 int e = *(p+1);
334 int cont = 1;
335 while (++s < ms->src_end) {
336 if (*s == e) {
337 if (--cont == 0) return s+1;
338 }
339 else if (*s == b) cont++;
340 }
341 }
342 return NULL; /* string ends out of balance */
343}
344
345
346static 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