* Compare long option for equality, adjusting for POPT_ARGFLAG_TOGGLE. * @param opt option * @param longName arg option * @param longNameLen arg option length * @return does long option match? */
| 299 | * @return does long option match? |
| 300 | */ |
| 301 | static int |
| 302 | longOptionStrcmp(const struct poptOption * opt, |
| 303 | const char * longName, size_t longNameLen) |
| 304 | { |
| 305 | const char * optLongName = opt->longName; |
| 306 | int rc; |
| 307 | |
| 308 | if (optLongName == NULL || longName == NULL) /* XXX can't heppen */ |
| 309 | return 0; |
| 310 | |
| 311 | if (F_ISSET(opt, TOGGLE)) { |
| 312 | if (optLongName[0] == 'n' && optLongName[1] == 'o') { |
| 313 | optLongName += sizeof("no") - 1; |
| 314 | if (optLongName[0] == '-') |
| 315 | optLongName++; |
| 316 | } |
| 317 | if (longName[0] == 'n' && longName[1] == 'o') { |
| 318 | longName += sizeof("no") - 1; |
| 319 | longNameLen -= sizeof("no") - 1; |
| 320 | if (longName[0] == '-') { |
| 321 | longName++; |
| 322 | longNameLen--; |
| 323 | } |
| 324 | } |
| 325 | } |
| 326 | rc = (int)(strlen(optLongName) == longNameLen); |
| 327 | if (rc) |
| 328 | rc = (int)(strncmp(optLongName, longName, longNameLen) == 0); |
| 329 | return rc; |
| 330 | } |
| 331 | |
| 332 | /* Only one of longName, shortName may be set at a time */ |
| 333 | static int handleAlias(poptContext con, |
no outgoing calls
no test coverage detected