From 01ccab08b4ae8eafe9ee96990b5a2e69c1e394e6 Mon Sep 17 00:00:00 2001 From: MCUdude Date: Fri, 30 Sep 2022 20:16:16 +0200 Subject: [PATCH] Improve exitspecs (-E) parsing Use the same implementation as linuxspi does, instead of the one suggested in #733 --- src/flip2.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/flip2.c b/src/flip2.c index 5e74dfe9..40c4cc54 100644 --- a/src/flip2.c +++ b/src/flip2.c @@ -506,17 +506,26 @@ int flip2_paged_write(const PROGRAMMER *pgm, const AVRPART *part, const AVRMEM * return (result == 0) ? n_bytes : -1; } - // Parse the -E option flag -int flip2_parseexitspecs(PROGRAMMER* pgm, const char *s) { - if (strcmp(s, "reset") == 0) { - pgm->exit_reset = EXIT_RESET_ENABLED; - } else if (strcmp(s, "noreset") == 0) { - pgm->exit_reset = EXIT_RESET_DISABLED; - } else { +int flip2_parseexitspecs(PROGRAMMER *pgm, const char *sp) { + char *cp, *s, *str = cfg_strdup("flip2_parseextitspecs()", sp); + + s = str; + while ((cp = strtok(s, ","))) { + s = NULL; + if (!strcmp(cp, "reset")) { + pgm->exit_reset = EXIT_RESET_ENABLED; + continue; + } + if (!strcmp(cp, "noreset")) { + pgm->exit_reset = EXIT_RESET_DISABLED; + continue; + } + free(str); return -1; } + free(str); return 0; }