Fixed option recognition heuristics.
Showing
1 changed file
with
8 additions
and
7 deletions
... | @@ -53,13 +53,14 @@ mh_getopt (int argc, char **argv, struct mh_option *mh_opt) | ... | @@ -53,13 +53,14 @@ mh_getopt (int argc, char **argv, struct mh_option *mh_opt) |
53 | optlen = strlen (mh_optptr+1); | 53 | optlen = strlen (mh_optptr+1); |
54 | for (p = mh_opt; p->opt; p++) | 54 | for (p = mh_opt; p->opt; p++) |
55 | { | 55 | { |
56 | if (p->match_len <= optlen | 56 | if ((p->match_len <= optlen |
57 | && strlen (p->opt) >= optlen | 57 | && memcmp (mh_optptr+1, p->opt, optlen) == 0) |
58 | && (memcmp (mh_optptr+1, p->opt, optlen) == 0 | 58 | || (p->flags == MH_OPT_BOOL |
59 | || (p->flags == MH_OPT_BOOL | 59 | && optlen > 2 |
60 | && optlen > 2 | 60 | && memcmp (mh_optptr+1, "no", 2) == 0 |
61 | && memcmp (mh_optptr+3, p->opt, optlen-2) == 0))) | 61 | && strlen (p->opt) >= optlen-2 |
62 | break; | 62 | && memcmp (mh_optptr+3, p->opt, optlen-2) == 0)) |
63 | break; | ||
63 | } | 64 | } |
64 | 65 | ||
65 | if (p->opt) | 66 | if (p->opt) | ... | ... |
-
Please register or sign in to post a comment