MCPcopy Create free account
hub / github.com/BZFlag-Dev/bzflag / add_value

Function add_value

other_src/lua/src/lstrlib.cpp:612–641  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

610
611
612static void add_value (MatchState *ms, luaL_Buffer *b, const char *s,
613 const char *e) {
614 lua_State *L = ms->L;
615 switch (lua_type(L, 3)) {
616 case LUA_TNUMBER:
617 case LUA_TSTRING: {
618 add_s(ms, b, s, e);
619 return;
620 }
621 case LUA_TFUNCTION: {
622 int n;
623 lua_pushvalue(L, 3);
624 n = push_captures(ms, s, e);
625 lua_call(L, n, 1);
626 break;
627 }
628 case LUA_TTABLE: {
629 push_onecapture(ms, 0, s, e);
630 lua_gettable(L, 3);
631 break;
632 }
633 }
634 if (!lua_toboolean(L, -1)) { /* nil or false? */
635 lua_pop(L, 1);
636 lua_pushlstring(L, s, e - s); /* keep original text */
637 }
638 else if (!lua_isstring(L, -1))
639 luaL_error(L, "invalid replacement value (a %s)", luaL_typename(L, -1));
640 luaL_addvalue(b); /* add result to accumulator */
641}
642
643
644static int str_gsub (lua_State *L) {

Callers 1

str_gsubFunction · 0.70

Calls 12

lua_typeFunction · 0.70
add_sFunction · 0.70
lua_pushvalueFunction · 0.70
push_capturesFunction · 0.70
lua_callFunction · 0.70
push_onecaptureFunction · 0.70
lua_gettableFunction · 0.70
lua_tobooleanFunction · 0.70
lua_pushlstringFunction · 0.70
lua_isstringFunction · 0.70
luaL_errorFunction · 0.70
luaL_addvalueFunction · 0.70

Tested by

no test coverage detected