Skip to content

Commit

Permalink
Case insensitive extension testing
Browse files Browse the repository at this point in the history
  • Loading branch information
bbbbbr committed Jun 29, 2021
1 parent 1a2ea25 commit 984cd10
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions romusage.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
void static display_cdb_warning(void);
void static display_help(void);
int handle_args(int argc, char * argv[]);
static int matches_extension(char *, char *);
static bool matches_extension(char *, char *);
static void init(void);
void cleanup(void);

Expand Down Expand Up @@ -152,8 +152,16 @@ int handle_args(int argc, char * argv[]) {
}


static int matches_extension(char * filename, char * extension) {
return (strcmp(filename + (strlen(filename) - strlen(extension)), extension) == 0);
// Case insensitive
static bool matches_extension(char * filename, char * extension) {

if (strlen(filename) >= strlen(extension)) {
char * str_ext = filename + (strlen(filename) - strlen(extension));

return (strncasecmp(str_ext, extension, strlen(extension)) == 0);
}
else
return false;
}


Expand Down

0 comments on commit 984cd10

Please sign in to comment.