Fix infinite loop in hh --color.

Summary: My previous algorithm assumed an invariant that did not actually
hold. I've made that invariant hold, in addition to describing it explicitly
in a comment.

Reviewed By: @jwatzman

Differential Revision: D1654746
Fix hphpd crash when printing systemlib classes

Summary: fixes facebook/hhvm#4075

Reviewed By: @paulbiss

Differential Revision: D1642223