Porting Simon's fix to support %i in printf