diff options
author | Evan Martin <martine@danga.com> | 2012-06-18 18:51:24 (GMT) |
---|---|---|
committer | Evan Martin <martine@danga.com> | 2012-06-18 18:51:24 (GMT) |
commit | 0d892830aa1b32b5a98fa7f81c588993a188af38 (patch) | |
tree | 776baba2be4d4913418c7474bfd93ed90e9a26f1 /src | |
parent | e152414a933a57b9ee22d51d8bebf3c2e2839f08 (diff) | |
parent | f9abd79c75dcf63fd88c718f19af09077e38d71f (diff) | |
download | Ninja-0d892830aa1b32b5a98fa7f81c588993a188af38.zip Ninja-0d892830aa1b32b5a98fa7f81c588993a188af38.tar.gz Ninja-0d892830aa1b32b5a98fa7f81c588993a188af38.tar.bz2 |
Merge pull request #338 from syntheticpp/empty-log-file
no recompacting needed when log file is empty
Diffstat (limited to 'src')
-rw-r--r-- | src/build_log.cc | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/build_log.cc b/src/build_log.cc index 97c3344..720b4b4 100644 --- a/src/build_log.cc +++ b/src/build_log.cc @@ -223,7 +223,8 @@ bool BuildLog::Load(const string& path, string* err) { int total_entry_count = 0; LineReader reader(file); - char* line_start, *line_end; + char* line_start = 0; + char* line_end = 0; while (reader.ReadLine(&line_start, &line_end)) { if (!log_version) { log_version = 1; // Assume by default. @@ -295,6 +296,11 @@ bool BuildLog::Load(const string& path, string* err) { entry->command_hash = LogEntry::HashCommand(StringPiece(start, end - start)); } + fclose(file); + + if (!line_start) { + return true; // file was empty + } // Decide whether it's time to rebuild the log: // - if we're upgrading versions @@ -308,8 +314,6 @@ bool BuildLog::Load(const string& path, string* err) { needs_recompaction_ = true; } - fclose(file); - return true; } |