Remove dead entries in .ninja_log and .ninja_deps while recompacting.

For .ninja_deps, remove objects that have no in-edges or whose in-edges
do not have a "deps" attribute. (This matches the behaviour of `-t
deps`).

BuildLog doesn't know about state, so let its recompact method take
delegate that decides is a path is life or not, and implement it in
NinjaMain.
Make tests compile (one fails atm).
Fix DepsLogTest.Recompact by making sure outputs aren't garbag-collected.
Add a test for collection of dead deps entries.
Add a test for collection of dead log entries.
Move duplicated code into a helper function.
Rename "IsDead" to "BuildLogUser".
Add a comment.
More robust escaping of $in, $out paths

In summary: don’t escape if the path doesn’t contain problematic characters, otherwise:
- Shell: enclose string in single quotes, escape embedded single quotes with the magic quote-backslash-quote sequence
- Win32: Escape double quotes by doubling the number of consecutive backslashes that precede them (if any) and adding one more. Finally, double the number of trailing backslashes, and enclose the whole thing in double quotes.
Merge pull request #690 from nickhutchinson/feature/escape-paths-properly

More robust escaping of $in, $out paths
Make BuildLogUser reference constant.
Merge pull request #697 from nico/gclogs

Remove old outputs from build log and deps log during recompaction.