Use fwrite in the msvc tool instead of printf

This allows wide characters from the compiler to propagate through the
msvc tool.  Similar to ad76e867f782e75e0fed620e7b39f7099af154a9.
Avoid indexing into an empty string.
Merge branch 'master' into wstr
Fix for incorrect number of total edges in the status message
Merge pull request #639 from rgeary1/StatusMessageFix

Fix for #638 incorrect number of total edges in the status message
Add a test for issue #638.
Merge pull request #640 from nico/edgetest

Add a test for issue #638.
Merge pull request #628 from rnk/wstr

Use fwrite in the msvc tool instead of printf
Minor style fixes, no behavior change.
Merge pull request #641 from nico/ocd2

Minor style fixes, no behavior change.
Suffix depslog path records with their expected index.

ninja assumes that numbering path entries in the deps log in order produces
valid dense integer ids.  If two ninja processes write to the same deps log
concurrently, this is not true.  Store the expected indices of path records
in the log and treat the rest of a deps log as invalid if the dense id of a
path record doesn't match the expected id stored in the log.  Addresses the
rest of issue #595.

This requires bumping the deps log file format version.  Do not migrate the
old version to the new, as the old format did not have this protection, and
might hence contain invalid data.  (Unlikely, but possible.)

Also store the record id as one's complement, to make them look less like
regular deps record values.  Since each record is written atomically this
isn't really necessary, but it makes the format somewhat more robust (and
easier to read in a hex editor).
Merge pull request #642 from nico/depslogidx

Suffix depslog path records with their expected index.
Deps log format v3

This fixes two bugs.

1.) It makes the record size field 4 byte instead of 2, and allows a max
    record size of 512kB. This fixes #605, ninja "only" supporting 8k
    dependencies per file -- 512kB have room for 128k dependencies. (If that's
    still not enough, the current design can support at least 4x that if the
    constant is tweaked.)

2.) It makes all records 4-byte aligned, which is probably needed to make the
    `reinterpret_cast<int*>(buf)` work on SPARC (cf issue #481), and it's
    generally nicer too. (Since there's already one reinterpret_cast, convert
    a memcpy() to reinterpret_cast in another branch too).
document an assumption
Merge pull request #644 from nico/v3

Deps log format v3
Fix an issue with more than 64k deps, spotted by maximuska.

Also add a test for this case, which would have spotted the issue too.
Merge pull request #645 from nico/maximfix

Fix an issue with more than 64k deps, spotted by maximuska.
Simplify implementation of GetProcessorCount().

The current implementation is unnecessarily complex, because:

- The BSD derived systems implement sysconf(_SC_NPROCESSORS_ONLN)
  in terms of sysctl({CTL_HW,HW_NCPU}).
- get_nprocs() is a GNU extension, and glibc implements
  sysconf(_SC_NPROCESSORS_ONLN) in terms of get_nprocs().
Merge pull request #647 from bmeurer/SimplifyGetProcessorCount

Simplify implementation of GetProcessorCount().
Check depslog timestamp in LoadDepsFromLog(), not in RecomputeOutputDirty().

RecomputeOutputDirty() is called from two places:

1. RecomputeDirty(), which calls LoadDeps().
2. CleanNode(), which always passes 0 for the deps mtime.

So this is no behavior change in either case.

deps_mtime was nonzero only in deps mode, and it got passed all over the
place.  This makes things simpler.