Fix DRY violations in `console.c`.

Warning: The code here is untested and might not work. Also, it might not follow good C coding conventions.