Skip to content

Commit

Permalink
avoid stricmp entirely, just use the lowerCase boilerplate found in m…
Browse files Browse the repository at this point in the history
…any other places in the code
  • Loading branch information
bbbradsmith authored and tildearrow committed Dec 19, 2024
1 parent 251bec6 commit 65a6a55
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include "pch.h"
#ifdef HAVE_SDL2
#include "SDL_events.h"
Expand Down Expand Up @@ -921,13 +920,17 @@ int main(int argc, char** argv) {
e.setConsoleMode(true);
// select ROM target type
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++) {
DivROMExportOptions opt = (DivROMExportOptions)i;
if (e.isROMExportViable(opt)) {
const DivROMExportDef* newDef=e.getROMExportDef((DivROMExportOptions)i);
if (newDef->fileExt &&
romOutName.length()>=strlen(newDef->fileExt) &&
!stricmp(newDef->fileExt,romOutName.c_str()+(romOutName.length()-strlen(newDef->fileExt)))) {
lowerCase.length()>=strlen(newDef->fileExt) &&
lowerCase.substr(lowerCase.length()-strlen(newDef->fileExt))==newDef->fileExt) {
romTarget = opt;
break; // extension matched, stop searching
}
Expand Down

0 comments on commit 65a6a55

Please sign in to comment.