mirror of
https://github.com/avrdudes/avrdude.git
synced 2026-09-29 12:28:41 +03:00
Provide str_mcunames_signature()
This commit is contained in:
@@ -1514,6 +1514,7 @@ char *str_nexttok(char *buf, const char *delim, char **next);
|
||||
const char *str_ccfrq(double f, int n);
|
||||
int str_levenshtein(const char *str1, const char *str2, int swap, int subst, int add, int del);
|
||||
size_t str_weighted_damerau_levenshtein(const char *str1, const char *str2);
|
||||
int str_mcunames_signature(uint8_t *sigs, char *p, size_t n);
|
||||
|
||||
int led_set(const PROGRAMMER *pgm, int led);
|
||||
int led_clr(const PROGRAMMER *pgm, int led);
|
||||
|
||||
@@ -1301,3 +1301,24 @@ size_t str_weighted_damerau_levenshtein(const char *s1, const char *s2) {
|
||||
mmt_free(row2);
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
// Puts a comma-separated list of matching MCU names into array p with n chars space
|
||||
int str_mcunames_signature(uint8_t *sigs, char *p, size_t n) {
|
||||
int matching = 0;
|
||||
|
||||
for(size_t i=0; i < sizeof uP_table/sizeof *uP_table; i++) {
|
||||
if(0 == memcmp(sigs, uP_table[i].sigs, sizeof uP_table->sigs)) {
|
||||
if(matching && n > 2)
|
||||
strcpy(p, ", "), n -= 2, p += 2;
|
||||
size_t len = strlen(uP_table[i].name);
|
||||
if(n > len) {
|
||||
strcpy(p, uP_table[i].name);
|
||||
n -= len; p += len;
|
||||
}
|
||||
matching++;
|
||||
}
|
||||
}
|
||||
|
||||
return matching;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user