From 1a46faaa6eb7c36df983f56a0c70da17ba6b6b3b Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sat, 13 Apr 2024 00:30:24 +0100 Subject: [PATCH] Check all ids of a programmer for exact match --- src/pgm.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/pgm.c b/src/pgm.c index 3196f8d3..03f7ee80 100644 --- a/src/pgm.c +++ b/src/pgm.c @@ -24,6 +24,7 @@ #include #include #include +#include #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) {