Skip to content

Commit a65de92

Browse files
Erase \r in the string, read from the file and Fix Windows issues
1 parent d528264 commit a65de92

File tree

5 files changed

+10
-4
lines changed

5 files changed

+10
-4
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ integration_tests/b5/*
7272
integration_tests/b6/*
7373
integration_tests/_lpython-tmp-test-*
7474
inst/bin/*
75+
*.tmp
7576
*.tlog
7677
*.filters
7778
*.obj

examples/expr2.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
def main0():
22
x: i32
3-
x = 1
4-
3+
x = (2+3)*5
4+
print(x)
55
main0()
66

77
# Not implemented yet in LPython:

src/bin/lpython.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1008,9 +1008,11 @@ int link_executable(const std::vector<std::string> &infiles,
10081008
cmd += s + " ";
10091009
}
10101010
cmd += runtime_library_dir + "\\lpython_runtime_static.lib";
1011+
cmd += " > " + outfile + ".tmp";
10111012
int err = system(cmd.c_str());
10121013
if (err) {
1013-
std::cout << "The command '" + cmd + "' failed." << std::endl;
1014+
std::cout << "The command '" + cmd + "' failed."
1015+
" Error written in `" + outfile + ".tmp`" << std::endl;
10141016
return 10;
10151017
}
10161018
if (compiler_options.arg_o == "") {

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)