printing: simplify code where two paths do exactly the same thing

AFAICT, StrPrinter separates into two cases here but both of them
do the same thing.  Simplify the code.
CodePrinter has very similar code so fix same thing there too.