MCPcopy Create free account
hub / github.com/BZFlag-Dev/bzflag / findKeyword

Method findKeyword

other_src/astyle/src/ASResource.cpp:527–547  ·  view source on GitHub ↗

check if a specific line position contains a keyword.

Source from the content-addressed store, hash-verified

525
526// check if a specific line position contains a keyword.
527bool ASBase::findKeyword(const string& line, int i, const string& keyword) const
528{
529 assert(isCharPotentialHeader(line, i));
530 // check the word
531 const size_t keywordLength = keyword.length();
532 const size_t wordEnd = i + keywordLength;
533 if (wordEnd > line.length())
534 return false;
535 if (line.compare(i, keywordLength, keyword) != 0)
536 return false;
537 // check that this is not part of a longer word
538 if (wordEnd == line.length())
539 return true;
540 if (isLegalNameChar(line[wordEnd]))
541 return false;
542 // is not a keyword if part of a definition
543 const char peekChar = peekNextChar(line, wordEnd - 1);
544 if (peekChar == ',' || peekChar == ')')
545 return false;
546 return true;
547}
548
549// get the current word on a line
550// index must point to the beginning of the word

Callers

nothing calls this directly

Calls 1

lengthMethod · 0.45

Tested by

no test coverage detected