| 128 | } |
| 129 | |
| 130 | static int |
| 131 | argparse_long_opt(struct argparse *this_, const struct argparse_option *options) |
| 132 | { |
| 133 | for (; options->type != ARGPARSE_OPT_END; options++) { |
| 134 | const char *rest; |
| 135 | int opt_flags = 0; |
| 136 | if (!options->long_name) |
| 137 | continue; |
| 138 | |
| 139 | rest = prefix_skip(this_->argv[0] + 2, options->long_name); |
| 140 | if (!rest) { |
| 141 | // Negation allowed? |
| 142 | if (options->flags & OPT_NONEG) { |
| 143 | continue; |
| 144 | } |
| 145 | // Only boolean/bit allow negation. |
| 146 | if (options->type != ARGPARSE_OPT_BOOLEAN && options->type != ARGPARSE_OPT_BIT) { |
| 147 | continue; |
| 148 | } |
| 149 | |
| 150 | if (!prefix_cmp(this_->argv[0] + 2, "no-")) { |
| 151 | rest = prefix_skip(this_->argv[0] + 2 + 3, options->long_name); |
| 152 | if (!rest) |
| 153 | continue; |
| 154 | opt_flags |= OPT_UNSET; |
| 155 | } else { |
| 156 | continue; |
| 157 | } |
| 158 | } |
| 159 | if (*rest) { |
| 160 | if (*rest != '=') |
| 161 | continue; |
| 162 | this_->optvalue = rest + 1; |
| 163 | } |
| 164 | return argparse_getvalue(this_, options, opt_flags); |
| 165 | } |
| 166 | return -2; |
| 167 | } |
| 168 | |
| 169 | int |
| 170 | argparse_init(struct argparse *this_, struct argparse_option *options, |
no test coverage detected