MCPcopy Create free account
hub / github.com/alliedmodders/sourcemod / MatchRegexAll

Function MatchRegexAll

extensions/regex/extension.cpp:164–215  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

162}
163
164static cell_t MatchRegexAll(IPluginContext *pCtx, const cell_t *params)
165{
166 Handle_t hndl = static_cast<Handle_t>(params[1]);
167 HandleError err;
168 HandleSecurity sec;
169 sec.pOwner = NULL;
170 sec.pIdentity = myself->GetIdentity();
171
172 RegEx *x;
173
174 if ((err = g_pHandleSys->ReadHandle(hndl, g_RegexHandle, &sec, (void **)&x)) != HandleError_None)
175 {
176 return pCtx->ThrowNativeError("Invalid regex handle %x (error %d)", hndl, err);
177 }
178
179 if (!x)
180 {
181 pCtx->ThrowNativeError("Regex data not found\n");
182
183 return 0;
184 }
185
186 char *str;
187 pCtx->LocalToString(params[2], &str);
188
189 int e = x->MatchAll(str);
190
191 if (e == -1)
192 {
193 /* there was a match error. move on. */
194 cell_t *res;
195 pCtx->LocalToPhysAddr(params[3], &res);
196 *res = x->mErrorCode;
197 /* only clear the match results, since the regex object
198 may still be referenced later */
199 x->ClearMatch();
200
201 return -1;
202 }
203 else if (e == 0)
204 {
205 /* only clear the match results, since the regex object
206 may still be referenced later */
207 x->ClearMatch();
208
209 return 0;
210 }
211 else
212 {
213 return x->mMatchCount;
214 }
215}
216
217static cell_t GetRegexSubString(IPluginContext *pCtx, const cell_t *params)
218{

Callers

nothing calls this directly

Calls 4

MatchAllMethod · 0.80
ClearMatchMethod · 0.80
GetIdentityMethod · 0.45
ReadHandleMethod · 0.45

Tested by

no test coverage detected