Skip to content

Commit

Permalink
fixed line endings
Browse files Browse the repository at this point in the history
  • Loading branch information
ChriZ982 committed Jan 3, 2018
1 parent ba1cff8 commit bd19b06
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
8 changes: 8 additions & 0 deletions OpenHab2RulesGenerator/src/FileParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ std::vector<std::string> FileParser::read_file(const std::string &filename) {

std::vector<std::string> result;
for (std::wstring line; getline(file, line);) {
#ifdef PLATFORM_UNIX
result.emplace_back(StringUtils::erase_all(std::string(line.begin(), line.end()), {"\r"}));
#else
result.emplace_back(line.begin(), line.end());
#endif
}

return result;
Expand All @@ -28,7 +32,11 @@ void FileParser::write_file(const std::string &filename, const std::vector<std::
}

for (const auto &line : lines) {
#ifdef PLATFORM_UNIX
file << std::wstring(line.begin(), line.end()) << "\r\n";
#else
file << std::wstring(line.begin(), line.end()) << "\n";
#endif
}
}

Expand Down
4 changes: 4 additions & 0 deletions OpenHab2RulesGenerator/src/Main.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#if defined(unix) || defined(__unix__) || defined(__unix)
#define PLATFORM_UNIX
#endif

#include <iostream>
#include "FileParser.h"
#include "StringUtils.h"
Expand Down

0 comments on commit bd19b06

Please sign in to comment.