Skip to content

Commit 0396bea

Browse files
Erase \r in the string read from the file
1 parent d528264 commit 0396bea

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/libasr/string_utils.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,9 @@ std::string read_file(const std::string &filename)
9999
std::vector<char> bytes(filesize);
100100
ifs.read(&bytes[0], filesize);
101101

102-
return std::string(&bytes[0], filesize);
102+
std::string s(&bytes[0], filesize);
103+
s.erase( std::remove(s.begin(), s.end(), '\r'), s.end() );
104+
return s;
103105
}
104106

105107
std::string parent_path(const std::string &path) {

src/libasr/utils2.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ bool read_file(const std::string &filename, std::string &text)
2525
ifs.read(&bytes[0], filesize);
2626

2727
text = std::string(&bytes[0], filesize);
28+
text.erase( std::remove(text.begin(), text.end(), '\r'), text.end() );
2829
return true;
2930
}
3031

0 commit comments

Comments
 (0)