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:
Lee Thomason
2021-02-05 17:39:18 -08:00
committed by GitHub
parent 4a0ee26aa4
commit 0c7e4c1167
2 changed files with 6 additions and 16 deletions

View File

@@ -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() );
}