summaryrefslogtreecommitdiff
path: root/libs/ezsat
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2014-10-17 15:51:33 +0200
committerClifford Wolf <clifford@clifford.at>2014-10-17 16:04:59 +0200
commitb3a6f8f53019d1984d4e319db459b11da0663aa3 (patch)
tree4f370d208bb86cfe681a0a054783ec7869c6ccf1 /libs/ezsat
parent468ae923748a01b2763bafa3cf5fba883fe06479 (diff)
More win32 (mxe and vs) build fixes
Diffstat (limited to 'libs/ezsat')
-rw-r--r--libs/ezsat/ezsat.cc29
1 files changed, 18 insertions, 11 deletions
diff --git a/libs/ezsat/ezsat.cc b/libs/ezsat/ezsat.cc
index 54a6e9c7..657bed9d 100644
--- a/libs/ezsat/ezsat.cc
+++ b/libs/ezsat/ezsat.cc
@@ -22,12 +22,24 @@
#include <cmath>
#include <algorithm>
#include <cassert>
+#include <string>
#include <stdlib.h>
const int ezSAT::CONST_TRUE = 1;
const int ezSAT::CONST_FALSE = 2;
+static std::string my_int_to_string(int i)
+{
+#ifdef __MINGW32__
+ char buffer[64];
+ snprintf(buffer, 64, "%d", i);
+ return buffer;
+#else
+ return std::to_string(i);
+#endif
+}
+
ezSAT::ezSAT()
{
flag_keep_cnf = false;
@@ -183,7 +195,7 @@ int ezSAT::expression(OpId op, const std::vector<int> &args)
if (expressionsCache.count(myExpr) > 0) {
id = expressionsCache.at(myExpr);
} else {
- id = -(expressions.size() + 1);
+ id = -(int(expressions.size()) + 1);
expressionsCache[myExpr] = id;
expressions.push_back(myExpr);
}
@@ -490,13 +502,13 @@ int ezSAT::bound(int id) const
std::string ezSAT::cnfLiteralInfo(int idx) const
{
- for (size_t i = 0; i < cnfLiteralVariables.size(); i++) {
+ for (int i = 0; i < int(cnfLiteralVariables.size()); i++) {
if (cnfLiteralVariables[i] == idx)
return to_string(i+1);
if (cnfLiteralVariables[i] == -idx)
return "NOT " + to_string(i+1);
}
- for (size_t i = 0; i < cnfExpressionVariables.size(); i++) {
+ for (int i = 0; i < int(cnfExpressionVariables.size()); i++) {
if (cnfExpressionVariables[i] == idx)
return to_string(-i-1);
if (cnfExpressionVariables[i] == -idx)
@@ -670,9 +682,7 @@ std::vector<int> ezSAT::vec_var(std::string name, int numBits)
{
std::vector<int> vec;
for (int i = 0; i < numBits; i++) {
- char buf[64];
- snprintf(buf, 64, " [%d]", i);
- vec.push_back(VAR(name + buf));
+ vec.push_back(VAR(name + my_int_to_string(i)));
}
return vec;
}
@@ -1245,11 +1255,8 @@ static std::string expression2str(const std::pair<ezSAT::OpId, std::vector<int>>
#undef X
}
text += ":";
- for (auto it : data.second) {
- char buf[64];
- snprintf(buf, 64, " %d", it);
- text += buf;
- }
+ for (auto it : data.second)
+ text += " " + my_int_to_string(it);
return text;
}