Fix bad interaction between element limit and repeated values (BZ#24331).

Currently

  print -elements=3 -- "AAAAAA"

prints complete string, which is not what the user asked for.

Fix two buggy tests exposed by the fix, and add a new test.

Reviewed-by: Keith Seitz <keiths@redhat.com>
3 files changed