diff --git a/src/grib_query.c b/src/grib_query.c index c9e6ba9e3..0ba905a09 100644 --- a/src/grib_query.c +++ b/src/grib_query.c @@ -179,10 +179,10 @@ static char* get_condition(const char* name,codes_condition* condition) end=NULL; lval=strtol(str,&end,10); - if (*end != 0) { + if (*end != 0) { /* strtol failed. Not an integer */ double dval; dval=strtod(str,&end); - if (*end != 0) { + if (*end == 0) { /* strtod passed. So a double */ condition->rightType=GRIB_TYPE_DOUBLE; condition->rightDouble=dval; } diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 47004d201..e942207b1 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -94,6 +94,7 @@ list( APPEND tests_data_reqd bufr_ecc-433 bufr_ecc-750 bufr_ecc-875 + bufr_ecc-887 grib_ecc-490 grib_ecc-756 grib_ecc-873 diff --git a/tests/bufr_ecc-887.sh b/tests/bufr_ecc-887.sh new file mode 100755 index 000000000..dd4afef14 --- /dev/null +++ b/tests/bufr_ecc-887.sh @@ -0,0 +1,32 @@ +#!/bin/sh +# Copyright 2005-2018 ECMWF. +# +# This software is licensed under the terms of the Apache Licence Version 2.0 +# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. +# +# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by +# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. +# + +. ./include.sh + +# --------------------------------------------------------- +# This is the test for the JIRA issue ECC-887 +# BUFR: Search by condition does not work for floating point value +# --------------------------------------------------------- +label="bufr_ecc-887-test" +tempOut=temp.${label}.out +tempRules=temp.${label}.filter + + +input=${data_dir}/bufr/temp_101.bufr +cat > $tempRules <