Added decoding checks for the most obvious of sam parsing failures.

Note that some of these cannot be done in bam_read1 due to it not
having enough information (no header), so they are performed in
sam_read1 instead.

The auxiliary tag checking needs far more work, and is only done in
sam_format1 at present. I'm not sure there is a way to make this check
efficient given that a lot of calls to sam_read1 may not care to
decode auxiliary data. Instead we maybe just need to have a set of
standard auxiliary tag parsing functions and make sure all have
appropriate error handling.
Removed old comment from earlier code.
Merge branch 'develop' of https://github.com/samtools/htslib into develop
Further fixing of auxiliary tag decoding.
Added the ability to do samtools index on a CRAM file.

This is not the same as being able to use the index. This has not been
added yet.
Merge cram_index_build() from github.com/jkbonfield/htslib

bam_index_build() now also works with CRAM files, though this might not
be the ideal place to plug into index-building.  This merge also brings
various consistency checks mostly around reading aux fields.
l_qname is unsigned, so is always >= 0

Probably some of the other fields being checked here ought to be
unsigned too, but that's a story for another day...
Ensure r is clearly always initialised [minor]
Use $(LDFLAGS) & $(LDLIBS) when linking shared objects

Previously we weren't doing this on the basis that perhaps shared
libraries would want different flags from static test executables,
but we'll cross that bridge if we come to it.  Fixes #36.
Use the exact type in malloc(N * sizeof(TYPE*)) etc

This is clearer and silences warnings from clang's static analyzer.
Fix pointer arithmetic [minor]

Pointer arithmetic on void pointers is a GCC extension.
Add HTS_NORETURN and annotate fail() as such

This suppresses false positives from clang's static analyzer.  Eventually
HTS_NORETURN might migrate to the public API, if the API were to acquire
such things.

(The noreturn attribute has been supported since GCC 2.5 and clang 1.4,
but this approximation is close enough.)
Merge branch 'develop' into bcftools+calling
bcf_remove_alleles: Assume diploid genotypes if the ploidy cannot be determined, better to proceed than crash.
vcf: Update rlen on BCF output, this is important in BCF indexing, rlen is used as it is. Todo: also END should be checked with symbolic alleles
Merge branch 'bcftools+calling' into develop
Use the exact type in realloc(N * sizeof(TYPE*))

This one was missed previously as it's not used within htslib.
Merge branch 'develop' into bcftools+calling
sam: New bam_str2flag and bam_flag2str functions for a more user-friendly setting of bitmasks. Removed the default pileup filters (except for BAM_FUNMAP) and moved the filtering to BAM-reading callbacks
Merge branch 'bcftools+calling' into develop