(L *LState)
| 146 | } |
| 147 | |
| 148 | func strGsub(L *LState) int { |
| 149 | str := L.CheckString(1) |
| 150 | pat := L.CheckString(2) |
| 151 | L.CheckTypes(3, LTString, LTTable, LTFunction) |
| 152 | repl := L.CheckAny(3) |
| 153 | limit := L.OptInt(4, -1) |
| 154 | |
| 155 | mds, err := pm.Find(pat, unsafeFastStringToReadOnlyBytes(str), 0, limit) |
| 156 | if err != nil { |
| 157 | L.RaiseError(err.Error()) |
| 158 | } |
| 159 | if len(mds) == 0 { |
| 160 | L.SetTop(1) |
| 161 | L.Push(LNumber(0)) |
| 162 | return 2 |
| 163 | } |
| 164 | switch lv := repl.(type) { |
| 165 | case LString: |
| 166 | L.Push(LString(strGsubStr(L, str, string(lv), mds))) |
| 167 | case *LTable: |
| 168 | L.Push(LString(strGsubTable(L, str, lv, mds))) |
| 169 | case *LFunction: |
| 170 | L.Push(LString(strGsubFunc(L, str, lv, mds))) |
| 171 | } |
| 172 | L.Push(LNumber(len(mds))) |
| 173 | return 2 |
| 174 | } |
| 175 | |
| 176 | type replaceInfo struct { |
| 177 | Indicies []int |
nothing calls this directly
no test coverage detected
searching dependent graphs…