tools: change the list separator handling

Slightly easier to read than the "bool first" approach.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
master
Peter Hutterer 2021-04-22 12:42:00 +10:00 committed by Ran Benita
parent 68dddd4132
commit 693ffb073b
1 changed files with 14 additions and 13 deletions

View File

@ -156,7 +156,6 @@ main(int argc, char **argv)
struct rxkb_iso3166_code *iso3166; struct rxkb_iso3166_code *iso3166;
const char *variant = rxkb_layout_get_variant(l); const char *variant = rxkb_layout_get_variant(l);
const char *brief = rxkb_layout_get_brief(l); const char *brief = rxkb_layout_get_brief(l);
bool first;
printf("- %s%s%s%s:%s:%s", printf("- %s%s%s%s:%s:%s",
rxkb_layout_get_name(l), rxkb_layout_get_name(l),
@ -167,22 +166,24 @@ main(int argc, char **argv)
rxkb_layout_get_description(l)); rxkb_layout_get_description(l));
iso639 = rxkb_layout_get_iso639_first(l); iso639 = rxkb_layout_get_iso639_first(l);
if (iso639) if (iso639) {
const char *sep = "";
printf(":iso639-"); printf(":iso639-");
first = true; while (iso639) {
while (iso639) { printf("%s%s", sep, rxkb_iso639_code_get_code(iso639));
printf("%s%s", first ? "" : ",", rxkb_iso639_code_get_code(iso639)); iso639 = rxkb_iso639_code_next(iso639);
iso639 = rxkb_iso639_code_next(iso639); sep = ",";
first = false; }
} }
iso3166 = rxkb_layout_get_iso3166_first(l); iso3166 = rxkb_layout_get_iso3166_first(l);
if (iso3166) if (iso3166) {
const char *sep = "";
printf(":iso3166-"); printf(":iso3166-");
first = true; while (iso3166) {
while (iso3166) { printf("%s%s", sep, rxkb_iso3166_code_get_code(iso3166));
printf("%s%s", first ? "" : ",", rxkb_iso3166_code_get_code(iso3166)); iso3166 = rxkb_iso3166_code_next(iso3166);
iso3166 = rxkb_iso3166_code_next(iso3166); sep = ",";
first = false; }
} }
printf("\n"); printf("\n");