@@ -1605,7 +1605,7 @@ static int vector_logic_and(filter_t *filter, bcf1_t *line, token_t *rtok, token
1605
1605
{ \
1606
1606
if ( missing_logic[nmiss] ) { rtok->pass_site = 1; i = atok->nvalues; break; } \
1607
1607
} \
1608
- else if ( atok->values[i] CMP_OP btok->values[j] ) { rtok->pass_site = 1; i = atok->nvalues; break; } \
1608
+ else if ( (float) atok->values[i] CMP_OP (float) btok->values[j] ) { rtok->pass_site = 1; i = atok->nvalues; break; } \
1609
1609
} \
1610
1610
} \
1611
1611
} \
@@ -1665,7 +1665,7 @@ static int vector_logic_and(filter_t *filter, bcf1_t *line, token_t *rtok, token
1665
1665
{ \
1666
1666
if ( missing_logic [nmiss ] ) { rtok -> pass_samples [i ] = 1 ; rtok -> pass_site = 1 ; j = xtok -> nval1 ; break ; } \
1667
1667
} \
1668
- else if ( xptr [j ] CMP_OP yptr [k ] ) { rtok -> pass_samples [i ] = 1 ; rtok -> pass_site = 1 ; j = xtok -> nval1 ; break ; } \
1668
+ else if ( ( float ) xptr [j ] CMP_OP ( float ) yptr [k ] ) { rtok -> pass_samples [i ] = 1 ; rtok -> pass_site = 1 ; j = xtok -> nval1 ; break ; } \
1669
1669
} \
1670
1670
} \
1671
1671
} \
@@ -2284,13 +2284,14 @@ static int filters_init1(filter_t *filter, char *str, int len, token_t *tok)
2284
2284
// is it a value? Here we parse as integer/float separately and use strtof
2285
2285
// rather than strtod, because the more accurate double representation
2286
2286
// would invalidate floating point comparisons like QUAL=59.2, obtained via
2287
- // htslib/vcf parser
2287
+ // htslib/vcf parser.
2288
+ // Update: use strtod() and force floats only in comparisons
2288
2289
char * end ;
2289
2290
tok -> threshold = strtol (tmp .s , & end , 10 ); // integer?
2290
2291
if ( end - tmp .s != strlen (tmp .s ) )
2291
2292
{
2292
2293
errno = 0 ;
2293
- tok -> threshold = strtof (tmp .s , & end ); // float?
2294
+ tok -> threshold = strtod (tmp .s , & end ); // float?
2294
2295
if ( errno != 0 || end != tmp .s + len ) error ("[%s:%d %s] Error: the tag \"%s\" is not defined in the VCF header\n" , __FILE__ ,__LINE__ ,__FUNCTION__ ,tmp .s );
2295
2296
}
2296
2297
tok -> is_constant = 1 ;
0 commit comments