mirror of https://github.com/ecmwf/eccodes.git
ECC-1126: Clean up special cases
This commit is contained in:
parent
c1ea826af2
commit
fb0b601757
|
@ -89,28 +89,12 @@ int codes_bufr_keys_iterator_rewind(bufr_keys_iterator* ki)
|
|||
return GRIB_SUCCESS;
|
||||
}
|
||||
|
||||
static int is_ident_key(const bufr_keys_iterator* kiter)
|
||||
{
|
||||
if (kiter->current->sub_section)
|
||||
return 0;
|
||||
|
||||
if ((GRIB_ACCESSOR_FLAG_HIDDEN & kiter->current->flags) != 0 &&
|
||||
strcmp(kiter->current->name, "keyMore") == 0 &&
|
||||
grib_is_defined(kiter->handle, "ls.ident")) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int skip(bufr_keys_iterator* kiter)
|
||||
{
|
||||
if (kiter->current->sub_section)
|
||||
return 1;
|
||||
|
||||
if (kiter->current->flags & kiter->accessor_flags_skip) {
|
||||
/* The "ident" key deserves special treatment */
|
||||
if (is_ident_key(kiter))
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -232,15 +216,10 @@ char* codes_bufr_keys_iterator_get_name(const bufr_keys_iterator* ckiter)
|
|||
r = (int*)grib_trie_get(kiter->seen, kiter->current->name);
|
||||
sprintf(ret, "#%d#%s", *r, kiter->current->name);
|
||||
}
|
||||
else {
|
||||
if (is_ident_key(kiter)) {
|
||||
strcpy(ret, "ident");
|
||||
}
|
||||
else {
|
||||
strcpy(ret, kiter->current->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
kiter->key_name = ret; /*store reference to last key name*/
|
||||
|
||||
|
|
|
@ -276,13 +276,13 @@ static int bufr_decode_extra_rdb_keys(const void* message, long offset_section2,
|
|||
hdr->localLongitude = (lValue - 18000000.0) / 100000.0;
|
||||
|
||||
/* interpret keyMore as a string. Copy to a temporary */
|
||||
for (i = 0; i < 8; ++i) {
|
||||
for (i = 0; i < IDENT_LEN - 1; ++i) {
|
||||
temp[i] = *pKeyMore++;
|
||||
}
|
||||
temp[i] = '\0';
|
||||
pTemp = temp;
|
||||
lrtrim(&pTemp, 1, 1); /* Trim left and right */
|
||||
strncpy(hdr->ident, pTemp, 8);
|
||||
strncpy(hdr->ident, pTemp, IDENT_LEN - 1);
|
||||
}
|
||||
|
||||
return GRIB_SUCCESS;
|
||||
|
|
|
@ -694,18 +694,8 @@ static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment)
|
|||
if (size == 0)
|
||||
return;
|
||||
|
||||
if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) {
|
||||
/* ECC-356: Solution for the special local section key 'keyMore' and its alias 'ident' */
|
||||
int skip = 1;
|
||||
if ((a->flags & GRIB_ACCESSOR_FLAG_HIDDEN) != 0) {
|
||||
if (strcmp(a->name, "keyMore") == 0 && grib_is_defined(h, "ls.ident")) {
|
||||
skip = 0;
|
||||
acc_name = "ident";
|
||||
}
|
||||
}
|
||||
if (skip)
|
||||
if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0)
|
||||
return;
|
||||
}
|
||||
|
||||
value = (char*)grib_context_malloc_clear(c, size);
|
||||
if (!value) {
|
||||
|
|
|
@ -748,18 +748,8 @@ static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment)
|
|||
if (size == 0)
|
||||
return;
|
||||
|
||||
if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) {
|
||||
/* ECC-356: Solution for the special local section key 'keyMore' and its alias 'ident' */
|
||||
int skip = 1;
|
||||
if ((a->flags & GRIB_ACCESSOR_FLAG_HIDDEN) != 0) {
|
||||
if (strcmp(a->name, "keyMore") == 0 && grib_is_defined(h, "ls.ident")) {
|
||||
skip = 0;
|
||||
acc_name = "ident";
|
||||
}
|
||||
}
|
||||
if (skip)
|
||||
if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0)
|
||||
return;
|
||||
}
|
||||
|
||||
value = (char*)grib_context_malloc_clear(c, size);
|
||||
if (!value) {
|
||||
|
|
|
@ -691,18 +691,8 @@ static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment)
|
|||
if (size == 0)
|
||||
return;
|
||||
|
||||
if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) {
|
||||
/* ECC-356: Solution for the special local section key 'keyMore' and its alias 'ident' */
|
||||
int skip = 1;
|
||||
if ((a->flags & GRIB_ACCESSOR_FLAG_HIDDEN) != 0) {
|
||||
if (strcmp(acc_name, "keyMore") == 0 && grib_is_defined(h, "ls.ident")) {
|
||||
skip = 0;
|
||||
acc_name = "ident";
|
||||
}
|
||||
}
|
||||
if (skip)
|
||||
if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0)
|
||||
return;
|
||||
}
|
||||
|
||||
value = (char*)grib_context_malloc_clear(c, size);
|
||||
if (!value) {
|
||||
|
|
|
@ -642,9 +642,6 @@ static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment)
|
|||
grib_handle* h = grib_handle_of_accessor(a);
|
||||
const char* acc_name = a->name;
|
||||
|
||||
if ( strcmp(acc_name,"ident")==0 )
|
||||
puts("");
|
||||
|
||||
if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1319,16 +1319,6 @@ static int compare_all_dump_keys(grib_handle* handle1, grib_handle* handle2, gri
|
|||
|
||||
grib_keys_iterator_delete(iter);
|
||||
|
||||
/* ECC-356: Handling special case of 'ident' key */
|
||||
name = "ls.ident";
|
||||
if (!blacklisted("ident") && grib_is_defined(handle1, name) && grib_is_defined(handle2, name)) {
|
||||
if (compare_values(options, handle1, handle2, "ident", GRIB_TYPE_STRING)) {
|
||||
(*pErr)++;
|
||||
write_messages(handle1, handle2);
|
||||
ret = 1;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue