MCPcopy Create free account
hub / github.com/RomanKubiak/ctrlr / matchbalance

Function matchbalance

Source/Misc/lua/src/lua.c:13958–13975  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13956
13957
13958static const char *matchbalance (MatchState *ms, const char *s,
13959const char *p) {
13960if (*p == 0 || *(p+1) == 0)
13961luaL_error(ms->L, "unbalanced pattern");
13962if (*s != *p) return NULL;
13963else {
13964int b = *p;
13965int e = *(p+1);
13966int cont = 1;
13967while (++s < ms->src_end) {
13968if (*s == e) {
13969if (--cont == 0) return s+1;
13970}
13971else if (*s == b) cont++;
13972}
13973}
13974return NULL; /* string ends out of balance */
13975}
13976
13977
13978static 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