In order to handle end-of-buffer reads with partial line chunks,
merge those when cleaning text. Pass each line then to the offset
extracting function which gathers begin/end offsets of escape
sequences. Finally, for printing cleaned lines of text, omit all
color escape sequences as defined by their set of offsets (and
restore characters temporarily overwritten with terminating NUL).
Furthermore, add a basic string concatenation function and wrap
the free memory function to have it nullify pointers.
Steven Schubiger [Thu, 24 Jan 2013 22:59:34 +0000 (23:59 +0100)]
Wrap memory allocation functions
This covers currently calls to malloc(), realloc() and the custom
strdup() (which uses malloc, too). If allocation of memory fails
(i.e., NULL is returned from one of former two calls), a fatal
diagnostic is emitted (accompanied by source filename and line
number if compiled with DEBUG=1).