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

Function indexlist

source/src/command.cpp:1196–1221  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1194COMMANDF(looplisti, "sss", (char *list, char *varlist, char *body) { looplist(list, varlist, body, true); });
1195
1196char *indexlist(const char *s, int pos)
1197{
1198 DEBUGCODE(if(pos < 0) conoutf("\f3warning: negative index for 'at' \"%s\" %d", s, pos);) // FIXME remove this warning before release
1199 if(pos < 0) return newstring("");
1200 whitespaceskip;
1201 loopi(pos)
1202 {
1203 elementskip;
1204 whitespaceskip;
1205 if(!*s) break;
1206 }
1207 const char *e = s;
1208 char *res;
1209 elementskip;
1210 if(*e=='"')
1211 {
1212 e++;
1213 if(s[-1]=='"') --s;
1214 res = newstring(e, s - e);
1215#ifndef STANDALONE
1216 filterrichtext(res, res, s - e);
1217#endif
1218 }
1219 else res = newstring(e, s-e);
1220 return res;
1221}
1222COMMANDF(at, "si", (char *s, int *pos) { commandret = indexlist(s, *pos); });
1223
1224int listlen(const char *s)

Callers 1

command.cppFile · 0.85

Calls 3

newstringFunction · 0.85
filterrichtextFunction · 0.85
conoutfFunction · 0.70

Tested by

no test coverage detected