Skip to content

Commit

Permalink
Improve exitspecs (-E) parsing
Browse files Browse the repository at this point in the history
Use the same implementation as linuxspi does, instead of the one suggested in avrdudes#733
  • Loading branch information
MCUdude committed Sep 30, 2022
1 parent 521155c commit 01ccab0
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions src/flip2.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 01ccab0

Please sign in to comment.