Commit 211a7dac authored by Jonathan Jenkins's avatar Jonathan Jenkins

mapping: option to count only "first-found" lp entry

parent d4bd177d
...@@ -43,8 +43,10 @@ int codes_mapping_get_group_reps(const char* group_name); ...@@ -43,8 +43,10 @@ int codes_mapping_get_group_reps(const char* group_name);
* lp_type_name - name of LP type * lp_type_name - name of LP type
* annotation - optional annotation. If NULL, entry is considered * annotation - optional annotation. If NULL, entry is considered
* unannotated * unannotated
* ignore_annos - If non-zero, then count across all annotations (and * ignore_annos - If zero, then count in an annotation-specific manner.
* ignore whatever annotation parameter is passed in) * If 1, then count the "first-found" LP in the
* configuration, regardless of annotation.
* Otherwise, count across all annotations.
* *
* returns the number of LPs found (0 in the case of some combination of group, * returns the number of LPs found (0 in the case of some combination of group,
* lp_type_name, and annotation not being found) * lp_type_name, and annotation not being found)
......
...@@ -107,7 +107,7 @@ int codes_mapping_get_lp_count( ...@@ -107,7 +107,7 @@ int codes_mapping_get_lp_count(
// check - if group name is null, then disable ignore_repetitions (the // check - if group name is null, then disable ignore_repetitions (the
// former takes precedence) // former takes precedence)
if (group_name == NULL) if (group_name == NULL)
ignore_repetitions = 0; ignore_repetitions = 0;
for (int g = 0; g < lpconf.lpgroups_count; g++){ for (int g = 0; g < lpconf.lpgroups_count; g++){
const config_lpgroup_t *lpg = &lpconf.lpgroups[g]; const config_lpgroup_t *lpg = &lpconf.lpgroups[g];
...@@ -125,6 +125,8 @@ int codes_mapping_get_lp_count( ...@@ -125,6 +125,8 @@ int codes_mapping_get_lp_count(
lp_type_ct_total += lpt->count; lp_type_ct_total += lpt->count;
else else
lp_type_ct_total += lpt->count * lpg->repetitions; lp_type_ct_total += lpt->count * lpg->repetitions;
if (ignore_annos == 1)
break;
} }
} }
} }
......
...@@ -163,7 +163,7 @@ int main(int argc, char *argv[]) ...@@ -163,7 +163,7 @@ int main(int argc, char *argv[])
groups[g], lpnm); groups[g], lpnm);
} }
printf("TEST1 %2d %6s %s ignore annos\n", printf("TEST1 %2d %6s %s ignore annos\n",
codes_mapping_get_lp_count(groups[g], 0, lps[l], NULL, 1), codes_mapping_get_lp_count(groups[g], 0, lps[l], NULL, 2),
groups[g], lps[l]); groups[g], lps[l]);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment