From c6b93677dd7ce0a3330a3cca358ea4e6d90f7b24 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Tue, 23 Jun 2015 13:34:03 +0100 Subject: [PATCH] ECC-134: Case-sensitivity of codetable keys --- src/grib_accessor_class_codetable.c | 4 ++-- tests/step.sh | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/grib_accessor_class_codetable.c b/src/grib_accessor_class_codetable.c index 660820c6d..80f3652ee 100644 --- a/src/grib_accessor_class_codetable.c +++ b/src/grib_accessor_class_codetable.c @@ -595,10 +595,10 @@ static int pack_string(grib_accessor* a, const char* buffer, size_t *len) typedef int (*cmpproc)(const char*, const char*); #ifndef ECCODES_ON_WINDOWS - cmpproc cmp = (a->flags | GRIB_ACCESSOR_FLAG_LOWERCASE) ? grib_strcasecmp : strcmp; + cmpproc cmp = (a->flags & GRIB_ACCESSOR_FLAG_LOWERCASE) ? grib_strcasecmp : strcmp; #else /* Microsoft Windows Visual Studio support */ - cmpproc cmp = (a->flags | GRIB_ACCESSOR_FLAG_LOWERCASE) ? stricmp : strcmp; + cmpproc cmp = (a->flags & GRIB_ACCESSOR_FLAG_LOWERCASE) ? stricmp : strcmp; #endif if(!self->table) self->table = load_table(self); diff --git a/tests/step.sh b/tests/step.sh index e16215650..f8df2e5f5 100755 --- a/tests/step.sh +++ b/tests/step.sh @@ -73,5 +73,27 @@ hourEnd=$1; dayEnd=$2 [ "$hourEnd" = "0" ] [ "$dayEnd" = "6" ] + +# ECC-134 case-sensitivity +grib1_sample=$ECCODES_SAMPLES_PATH/GRIB1.tmpl +grib2_sample=$ECCODES_SAMPLES_PATH/GRIB2.tmpl +temp=temp.step.$$.grib +# M is for Month (code 3) +${tools_dir}grib_set -s indicatorOfUnitOfTimeRange=M $grib1_sample $temp +unit=`${tools_dir}grib_get -p unitOfTimeRange $temp` +[ "$unit" = "3" ] +${tools_dir}grib_set -s indicatorOfUnitOfTimeRange=M $grib2_sample $temp +unit=`${tools_dir}grib_get -p indicatorOfUnitOfTimeRange $temp` +[ "$unit" = "3" ] + +# m is for Minute (code 0) +${tools_dir}grib_set -s indicatorOfUnitOfTimeRange=m $grib1_sample $temp +unit=`${tools_dir}grib_get -p unitOfTimeRange $temp` +[ "$unit" = "0" ] +${tools_dir}grib_set -s indicatorOfUnitOfTimeRange=m $grib2_sample $temp +unit=`${tools_dir}grib_get -p indicatorOfUnitOfTimeRange $temp` +[ "$unit" = "0" ] + +rm -f $temp rm -f $grib2File.p8tmp ${grib2File}.tmp | true rm -f x.grib