Commit cf3fdc22 cf3fdc2232fc6726a4a9e42eb8d7c830fe58a6ec by Sergey Poznyakoff

Fixed option recognition heuristics.

1 parent 53f9c27e
...@@ -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)
......