Skip to content

Commit

Permalink
fix ambiguity in mods string parsing (Fixes #25)
Browse files Browse the repository at this point in the history
  • Loading branch information
Francesco149 committed Dec 10, 2017
1 parent e4df689 commit c563388
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
28 changes: 20 additions & 8 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1024,22 +1024,34 @@ int main(int argc, char* argv[])
/* this should be last because it uppercase's the string */
if (*a == '+')
{
for (p = a; *p; ++p) {
mods_str = a + 1;

for (p = mods_str; *p; ++p) {
*p = uppercase(*p);
}

# define m(mod) \
if (strstr(a + 1, #mod)) { mods |= MODS_##mod; } \
if (!strncmp(p, #mod, strlen(#mod))) { \
mods |= MODS_##mod; \
p += strlen(#mod); \
continue; \
} \

m(NF) m(EZ) m(HD) m(HR) m(DT) m(HT) m(NC) m(FL) m(SO)
m(NOMOD)
#undef m
for (p = mods_str; *p;)
{
m(NF) m(EZ) m(HD) m(HR) m(DT) m(HT) m(NC) m(FL)
m(SO) m(NOMOD)

if (strstr(a + 1, "TD")) {
mods |= MODS_TOUCH_DEVICE;
if (!strncmp(p, "TD", 2)) {
mods |= MODS_TOUCH_DEVICE;
p += 2;
continue;
}

++p;
}
#undef m

mods_str = a + 1;
continue;
}

Expand Down
2 changes: 1 addition & 1 deletion oppai.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@

#define OPPAI_VERSION_MAJOR 1
#define OPPAI_VERSION_MINOR 1
#define OPPAI_VERSION_PATCH 30
#define OPPAI_VERSION_PATCH 31

/* if your compiler doesn't have stdint, define this */
#ifdef OPPAI_NOSTDINT
Expand Down

0 comments on commit c563388

Please sign in to comment.