Raise error if give @HD SO:coordinate to 'samtools fixmate'

The (minimal) documentation does tell you 'samtools fixmate' requires query name
sorted reads (in fact grouped by query name is enough), but doesn't actually raise
an error if given coordinate sorted reads (it just silently fails to fix them).

This change raises an explicit error is the @HD line contains SO:coordinate
Fix compilation with the Clang compiler.
Fix type mismatches between types in sizeof() in malloc/calloc/realloc calls. This generates a warning in the clang analyzer, designed to catch incorrectly sized memory allocations.

The allocation at bam_plcmd.c:208 is twice as big as it needs to be, and has been fixed.
Catch overflow in n_cigar and give an explicit error.

Due to the use of an unsigned 16bit integer, BAM
files can only hold reads with up to 65535 CIGAR
operators. SAM does not have this limit, but the
samtools implementation (reasonably) also has the
same 16bit limit.

Prior to this fix a very long CIGAR read would
give a confusing 'unmatched CIGAR operation'
warning and then abort with a core dump.
Free the outer struct last
Merge branch master of git://github.com/leecbaker/samtools

Some of the files in the original PR have moved to the bcftools repository,
and the remaining type mismatches of this kind have been fixed there.
Use floor(x+0.5) instead of C99's round()
Fixed GCC section so that read cycle column begins with 1 instead of 0.
Merge pull request #95 from wtsi-hgi/develop

Fixed GCC section of stats so that read cycle column begins with 1 instead of 0.
mpileup: Allow up to five alleles (N,A,C,G,T)
Rearrange (so tags can see main_depth()) [minor]
Remove incorrect parameter check

The q parameter is an m*m matrix, and is allocated by the caller and
m & q are passed in accordingly.  It appears that this check may have been
intended to be "if (m > qmax)" but we have no independent idea of the size
of q, so there's no way to validate m against it.

Values in q are computed from aux.bsum[k]/etc where 0 <= k < m, so m is
also limited by the size of bsum[], namely 16.  However meaningful indices
for bsum/etc mostly are 0...4 (i.e., A,C,G,T,N) and in practice (currently)
m is either 4 or 5 (with q sized accordingly).  So checking "if (m > 16)"
would be somewhat pointless.
New "flags" command plus moved filtering from htslib/pileup to BAM reading callbacks
On behalf of Peter Chines, test that filter mask replaces (not just adds to) default mask
mpileup: Disabled CDF version of MWU annotations and made it optional at compile time
Merge branch 'develop' into calling
Merge branch 'calling' into develop
plot-bamstats: Skip generation of empty GCD graphs
Adds tests for usage message for samtools and all subcommands

Parses usage output into sections and looks for usage, version, and commands sections
using regexes.

Dispatches a further usage test for each subcommand reported by `samtools`

Verifies that subcommand usage lines mention `samtools subcommand` where subcommand
is the name of the subcommand (this test is not run if the regex 'not.*implemented'
is found anywhere in the subcommand output -- it seems reasonable enough that not
yet implemented subcommands would not have usage messages)

N.B. this currently fails on 4 subcommands - these need fixing and these
tests should tell us when they are fixed.
Modifies test.pl so that it exits with non-zero status if any tests fail.