--------------------------------------------------------------------------- ^FUNCTION: Options::match_opt - match an option ^SYNOPSIS: const char * match_opt(opt, int ignore_case) const ^PARAMETERS: char opt -- the option-character to match int ignore_case -- should we ignore character-case? ^DESCRIPTION: See if "opt" is found in "optvec" ^REQUIREMENTS: - optvec should be non-NULL and termin
| 690 | // end-for |
| 691 | // ^^------------------------------------------------------------------------- |
| 692 | const char *Options::match_opt(char opt, int ignore_case) const |
| 693 | { |
| 694 | if ((optvec == NULL) || (!*optvec)) |
| 695 | return NULLSTR; |
| 696 | |
| 697 | for (const char *const *optv = optvec; *optv; optv++) |
| 698 | { |
| 699 | OptionSpec optspec = *optv; |
| 700 | char optchar = optspec.OptChar(); |
| 701 | if (isNullOpt(optchar)) |
| 702 | continue; |
| 703 | if (opt == optchar) |
| 704 | { |
| 705 | return optspec; |
| 706 | } |
| 707 | else if (ignore_case && (TOLOWER(opt) == TOLOWER(optchar))) |
| 708 | { |
| 709 | return optspec; |
| 710 | } |
| 711 | } |
| 712 | |
| 713 | return NULLSTR; // not found |
| 714 | } |
| 715 | |
| 716 | // --------------------------------------------------------------------------- |
| 717 | // ^FUNCTION: Options::match_longopt - match a long-option |