avoid stricmp entirely, just use the lowerCase boilerplate found in many other places in the code

This commit is contained in:
bbbradsmith 2024-12-13 05:42:30 -05:00 committed by tildearrow
parent 251bec69a9
commit 65a6a55d3e

View file

@ -19,7 +19,6 @@
#include <stdio.h> #include <stdio.h>
#include <stdint.h> #include <stdint.h>
#include <string.h>
#include "pch.h" #include "pch.h"
#ifdef HAVE_SDL2 #ifdef HAVE_SDL2
#include "SDL_events.h" #include "SDL_events.h"
@ -921,13 +920,17 @@ int main(int argc, char** argv) {
e.setConsoleMode(true); e.setConsoleMode(true);
// select ROM target type // select ROM target type
DivROMExportOptions romTarget = DIV_ROM_ABSTRACT; DivROMExportOptions romTarget = DIV_ROM_ABSTRACT;
String lowerCase=romOutName;
for (char& i: lowerCase) {
if (i>='A' && i<='Z') i+='a'-'A';
}
for (int i=0; i<DIV_ROM_MAX; i++) { for (int i=0; i<DIV_ROM_MAX; i++) {
DivROMExportOptions opt = (DivROMExportOptions)i; DivROMExportOptions opt = (DivROMExportOptions)i;
if (e.isROMExportViable(opt)) { if (e.isROMExportViable(opt)) {
const DivROMExportDef* newDef=e.getROMExportDef((DivROMExportOptions)i); const DivROMExportDef* newDef=e.getROMExportDef((DivROMExportOptions)i);
if (newDef->fileExt && if (newDef->fileExt &&
romOutName.length()>=strlen(newDef->fileExt) && lowerCase.length()>=strlen(newDef->fileExt) &&
!stricmp(newDef->fileExt,romOutName.c_str()+(romOutName.length()-strlen(newDef->fileExt)))) { lowerCase.substr(lowerCase.length()-strlen(newDef->fileExt))==newDef->fileExt) {
romTarget = opt; romTarget = opt;
break; // extension matched, stop searching break; // extension matched, stop searching
} }