mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #8268 from a3d4/lineatposition-crlf
Avoided trailing '\r' in CharStream::lineAtPosition().
This commit is contained in:
commit
64bb0d55e0
@ -93,10 +93,13 @@ string CharStream::lineAtPosition(int _position) const
|
|||||||
lineStart = 0;
|
lineStart = 0;
|
||||||
else
|
else
|
||||||
lineStart++;
|
lineStart++;
|
||||||
return m_source.substr(
|
string line = m_source.substr(
|
||||||
lineStart,
|
lineStart,
|
||||||
min(m_source.find('\n', lineStart), m_source.size()) - lineStart
|
min(m_source.find('\n', lineStart), m_source.size()) - lineStart
|
||||||
);
|
);
|
||||||
|
if (!line.empty() && line.back() == '\r')
|
||||||
|
line.pop_back();
|
||||||
|
return line;
|
||||||
}
|
}
|
||||||
|
|
||||||
tuple<int, int> CharStream::translatePositionToLineColumn(int _position) const
|
tuple<int, int> CharStream::translatePositionToLineColumn(int _position) const
|
||||||
|
Loading…
Reference in New Issue
Block a user