MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / matchbalance

Function matchbalance

extlibs/lua/src/lstrlib.c:483–500  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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