str_gsub
function · lua · boundary
- Address
0x7fd0e0· 438 bytes, up to0x7fd295- Signature
int __fastcall (lua_State *L)- Meaning
- Pushes a string with the matches of a pattern replaced, and the replacement count
- Confidence
- verified, proof one
- Finding
- lua/libs#search-and-replace
Finding: Search and replace in lua: the libraries
str_find searches for a pattern, or for a plain string when the fourth argument is true or the
pattern has none of the characters ^$*+?.([%-, and answers the start, the end and the captures.
gfind returns an iterator closure over gfind_aux, which carries the subject, pattern and
next position in three upvalues. str_gsub replaces matches with a string or a function result
through add_s and answers the new string and the count. push_captures and push_onecapture
push the captures, lmemfind is the plain search.
| function | name | decided by |
|---|---|---|
0x7fc3b0 | str_find | luaL_optnumber init (0x7fc3f2), lua_toboolean plain (0x7fc41c), strpbrk of the special set (0x7fc432), lmemfind (0x7fc515) |
0x7fce50 | lmemfind | memchr of the first byte (0x7fce99), an empty needle returns the start |
0x7fcee0 | push_captures | luaL_checkstack too many captures (0x7fcef4), whole match by lua_pushlstring (0x7fcf0f), push_onecapture (0x7fcf29) |
0x7fcf40 | push_onecapture | length -1 raises unfinished capture (0x7fcf57), -2 pushes a position (0x7fcf79, 0x7fcf94) |
0x7fcfa0 | gfind | two luaL_checklstring, lua_settop 2 (0x7fcfc4), 0 pushed, lua_pushcclosure with 3 upvalues (0x7fcfdd) |
0x7fcff0 | gfind_aux | upvalues read by lua_tostring and lua_tonumber (0x7fd003..0x7fd045), match (0x7fd076), lua_replace (0x7fd0be) |
0x7fd0e0 | str_gsub | maximum count luaL_optnumber (0x7fd12f), anchor ^ (0x7fd13c), string or function expected (0x7fd189), add_s (0x7fd203) |
0x7fd2a0 | add_s | lua_isstring (0x7fd2b8), % handling (0x7fd2f0), check_capture, push_onecapture, lua_call (0x7fd38d) |
The derivation is in the doc.
Callers 0
None by a direct call or jump.
Callees 14
- __ftol crt
- lua_gettop lua
- lua_type lua
- lua_isstring lua
- lua_pushnumber lua
- luaL_argerror lua
- luaL_checklstring lua
- luaL_optnumber lua
- luaL_prepbuffer lua
- luaL_addlstring lua
- luaL_pushresult lua
- luaL_buffinit lua
- match lua
- add_s lua
Calls and jumps by a bare address, from tables/calls.tsv.