MSYS: Add support for running under MSYS runtime environment

Detect MSYS as CYGWIN, with the required adaptations.
This commit is contained in:
Orgad Shaneh
2021-04-01 20:03:52 +03:00
committed by Brad King
parent b3ca4f9ad1
commit ddcd1469e8
60 changed files with 246 additions and 66 deletions
@@ -8,6 +8,14 @@
#include "libshared.h"
#include "libstatic.h"
static void rtrim(std::string& str, char byte)
{
const std::size_t size = str.size();
if (size && str[size - 1] == byte) {
str.resize(size - 1);
}
}
void compare(const char* refName, const char* testName)
{
std::ifstream ref;
@@ -31,16 +39,14 @@ void compare(const char* refName, const char* testName)
// Some very old Borland runtimes (C++ Builder 5 WITHOUT Update 1) add a
// trailing null to the string that we need to strip before testing for a
// trailing space.
if (refLine.size() && refLine[refLine.size() - 1] == 0) {
refLine.resize(refLine.size() - 1);
}
if (testLine.size() && testLine[testLine.size() - 1] == 0) {
testLine.resize(testLine.size() - 1);
}
rtrim(refLine, 0);
rtrim(testLine, 0);
// The reference files never have trailing spaces:
if (testLine.size() && testLine[testLine.size() - 1] == ' ') {
testLine.resize(testLine.size() - 1);
}
rtrim(testLine, ' ');
// Strip trailing CR. LF is not returned by getline, but CR is returned
// on some platforms.
rtrim(refLine, '\r');
rtrim(testLine, '\r');
if (refLine != testLine) {
std::cout << "Ref and test are not the same:\n Ref: \"" << refLine
<< "\"\n Test: \"" << testLine << "\"\n";