mirror of
https://github.com/bkaradzic/bx.git
synced 2026-02-17 20:52:37 +01:00
Fix text files with mixed EOL (#260)
* fix some end of line bugs * reduce change Co-authored-by: Lee Thomason <leet@unity3d.com>
This commit is contained in:
@@ -276,7 +276,7 @@ namespace bx
|
||||
|
||||
StringView line(curr.getPtr(), m_curr.getPtr() );
|
||||
|
||||
return strRTrim(line, "\n\r");
|
||||
return strRTrim(strRTrim(line, "\n"), "\r");
|
||||
}
|
||||
|
||||
return m_curr;
|
||||
|
||||
@@ -564,23 +564,13 @@ namespace bx
|
||||
{
|
||||
StringView str(_str);
|
||||
|
||||
for (; str.getPtr() != _str.getTerm()
|
||||
; str = StringView(min(str.getPtr() + kFindStep, _str.getTerm() ), min(str.getPtr() + kFindStep*2, _str.getTerm() ) )
|
||||
)
|
||||
// This method returns the character past the \n, so
|
||||
// there is no need to look for he \r which preceedes it.
|
||||
StringView eol = strFind(str, "\n");
|
||||
if (!eol.isEmpty() )
|
||||
{
|
||||
StringView eol = strFind(str, "\r\n");
|
||||
if (!eol.isEmpty() )
|
||||
{
|
||||
return StringView(eol.getTerm(), _str.getTerm() );
|
||||
}
|
||||
|
||||
eol = strFind(str, '\n');
|
||||
if (!eol.isEmpty() )
|
||||
{
|
||||
return StringView(eol.getTerm(), _str.getTerm() );
|
||||
}
|
||||
return StringView(eol.getTerm(), str.getTerm() );
|
||||
}
|
||||
|
||||
return StringView(_str.getTerm(), _str.getTerm() );
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user