Implement better #ifndef detection.
Fix tricky include guard bug.

If the #endif for an #ifndef is in another file, the previous
ifdef guard detector would misinterpret that as the end of
the guard.