Skip to content

Commit 6fe5f4c

Browse files
committed
Fix importsym with Unix-style newlines
1 parent 72d306c commit 6fe5f4c

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

Commands/CDirectiveFile.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -591,12 +591,11 @@ CDirectiveSymImport::CDirectiveSymImport(const fs::path& fileName)
591591
{
592592
// End line at comment (starting with ;)
593593
// \x1A included here as well since No$gba .sym file ends with it
594-
size_t lineEnd = line.find_first_of(";\r\x1A");
594+
size_t lineEnd = line.length();
595+
lineEnd = std::min(line.find_first_of(";\r\x1A"),lineEnd);
595596
if (lineEnd != std::string::npos && lineEnd > 0)
596597
{
597-
lineEnd = line.find_last_not_of(" \t",lineEnd-1);
598-
if (lineEnd != std::string::npos)
599-
lineEnd += 1;
598+
lineEnd = std::max(line.find_last_not_of(" \t",lineEnd-1)+1,(size_t)0);
600599
}
601600

602601
// Skip empty line

Tests/Core/SymFileImport/input.sym

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
45544554 ValidLabelWithTabs
66
67766776 ValidLabelWithSpacesAndTabs
77
89988998 ValidLabelWithComment ; No$gba does allow this, if there is whitespace before the ;
8-
8+
99
11223344 @StaticLabel
1010
55667788 @StaticLabel
1111
99AABBCC @@LocalLabel

0 commit comments

Comments
 (0)