Similar to BSD's getline() but omits the \n terminator and manages the
memory as a kstring. Call with "(kgets_func *) fgets" to read from stdio,
or implement an fgets()-style function to read from other streams, e.g.,
a wrapper around gzgets() that reorders its parameters as per fgets().
- 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.