summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvan Martin <martine@danga.com>2012-08-10 20:27:08 (GMT)
committerEvan Martin <martine@danga.com>2012-08-10 20:44:40 (GMT)
commitd58a10965610eb6b338e411ce816b810d76ab59e (patch)
treef5e9627cb0fcd0c2f62665388fa93f284ba318ee
parentd98ba72ef8adfb1698b8de197de6751c8b14d5c0 (diff)
downloadNinja-d58a10965610eb6b338e411ce816b810d76ab59e.zip
Ninja-d58a10965610eb6b338e411ce816b810d76ab59e.tar.gz
Ninja-d58a10965610eb6b338e411ce816b810d76ab59e.tar.bz2
windows: fix size_t<->int conversions in ninja.exe
-rw-r--r--src/build_log.cc12
-rw-r--r--src/depfile_parser.cc4
-rw-r--r--src/depfile_parser.in.cc4
-rw-r--r--src/graph.h8
-rw-r--r--src/hash_map.h2
-rw-r--r--src/lexer.cc2
-rw-r--r--src/lexer.in.cc2
-rw-r--r--src/string_piece.h4
-rw-r--r--src/util.cc6
-rw-r--r--src/util.h2
10 files changed, 23 insertions, 23 deletions
diff --git a/src/build_log.cc b/src/build_log.cc
index 1b27be3..e72a93e 100644
--- a/src/build_log.cc
+++ b/src/build_log.cc
@@ -49,7 +49,7 @@ const int kCurrentVersion = 5;
#define BIG_CONSTANT(x) (x##LLU)
#endif // !defined(_MSC_VER)
inline
-uint64_t MurmurHash64A(const void* key, int len) {
+uint64_t MurmurHash64A(const void* key, size_t len) {
static const uint64_t seed = 0xDECAFBADDECAFBADull;
const uint64_t m = BIG_CONSTANT(0xc6a4a7935bd1e995);
const int r = 47;
@@ -58,11 +58,11 @@ uint64_t MurmurHash64A(const void* key, int len) {
const uint64_t * end = data + (len/8);
while(data != end) {
uint64_t k = *data++;
- k *= m;
- k ^= k >> r;
- k *= m;
+ k *= m;
+ k ^= k >> r;
+ k *= m;
h ^= k;
- h *= m;
+ h *= m;
}
const unsigned char* data2 = (const unsigned char*)data;
switch(len & 7)
@@ -80,7 +80,7 @@ uint64_t MurmurHash64A(const void* key, int len) {
h *= m;
h ^= h >> r;
return h;
-}
+}
#undef BIG_CONSTANT
diff --git a/src/depfile_parser.cc b/src/depfile_parser.cc
index 03dad92..6887c91 100644
--- a/src/depfile_parser.cc
+++ b/src/depfile_parser.cc
@@ -149,7 +149,7 @@ yy4:
yy5:
{
// Got a span of plain text.
- int len = in - start;
+ int len = (int)(in - start);
// Need to shift it over if we're overwriting backslashes.
if (out < start)
memmove(out, start, len);
@@ -191,7 +191,7 @@ yy13:
}
- int len = out - filename;
+ int len = (int)(out - filename);
const bool is_target = parsing_targets;
if (len > 0 && filename[len - 1] == ':') {
len--; // Strip off trailing colon, if any.
diff --git a/src/depfile_parser.in.cc b/src/depfile_parser.in.cc
index 68b6a95..1d4a177 100644
--- a/src/depfile_parser.in.cc
+++ b/src/depfile_parser.in.cc
@@ -70,7 +70,7 @@ bool DepfileParser::Parse(string* content, string* err) {
}
[a-zA-Z0-9+,/_:.~()@=-]+ {
// Got a span of plain text.
- int len = in - start;
+ int len = (int)(in - start);
// Need to shift it over if we're overwriting backslashes.
if (out < start)
memmove(out, start, len);
@@ -88,7 +88,7 @@ bool DepfileParser::Parse(string* content, string* err) {
*/
}
- int len = out - filename;
+ int len = (int)(out - filename);
const bool is_target = parsing_targets;
if (len > 0 && filename[len - 1] == ':') {
len--; // Strip off trailing colon, if any.
diff --git a/src/graph.h b/src/graph.h
index 0ef4f3f..f487a22 100644
--- a/src/graph.h
+++ b/src/graph.h
@@ -199,12 +199,12 @@ struct Edge {
// pointer...)
int implicit_deps_;
int order_only_deps_;
- bool is_implicit(int index) {
- return index >= ((int)inputs_.size()) - order_only_deps_ - implicit_deps_ &&
+ bool is_implicit(size_t index) {
+ return index >= inputs_.size() - order_only_deps_ - implicit_deps_ &&
!is_order_only(index);
}
- bool is_order_only(int index) {
- return index >= ((int)inputs_.size()) - order_only_deps_;
+ bool is_order_only(size_t index) {
+ return index >= inputs_.size() - order_only_deps_;
}
bool is_phony() const;
diff --git a/src/hash_map.h b/src/hash_map.h
index 88c2681..9904fb8 100644
--- a/src/hash_map.h
+++ b/src/hash_map.h
@@ -19,7 +19,7 @@
// MurmurHash2, by Austin Appleby
static inline
-unsigned int MurmurHash2(const void* key, int len) {
+unsigned int MurmurHash2(const void* key, size_t len) {
static const unsigned int seed = 0xDECAFBAD;
const unsigned int m = 0x5bd1e995;
const int r = 24;
diff --git a/src/lexer.cc b/src/lexer.cc
index f4036d4..5d7d185 100644
--- a/src/lexer.cc
+++ b/src/lexer.cc
@@ -30,7 +30,7 @@ bool Lexer::Error(const string& message, string* err) {
context = p + 1;
}
}
- int col = last_token_ ? last_token_ - context : 0;
+ int col = last_token_ ? (int)(last_token_ - context) : 0;
char buf[1024];
snprintf(buf, sizeof(buf), "%s:%d: ", filename_.AsString().c_str(), line);
diff --git a/src/lexer.in.cc b/src/lexer.in.cc
index ec3ad6b..7ae9c61 100644
--- a/src/lexer.in.cc
+++ b/src/lexer.in.cc
@@ -29,7 +29,7 @@ bool Lexer::Error(const string& message, string* err) {
context = p + 1;
}
}
- int col = last_token_ ? last_token_ - context : 0;
+ int col = last_token_ ? (int)(last_token_ - context) : 0;
char buf[1024];
snprintf(buf, sizeof(buf), "%s:%d: ", filename_.AsString().c_str(), line);
diff --git a/src/string_piece.h b/src/string_piece.h
index ad1153e..b1bf105 100644
--- a/src/string_piece.h
+++ b/src/string_piece.h
@@ -31,7 +31,7 @@ struct StringPiece {
StringPiece(const string& str) : str_(str.data()), len_(str.size()) {}
StringPiece(const char* str) : str_(str), len_(strlen(str)) {}
- StringPiece(const char* str, int len) : str_(str), len_(len) {}
+ StringPiece(const char* str, size_t len) : str_(str), len_(len) {}
bool operator==(const StringPiece& other) const {
return len_ == other.len_ && memcmp(str_, other.str_, len_) == 0;
@@ -47,7 +47,7 @@ struct StringPiece {
}
const char* str_;
- int len_;
+ size_t len_;
};
#endif // NINJA_STRINGPIECE_H_
diff --git a/src/util.cc b/src/util.cc
index 7c2f895..90a1d45 100644
--- a/src/util.cc
+++ b/src/util.cc
@@ -81,7 +81,7 @@ void Error(const char* msg, ...) {
bool CanonicalizePath(string* path, string* err) {
METRIC_RECORD("canonicalize str");
- int len = path->size();
+ size_t len = path->size();
char* str = 0;
if (len > 0)
str = &(*path)[0];
@@ -91,7 +91,7 @@ bool CanonicalizePath(string* path, string* err) {
return true;
}
-bool CanonicalizePath(char* path, int* len, string* err) {
+bool CanonicalizePath(char* path, size_t* len, string* err) {
// WARNING: this function is performance-critical; please benchmark
// any changes you make to it.
METRIC_RECORD("canonicalize path");
@@ -323,7 +323,7 @@ string ElideMiddle(const string& str, size_t width) {
const int kMargin = 3; // Space for "...".
string result = str;
if (result.size() + kMargin > width) {
- int elide_size = (width - kMargin) / 2;
+ size_t elide_size = (width - kMargin) / 2;
result = result.substr(0, elide_size)
+ "..."
+ result.substr(result.size() - elide_size, elide_size);
diff --git a/src/util.h b/src/util.h
index bfcbfa8..ab1882b 100644
--- a/src/util.h
+++ b/src/util.h
@@ -39,7 +39,7 @@ void Error(const char* msg, ...);
/// Canonicalize a path like "foo/../bar.h" into just "bar.h".
bool CanonicalizePath(string* path, string* err);
-bool CanonicalizePath(char* path, int* len, string* err);
+bool CanonicalizePath(char* path, size_t* len, string* err);
/// Read a file to a string.
/// Returns -errno and fills in \a err on error.