forked from OSchip/llvm-project
Fix an off by one in findEndOfWord, which could scan past the end of the string in a corner case.
llvm-svn: 90703
This commit is contained in:
parent
eddf1213e2
commit
a6cb9f21be
|
@ -497,12 +497,17 @@ static inline char findMatchingPunctuation(char c) {
|
|||
///
|
||||
/// \returns the index pointing one character past the end of the
|
||||
/// word.
|
||||
unsigned findEndOfWord(unsigned Start,
|
||||
const llvm::SmallVectorImpl<char> &Str,
|
||||
unsigned Length, unsigned Column,
|
||||
unsigned Columns) {
|
||||
static unsigned findEndOfWord(unsigned Start,
|
||||
const llvm::SmallVectorImpl<char> &Str,
|
||||
unsigned Length, unsigned Column,
|
||||
unsigned Columns) {
|
||||
assert(Start < Str.size() && "Invalid start position!");
|
||||
unsigned End = Start + 1;
|
||||
|
||||
// If we are already at the end of the string, take that as the word.
|
||||
if (End == Str.size())
|
||||
return End;
|
||||
|
||||
// Determine if the start of the string is actually opening
|
||||
// punctuation, e.g., a quote or parentheses.
|
||||
char EndPunct = findMatchingPunctuation(Str[Start]);
|
||||
|
|
Loading…
Reference in New Issue