Hi Janne,
attached is a patch that makes the two attached testcases work. It applies on top of the charlen->size_t patch. In the formatted I/O stuff, I have mostly used ptrdiff_t to avoid having to deal with signed/unsigned issues, as the previous code was using int.
Did you regression-test? If yes, I'd say this patch is OK (all the changes look obvious enough). With this, your character length patch is also OK. We can then open individual PRs for the other issues. However, I'd ask you to wait for a day or so with committing so that other people also have a chance for a (final) look at this. Regards Thomas