1
0
mirror of https://github.com/mist-devel/mist-firmware.git synced 2026-01-13 15:17:43 +00:00

user_io: fix user_io_get_ext_idx for the nth time

...fix handling of short extensions when one extension is a prefix
of the next (like GB with GBC).
This commit is contained in:
Gyorgy Szombathelyi 2025-03-25 19:59:34 +01:00
parent 207b4570af
commit 4fa14f0fa2

View File

@ -2655,14 +2655,19 @@ char user_io_key_remap(char *s, char action, int tag) {
unsigned char user_io_ext_idx(const char *name, const char* ext) {
unsigned char idx = 0;
char ext3[4]; // extension truncated or extended to 3 chars
int len = strlen(ext);
int extlen;
const char *nameext = GetExtension(name);
if (!nameext) return 0;
extlen = strlen(nameext);
for (int i=0; i<3; i++) {
ext3[i] = i<extlen ? nameext[i] : ' ';
}
ext3[3] = 0;
while((len>3) && *ext) {
if(!_strnicmp(nameext,ext,extlen > 3 ? 3 : extlen)) return idx;
if(!_strnicmp(ext3,ext,3)) return idx;
if(strlen(ext)<=3) break;
idx++;
ext +=3;