MCPcopy Create free account
hub / github.com/Achain-Dev/Achain / matchbalance

Function matchbalance

src/Chain/libraries/glua/lstrlib.cpp:352–369  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

350
351
352static const char *matchbalance(MatchState *ms, const char *s,
353 const char *p) {
354 if (p >= ms->p_end - 1)
355 luaL_error(ms->L, "malformed pattern (missing arguments to '%%b')");
356 if (*s != *p) return nullptr;
357 else {
358 int b = *p;
359 int e = *(p + 1);
360 int cont = 1;
361 while (++s < ms->src_end) {
362 if (*s == e) {
363 if (--cont == 0) return s + 1;
364 }
365 else if (*s == b) cont++;
366 }
367 }
368 return nullptr; /* string ends out of balance */
369}
370
371
372static 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