From 2352cef6d0757a4d31a18561a09a10f031388e12 Mon Sep 17 00:00:00 2001 From: William Wilgus Date: Sun, 13 Mar 2022 14:31:02 -0400 Subject: replace more strcmp if then trees with string_option() 1 Change-Id: Ic89bbb2ab41068d09c7bd9caa5ba7f38749b9084 --- apps/shortcuts.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'apps/shortcuts.c') diff --git a/apps/shortcuts.c b/apps/shortcuts.c index f573d6fe4e..754bd83b80 100644 --- a/apps/shortcuts.c +++ b/apps/shortcuts.c @@ -312,18 +312,22 @@ static int readline_cb(int n, char *buf, void *parameters) } else if (sc && settings_parseline(buf, &name, &value)) { - if (!strcmp(name, "type")) + static const char *nm_options[] = {"type", "name", "data", + "icon", "talkclip", NULL}; + int nm_op = string_option(name, nm_options, false); + + if (nm_op == 0) /*type*/ { int t = 0; for (t=0; ttype == SHORTCUT_UNDEFINED; t++) if (!strcmp(value, type_strings[t])) sc->type = t; } - else if (!strcmp(name, "name")) + else if (nm_op == 1) /*name*/ { strlcpy(sc->name, value, MAX_SHORTCUT_NAME); } - else if (!strcmp(name, "data")) + else if (nm_op == 2) /*data*/ { switch (sc->type) { @@ -357,7 +361,7 @@ static int readline_cb(int n, char *buf, void *parameters) break; } } - else if (!strcmp(name, "icon")) + else if (nm_op == 3) /*icon*/ { if (!strcmp(value, "filetype") && sc->type != SHORTCUT_SETTING && sc->u.path[0]) { @@ -368,7 +372,7 @@ static int readline_cb(int n, char *buf, void *parameters) sc->icon = atoi(value); } } - else if (!strcmp(name, "talkclip")) + else if (nm_op == 4) /*talkclip*/ { strlcpy(sc->talk_clip, value, MAX_PATH); } -- cgit v1.2.3