Fixed bug with quoted strings in doxygen comments
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13321 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
b99221e8af
commit
34dc515a40
1 changed files with 23 additions and 4 deletions
|
|
@ -26,6 +26,7 @@ TokenList TokenList::tokenizeDoxygenComment(const std::string &doxygenComment, c
|
||||||
tokList.fileLine = fileLine;
|
tokList.fileLine = fileLine;
|
||||||
tokList.fileName = fileName;
|
tokList.fileName = fileName;
|
||||||
|
|
||||||
|
bool isPlainString = false;
|
||||||
string::size_type pos, lastPos = 0;
|
string::size_type pos, lastPos = 0;
|
||||||
string currentWord;
|
string currentWord;
|
||||||
while (true) {
|
while (true) {
|
||||||
|
|
@ -42,17 +43,35 @@ TokenList TokenList::tokenizeDoxygenComment(const std::string &doxygenComment, c
|
||||||
else if (currentWord[0] == '!' || currentWord[0] == '*' || currentWord[0] == '/') {
|
else if (currentWord[0] == '!' || currentWord[0] == '*' || currentWord[0] == '/') {
|
||||||
// check if it's one of the '!!!', '***', '///' of any length
|
// check if it's one of the '!!!', '***', '///' of any length
|
||||||
char c = currentWord[0];
|
char c = currentWord[0];
|
||||||
bool isPlainString = false;
|
isPlainString = false;
|
||||||
for (int i=0; i<currentWord.size(); i++)
|
for (int i=0; i<currentWord.size(); i++)
|
||||||
if (currentWord[i] != c) {
|
if (currentWord[i] != c) {
|
||||||
isPlainString = true;
|
isPlainString = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (isPlainString)
|
}
|
||||||
|
else
|
||||||
|
isPlainString = true;
|
||||||
|
|
||||||
|
if (isPlainString) {
|
||||||
|
// handle quoted words
|
||||||
|
string::size_type qPos = currentWord.find('"', 0);
|
||||||
|
if (qPos != string::npos) {
|
||||||
|
lastPos += qPos;
|
||||||
|
pos = doxygenComment.find_first_of("\"\n", lastPos + 1);
|
||||||
|
if (pos == string::npos)
|
||||||
|
pos = doxygenComment.size();
|
||||||
|
if (pos == doxygenComment.size() || doxygenComment[pos] != '"') {
|
||||||
|
// hack to print error message before the list is constructed
|
||||||
|
tokList.m_tokenListIter = tokList.m_tokenList.end();
|
||||||
|
tokList.printListError("Unterminated string");
|
||||||
|
}
|
||||||
|
// also strip quotes
|
||||||
|
currentWord = doxygenComment.substr(lastPos + 1, pos-lastPos-1);
|
||||||
|
}
|
||||||
|
if (currentWord.size())
|
||||||
tokList.m_tokenList.push_back(Token(PLAINSTRING, currentWord));
|
tokList.m_tokenList.push_back(Token(PLAINSTRING, currentWord));
|
||||||
}
|
}
|
||||||
else // it is a plain string
|
|
||||||
tokList.m_tokenList.push_back(Token(PLAINSTRING, currentWord));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lastPos = pos + 1;
|
lastPos = pos + 1;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue