samtools/samtools — pull request #10 by kortschak (2012-06-14 01:05:31+00:00)
Title: Allow caller to determine response to parse errors in sam_read1

Hello samtools devs,

Please consider these changes to bam.h and bam_import.c.

Calling abort() in response to a parse error does not easily allow the
original caller to clean up. So the error condition should be passed
back to the original caller to allow them to decide how to handle the
situation.

I have defined additional error codes in bam.h that are consistent with
the currently used codes, and a bit flag to signal parse errors.
Checking for a parse error can be easily performed by checking the truth
of ~(retval|BAM_PARSE_ERROR), checking error codes is easily done by a
cast to char.

None of the error codes were previously defined in the documentation, so
while these changes may break some code, that code was relying on
unspecified behaviour. There is only one call to sam_read1 (via samread)
in the samtools suite, sam_view.main#L239-242 that should check the
parse error status and act appropriately if this change is accepted.

Note that in the flag parse block, the ret value from ks_getuntil is not
used. Is this intentional?