mirror of https://github.com/ecmwf/eccodes.git
ECC-1359: codes_set_string: Fails for integer key even if string can be converted to an integer
This commit is contained in:
parent
cc09ad375d
commit
55a95d17bd
|
@ -294,8 +294,7 @@ static int compare(grib_accessor* a, grib_accessor* b)
|
||||||
|
|
||||||
static int pack_string(grib_accessor* a, const char* val, size_t* len)
|
static int pack_string(grib_accessor* a, const char* val, size_t* len)
|
||||||
{
|
{
|
||||||
char* theEnd = NULL;
|
long v = 0; /* The converted value */
|
||||||
long v = 0;
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
/* Requires more work e.g. filter */
|
/* Requires more work e.g. filter */
|
||||||
|
@ -304,9 +303,9 @@ static int pack_string(grib_accessor* a, const char* val, size_t* len)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
v = strtol(val, &theEnd, 10);
|
if (string_to_long(val, &v) != GRIB_SUCCESS) {
|
||||||
if (theEnd) {
|
grib_context_log(a->context, GRIB_LOG_ERROR,
|
||||||
grib_context_log(a->context, GRIB_LOG_ERROR, "trying to pack \"%s\" as long", val);
|
"Trying to pack \"%s\" as long. String cannot be converted to an integer", val);
|
||||||
return GRIB_WRONG_TYPE;
|
return GRIB_WRONG_TYPE;
|
||||||
}
|
}
|
||||||
return grib_pack_long(a, &v, len);
|
return grib_pack_long(a, &v, len);
|
||||||
|
|
|
@ -173,9 +173,16 @@ ${tools_dir}/bufr_set -s ident=' AB CD ' $f $fBufrTmp
|
||||||
result=`${tools_dir}/bufr_get -p ident $fBufrTmp`
|
result=`${tools_dir}/bufr_get -p ident $fBufrTmp`
|
||||||
[ "$result" = "AB CD" ]
|
[ "$result" = "AB CD" ]
|
||||||
|
|
||||||
|
|
||||||
# ${tools_dir}/bufr_compare $f $fBufrTmp
|
# ${tools_dir}/bufr_compare $f $fBufrTmp
|
||||||
|
|
||||||
|
|
||||||
|
#-----------------------------------------------------------
|
||||||
|
# ECC-1359: string that can be converted to an integer
|
||||||
|
# ----------------------------------------------------------
|
||||||
|
${tools_dir}/bufr_set -s messageLength:s=333 $ECCODES_SAMPLES_PATH/BUFR4_local.tmpl $fBufrTmp
|
||||||
|
result=`${tools_dir}/bufr_get -p messageLength $fBufrTmp`
|
||||||
|
[ "$result" = "333" ]
|
||||||
|
|
||||||
# Clean up
|
# Clean up
|
||||||
rm -f $fLog
|
rm -f $fLog
|
||||||
rm -f $fBufrTmp
|
rm -f $fBufrTmp
|
||||||
|
|
|
@ -110,5 +110,9 @@ max=`${tools_dir}/grib_get -F%.3f -p max $input`
|
||||||
max=`${tools_dir}/grib_get -F%.3f -p max $temp`
|
max=`${tools_dir}/grib_get -F%.3f -p max $temp`
|
||||||
[ "$max" = "13.097" ]
|
[ "$max" = "13.097" ]
|
||||||
|
|
||||||
|
# ECC-1359: string that can be converted to an integer
|
||||||
|
# ---------------------------------------------------
|
||||||
|
${tools_dir}/grib_set -s month:s=6 $ECCODES_SAMPLES_PATH/GRIB2.tmpl $temp
|
||||||
|
grib_check_key_equals $temp month 6
|
||||||
|
|
||||||
rm -f $outfile $temp
|
rm -f $outfile $temp
|
||||||
|
|
Loading…
Reference in New Issue