MCPcopy Index your code
hub / github.com/assaultcube/AC / find

Function find

source/src/command.cpp:1233–1261  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1231COMMANDF(listlen, "s", (char *l) { intret(listlen(l)); });
1232
1233int find(char *s, const char *key)
1234{
1235 whitespaceskip;
1236 int len = strlen(key);
1237 for(int i = 0; *s; i++)
1238 {
1239 char *e = s;
1240 elementskip;
1241 char *a = s;
1242 if(*e == '"')
1243 {
1244 e++;
1245 if(s[-1] == '"') --s;
1246 if(s - e >= len)
1247 {
1248 *s = '\0';
1249#ifndef STANDALONE
1250 filterrichtext(e, e, s - e);
1251#endif
1252 if(int(strlen(e)) == len && !strncmp(e, key, len)) return i;
1253 *s = ' ';
1254 }
1255 }
1256 else if(s - e == len && !strncmp(e, key, s - e)) return i;
1257 s = a;
1258 whitespaceskip;
1259 }
1260 return -1;
1261}
1262COMMANDF(findlist, "ss", (char *s, char *key) { intret(find(s, key)); });
1263
1264#ifndef STANDALONE

Callers 1

command.cppFile · 0.85

Calls 1

filterrichtextFunction · 0.85

Tested by

no test coverage detected