Adressing some natspec issues

This commit is contained in:
Lefteris Karapetsas 2014-12-18 16:27:17 +01:00
parent a6b0fba227
commit d97bdba471
2 changed files with 7 additions and 4 deletions

View File

@ -170,7 +170,7 @@ std::string::const_iterator InterfaceHandler::parseDocTagLine(std::string::const
bool _appending) bool _appending)
{ {
auto nlPos = std::find(_pos, _end, '\n'); auto nlPos = std::find(_pos, _end, '\n');
if (_appending && *_pos != ' ') if (_appending && _pos < _end && *_pos != ' ')
_tagString += " "; _tagString += " ";
std::copy(_pos, nlPos, back_inserter(_tagString)); std::copy(_pos, nlPos, back_inserter(_tagString));
m_lastTag = _tagType; m_lastTag = _tagType;
@ -204,7 +204,7 @@ std::string::const_iterator InterfaceHandler::appendDocTagParam(std::string::con
solAssert(!m_params.empty(), "Internal: Tried to append to empty parameter"); solAssert(!m_params.empty(), "Internal: Tried to append to empty parameter");
auto pair = m_params.back(); auto pair = m_params.back();
if (*_pos != ' ') if (_pos < _end && *_pos != ' ')
pair.second += " "; pair.second += " ";
auto nlPos = std::find(_pos, _end, '\n'); auto nlPos = std::find(_pos, _end, '\n');
std::copy(_pos, nlPos, back_inserter(pair.second)); std::copy(_pos, nlPos, back_inserter(pair.second));

View File

@ -328,6 +328,7 @@ Token::Value Scanner::scanMultiLineDocComment()
void Scanner::scanToken() void Scanner::scanToken()
{ {
int savedPosition;
m_nextToken.literal.clear(); m_nextToken.literal.clear();
m_nextSkippedComment.literal.clear(); m_nextSkippedComment.literal.clear();
Token::Value token; Token::Value token;
@ -428,6 +429,7 @@ void Scanner::scanToken()
break; break;
case '/': case '/':
// / // /* /= // / // /* /=
savedPosition = getSourcePos();
advance(); advance();
if (m_char == '/') if (m_char == '/')
{ {
@ -436,7 +438,7 @@ void Scanner::scanToken()
else if (m_char == '/') else if (m_char == '/')
{ {
Token::Value comment; Token::Value comment;
m_nextSkippedComment.location.start = getSourcePos(); m_nextSkippedComment.location.start = savedPosition;
comment = scanSingleLineDocComment(); comment = scanSingleLineDocComment();
m_nextSkippedComment.location.end = getSourcePos(); m_nextSkippedComment.location.end = getSourcePos();
m_nextSkippedComment.token = comment; m_nextSkippedComment.token = comment;
@ -447,12 +449,13 @@ void Scanner::scanToken()
} }
else if (m_char == '*') else if (m_char == '*')
{ {
// /** doxygent style natspec comment
if (!advance()) /* slash star comment before EOS */ if (!advance()) /* slash star comment before EOS */
token = Token::WHITESPACE; token = Token::WHITESPACE;
else if (m_char == '*') else if (m_char == '*')
{ {
Token::Value comment; Token::Value comment;
m_nextSkippedComment.location.start = getSourcePos(); m_nextSkippedComment.location.start = savedPosition;
comment = scanMultiLineDocComment(); comment = scanMultiLineDocComment();
m_nextSkippedComment.location.end = getSourcePos(); m_nextSkippedComment.location.end = getSourcePos();
m_nextSkippedComment.token = comment; m_nextSkippedComment.token = comment;