summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDaniel Weber <daniel.weber.dev@gmail.com>2016-09-01 20:02:18 (GMT)
committerDaniel Weber <daniel.weber.dev@gmail.com>2016-09-01 20:02:18 (GMT)
commit1cc730ddc27df52d757be1c2e7aa96193f8ca9df (patch)
tree5c814701e730c28649056261902f5b5e383851a4 /src
parentc4b09e1e7e1d531a818601be33e0ec8ee18c3cde (diff)
downloadNinja-1cc730ddc27df52d757be1c2e7aa96193f8ca9df.zip
Ninja-1cc730ddc27df52d757be1c2e7aa96193f8ca9df.tar.gz
Ninja-1cc730ddc27df52d757be1c2e7aa96193f8ca9df.tar.bz2
Use uint64_t for slash_bits consistently
The VS compiler complained about possible loss of data (and it was right!)
Diffstat (limited to 'src')
-rw-r--r--src/graph.cc4
-rw-r--r--src/graph.h9
-rw-r--r--src/state.cc6
-rw-r--r--src/state.h7
-rw-r--r--src/util_test.cc3
5 files changed, 15 insertions, 14 deletions
diff --git a/src/graph.cc b/src/graph.cc
index a5bac1c..e7f63fe 100644
--- a/src/graph.cc
+++ b/src/graph.cc
@@ -348,10 +348,10 @@ bool Edge::use_console() const {
}
// static
-string Node::PathDecanonicalized(const string& path, unsigned int slash_bits) {
+string Node::PathDecanonicalized(const string& path, uint64_t slash_bits) {
string result = path;
#ifdef _WIN32
- unsigned int mask = 1;
+ uint64_t mask = 1;
for (char* c = &result[0]; (c = strchr(c, '/')) != NULL;) {
if (slash_bits & mask)
*c = '\\';
diff --git a/src/graph.h b/src/graph.h
index add8d3d..ec24293 100644
--- a/src/graph.h
+++ b/src/graph.h
@@ -21,6 +21,7 @@ using namespace std;
#include "eval_env.h"
#include "timestamp.h"
+#include "util.h"
struct BuildLog;
struct DiskInterface;
@@ -33,7 +34,7 @@ struct State;
/// Information about a node in the dependency graph: the file, whether
/// it's dirty, mtime, etc.
struct Node {
- Node(const string& path, unsigned int slash_bits)
+ Node(const string& path, uint64_t slash_bits)
: path_(path),
slash_bits_(slash_bits),
mtime_(-1),
@@ -76,8 +77,8 @@ struct Node {
return PathDecanonicalized(path_, slash_bits_);
}
static string PathDecanonicalized(const string& path,
- unsigned int slash_bits);
- unsigned int slash_bits() const { return slash_bits_; }
+ uint64_t slash_bits);
+ uint64_t slash_bits() const { return slash_bits_; }
TimeStamp mtime() const { return mtime_; }
@@ -101,7 +102,7 @@ private:
/// Set bits starting from lowest for backslashes that were normalized to
/// forward slashes by CanonicalizePath. See |PathDecanonicalized|.
- unsigned int slash_bits_;
+ uint64_t slash_bits_;
/// Possible values of mtime_:
/// -1: file hasn't been examined
diff --git a/src/state.cc b/src/state.cc
index d539e7b..6079229 100644
--- a/src/state.cc
+++ b/src/state.cc
@@ -100,7 +100,7 @@ Edge* State::AddEdge(const Rule* rule) {
return edge;
}
-Node* State::GetNode(StringPiece path, unsigned int slash_bits) {
+Node* State::GetNode(StringPiece path, uint64_t slash_bits) {
Node* node = LookupNode(path);
if (node)
return node;
@@ -134,13 +134,13 @@ Node* State::SpellcheckNode(const string& path) {
return result;
}
-void State::AddIn(Edge* edge, StringPiece path, unsigned int slash_bits) {
+void State::AddIn(Edge* edge, StringPiece path, uint64_t slash_bits) {
Node* node = GetNode(path, slash_bits);
edge->inputs_.push_back(node);
node->AddOutEdge(edge);
}
-bool State::AddOut(Edge* edge, StringPiece path, unsigned int slash_bits) {
+bool State::AddOut(Edge* edge, StringPiece path, uint64_t slash_bits) {
Node* node = GetNode(path, slash_bits);
if (node->in_edge())
return false;
diff --git a/src/state.h b/src/state.h
index b530207..54e9dc5 100644
--- a/src/state.h
+++ b/src/state.h
@@ -23,6 +23,7 @@ using namespace std;
#include "eval_env.h"
#include "hash_map.h"
+#include "util.h"
struct Edge;
struct Node;
@@ -93,12 +94,12 @@ struct State {
Edge* AddEdge(const Rule* rule);
- Node* GetNode(StringPiece path, unsigned int slash_bits);
+ Node* GetNode(StringPiece path, uint64_t slash_bits);
Node* LookupNode(StringPiece path) const;
Node* SpellcheckNode(const string& path);
- void AddIn(Edge* edge, StringPiece path, unsigned int slash_bits);
- bool AddOut(Edge* edge, StringPiece path, unsigned int slash_bits);
+ void AddIn(Edge* edge, StringPiece path, uint64_t slash_bits);
+ bool AddOut(Edge* edge, StringPiece path, uint64_t slash_bits);
bool AddDefault(StringPiece path, string* error);
/// Reset state. Keeps all nodes and edges, but restores them to the
diff --git a/src/util_test.cc b/src/util_test.cc
index 64c2bbf..45d0727 100644
--- a/src/util_test.cc
+++ b/src/util_test.cc
@@ -290,8 +290,7 @@ TEST(CanonicalizePath, TooManyComponents) {
"a\\.\\a\\.\\a\\.\\a\\.\\a\\.\\a\\.\\a\\.\\a\\.\\x.h";
EXPECT_TRUE(CanonicalizePath(&path, &slash_bits, &err));
- printf("%x\n",slash_bits);
- EXPECT_EQ(slash_bits, 0xffffffffLL);
+ EXPECT_EQ(slash_bits, 0xffffffff);
// 65 is not.
err = "";