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