MCPcopy Create free account
hub / github.com/assaultcube/AC / parseword

Function parseword

source/src/command.cpp:408–427  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

406}
407
408char *parseword(const char *&p, int arg, int *infix, int rec) // parse single argument, including expressions
409{
410 p += strspn(p, " \t");
411 if(p[0]=='/' && p[1]=='/') p += strcspn(p, "\n\r\0");
412 if(*p=='"') return parsequotes(p);
413 if(*p=='(' && !currentcontextisolated) return parseexp(p, ')', rec + 1); // on isolated contexts, only quotes are parsed
414 if(*p=='[' && !currentcontextisolated) return parseexp(p, ']', rec + 1);
415 int lvls = currentcontextisolated ? 0 : strspn(p, "$");
416 if(lvls && (p[lvls]=='(' || p[lvls]=='['))
417 { // $() $[]
418 p += lvls;
419 char *b = parseexp(p, *p == '(' ? ')' : ']', rec + 1);
420 if(b) return lookup(b, lvls);
421 }
422 const char *word = p;
423 p += strcspn(p, "; \t\n\r\0");
424 if(p-word==0) return NULL;
425 if(arg == 1 && *word == '=' && p - word == 1) *infix = *word;
426 return lvls ? lookup(newstring(word + lvls, p - word - lvls), lvls) : newstring(word, p-word);
427}
428
429char *conc(const char **w, int n, bool space)
430{

Callers 1

loopiFunction · 0.85

Calls 4

parsequotesFunction · 0.85
parseexpFunction · 0.85
lookupFunction · 0.85
newstringFunction · 0.85

Tested by

no test coverage detected