Error checking + updates from htslib

3-way merge between changes in https://github.com/jkbonfield/htslib/tree/develop/htslib, changes applied by myself to add error checking and ks_str/ks_len functions, and some upstream updates in attractivechaos/klib that had appeared since the initial copy into htslib.

~James

Merged with attractivechaos/klib:
- add upstream kvsprintf and rework ksprintf
- add upstream printf attribute checks
- use our kputw (has MIN_INT bug fix)
- keep our extra functions (kputc_, kputsn_, kputl)

Added ks_str and ks_len functions for tidier manipulation of
internals.

Added error checking to all functions that allocate memory and could
potentially fail; ie return EOF or negative values as per stdio
equivalents.