diff --git a/src/grib_io.cc b/src/grib_io.cc index 760b7245d..ce8d2aa65 100644 --- a/src/grib_io.cc +++ b/src/grib_io.cc @@ -1008,7 +1008,7 @@ static int read_any_taf(reader* r) int err = 0; unsigned char* buffer = NULL; unsigned long magic = 0; - unsigned long start = 0x54414620; + unsigned long start = 0x54414620; // 4 chars: TAF plus a space unsigned char tmp[1000] = {0,}; /* Should be enough */ size_t message_size = 0; size_t already_read = 0; @@ -1020,10 +1020,10 @@ static int read_any_taf(reader* r) magic &= 0xffffffff; if (magic == start) { - tmp[i++] = 0x54; - tmp[i++] = 0x41; - tmp[i++] = 0x46; - tmp[i++] = 0x20; + tmp[i++] = 0x54; //T + tmp[i++] = 0x41; //A + tmp[i++] = 0x46; //F + tmp[i++] = 0x20; //space r->offset = r->tell(r->read_data) - 4; @@ -1056,7 +1056,7 @@ static int read_any_metar(reader* r) int err = 0; unsigned char* buffer = NULL; unsigned long magic = 0; - unsigned long start = 0x4d455441; + unsigned long start = 0x4d455441; // 4 chars: META unsigned char tmp[32] = {0,}; /* Should be enough */ size_t message_size = 0; size_t already_read = 0; @@ -1071,10 +1071,10 @@ static int read_any_metar(reader* r) if (r->read(r->read_data, &c, 1, &err) != 1 || err != 0) break; if (c == 'R') { - tmp[i++] = 0x4d; - tmp[i++] = 0x45; - tmp[i++] = 0x54; - tmp[i++] = 0x41; + tmp[i++] = 0x4d; // M + tmp[i++] = 0x45; // E + tmp[i++] = 0x54; // T + tmp[i++] = 0x41; // A tmp[i++] = 'R'; r->offset = r->tell(r->read_data) - 4; diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index dfa32c9dc..2e478eefc 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -238,6 +238,7 @@ if( HAVE_BUILD_TOOLS ) gts_count gts_compare wrap + taf pseudo_diag metar_ls metar_get diff --git a/tests/taf.sh b/tests/taf.sh new file mode 100755 index 000000000..adc758361 --- /dev/null +++ b/tests/taf.sh @@ -0,0 +1,35 @@ +#!/bin/sh +# (C) Copyright 2005- 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. +# + +# Tests for TAF (Terminal Aerodrome Forecast) + +. ./include.ctest.sh + +label="taf_test" +tempTaf=temp.$label.taf +tempOut=temp.$label.out +tempTxt=temp.$label.txt +tempRef=temp.$label.ref + +cat >$tempTaf<