Check all ids of a programmer for exact match

This commit is contained in:
Stefan Rueger
2024-04-13 00:30:24 +01:00
parent c53a3ed866
commit 1a46faaa6e

View File

@@ -24,6 +24,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "avrdude.h"
#include "libavrdude.h"
@@ -327,21 +328,25 @@ PROGRAMMER *locate_programmer_starts_set(const LISTID programmers, const char *p
matchp = NULL;
for(LNODEID ln1=lfirst(programmers); ln1; ln1=lnext(ln1)) {
pgm = ldata(ln1);
if(is_programmer(pgm) && (pgm->prog_modes & pmode))
if(is_programmer(pgm) && (pgm->prog_modes & pmode)) {
int thispgmmatch = 0;
for(LNODEID ln2=lfirst(pgm->id); ln2; ln2=lnext(ln2)) {
const char *id = (const char *) ldata(ln2);
if(p1 == tolower((unsigned char) *id) && !strncasecmp(id, pgid, l)) { // Partial initial match
matchp = pgm;
matchid = id;
matches++;
if(!thispgmmatch) { // Only count match once for a programmer
thispgmmatch++;
matchp = pgm;
matchid = id;
matches++;
}
if(id[l] == 0) { // Exact match; return straight away
matches = 1;
goto done;
}
break;
}
}
}
}
done:
if(matches == 1) {