summaryrefslogtreecommitdiffstats
path: root/src/build_log.cc
diff options
context:
space:
mode:
authorNico Weber <nicolasweber@gmx.de>2012-01-05 00:49:41 (GMT)
committerNico Weber <nicolasweber@gmx.de>2012-01-05 00:49:41 (GMT)
commit83a50c341e016c3c5cf74a95775ae50e4f12d2ae (patch)
treefc1437a6e3ce959ee122f4d8f3a496a0c4ca3752 /src/build_log.cc
parentd56c101948bd69fdc9e7541eb6ac38ebc0e6c8bf (diff)
downloadNinja-83a50c341e016c3c5cf74a95775ae50e4f12d2ae.zip
Ninja-83a50c341e016c3c5cf74a95775ae50e4f12d2ae.tar.gz
Ninja-83a50c341e016c3c5cf74a95775ae50e4f12d2ae.tar.bz2
Switch build log to use tabs as field separators, to support outputs with spaces.
Diffstat (limited to 'src/build_log.cc')
-rw-r--r--src/build_log.cc15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/build_log.cc b/src/build_log.cc
index e3e96e5..b4435ba 100644
--- a/src/build_log.cc
+++ b/src/build_log.cc
@@ -33,7 +33,7 @@
namespace {
const char kFileSignature[] = "# ninja log v%d\n";
-const int kCurrentVersion = 3;
+const int kCurrentVersion = 4;
} // namespace
@@ -123,8 +123,11 @@ bool BuildLog::Load(const string& path, string* err) {
if (sscanf(buf, kFileSignature, &log_version) > 0)
continue;
}
+
+ char field_separator = log_version >= 4 ? '\t' : ' ';
+
char* start = buf;
- char* end = strchr(start, ' ');
+ char* end = strchr(start, field_separator);
if (!end)
continue;
*end = 0;
@@ -141,7 +144,7 @@ bool BuildLog::Load(const string& path, string* err) {
start_time = atoi(start);
start = end + 1;
- char* end = strchr(start, ' ');
+ char* end = strchr(start, field_separator);
if (!end)
continue;
*end = 0;
@@ -151,7 +154,7 @@ bool BuildLog::Load(const string& path, string* err) {
if (log_version >= 3) {
// In v3 we log the restat mtime.
- char* end = strchr(start, ' ');
+ char* end = strchr(start, field_separator);
if (!end)
continue;
*end = 0;
@@ -159,7 +162,7 @@ bool BuildLog::Load(const string& path, string* err) {
start = end + 1;
}
- end = strchr(start, ' ');
+ end = strchr(start, field_separator);
if (!end)
continue;
string output = string(start, end - start);
@@ -212,7 +215,7 @@ BuildLog::LogEntry* BuildLog::LookupByOutput(const string& path) {
}
void BuildLog::WriteEntry(FILE* f, const LogEntry& entry) {
- fprintf(f, "%d %d %ld %s %s\n",
+ fprintf(f, "%d\t%d\t%ld\t%s\t%s\n",
entry.start_time, entry.end_time, (long) entry.restat_mtime,
entry.output.c_str(), entry.command.c_str());
}