MCPcopy Create free account
hub / github.com/F-Stack/f-stack / matchbalance

Function matchbalance

freebsd/contrib/openzfs/module/lua/lstrlib.c:336–354  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

334
335
336static const char *matchbalance (MatchState *ms, const char *s,
337 const char *p) {
338 if (p >= ms->p_end - 1)
339 luaL_error(ms->L, "malformed pattern "
340 "(missing arguments to " LUA_QL("%%b") ")");
341 if (*s != *p) return NULL;
342 else {
343 int b = *p;
344 int e = *(p+1);
345 int cont = 1;
346 while (++s < ms->src_end) {
347 if (*s == e) {
348 if (--cont == 0) return s+1;
349 }
350 else if (*s == b) cont++;
351 }
352 }
353 return NULL; /* string ends out of balance */
354}
355
356
357static 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