MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / matchbalance

Function matchbalance

lib/lua/src/lstrlib.c:486–503  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

matchFunction · 0.85

Calls 1

luaL_errorFunction · 0.85

Tested by

no test coverage detected