Improve exitspecs (-E) parsing

Use the same implementation as linuxspi does, instead of the one suggested in #733
This commit is contained in:
MCUdude 2022-09-30 20:16:16 +02:00
parent 521155c1c2
commit 01ccab08b4
1 changed files with 16 additions and 7 deletions

View File

@ -506,17 +506,26 @@ int flip2_paged_write(const PROGRAMMER *pgm, const AVRPART *part, const AVRMEM *
return (result == 0) ? n_bytes : -1; return (result == 0) ? n_bytes : -1;
} }
// Parse the -E option flag // Parse the -E option flag
int flip2_parseexitspecs(PROGRAMMER* pgm, const char *s) { int flip2_parseexitspecs(PROGRAMMER *pgm, const char *sp) {
if (strcmp(s, "reset") == 0) { 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; pgm->exit_reset = EXIT_RESET_ENABLED;
} else if (strcmp(s, "noreset") == 0) { continue;
}
if (!strcmp(cp, "noreset")) {
pgm->exit_reset = EXIT_RESET_DISABLED; pgm->exit_reset = EXIT_RESET_DISABLED;
} else { continue;
}
free(str);
return -1; return -1;
} }
free(str);
return 0; return 0;
} }