Skip duplicate entries when listing concept values

This commit is contained in:
Shahram Najm 2015-07-31 11:33:03 +01:00
parent c1c41a7ae4
commit 9338360555
1 changed files with 7 additions and 2 deletions

View File

@ -402,13 +402,18 @@ int grib_concept_apply(grib_handle* h,grib_action* act,const char* name)
pCon = pCon->next;
}
count = i;
/* Printing out all values for concepts like paramId will be silly! */
/* Only print out all concepts if fewer than MAX_NUM_CONCEPT_VALUES.
* Printing out all values for concepts like paramId would be silly! */
if (count < MAX_NUM_CONCEPT_VALUES) {
fprintf(stderr, "Here are the possible values for concept %s:\n", act->name);
qsort(&all_concept_vals, count, sizeof(char*), cmpstringp);
for(i=0; i<count; ++i) {
if (all_concept_vals[i]) {
fprintf(stderr, "\t%s\n", all_concept_vals[i]);
int print_it = 1;
if (i>0 && strcmp(all_concept_vals[i], all_concept_vals[i-1]) == 0) {
print_it = 0; /* skip duplicate entries */
}
if (print_it) fprintf(stderr, "\t%s\n", all_concept_vals[i]);
}
}
}