MCPcopy Create free account
hub / github.com/EmbeddedRPC/erpc / match_longopt

Method match_longopt

erpcgen/src/options.cpp:756–791  ·  view source on GitHub ↗

--------------------------------------------------------------------------- ^FUNCTION: Options::match_longopt - match a long-option ^SYNOPSIS: const char * Options::match_longopt(opt, len, ambiguous) ^PARAMETERS: char * opt -- the long-option to match int len -- the number of character of "opt" to match int & ambiguous -- set by this routine before returning. ^DESCRIPTION: Try to match "opt" ag

Source from the content-addressed store, hash-verified

754// if we had exactly 1 partial match return it, else return NULL
755// ^^-------------------------------------------------------------------------
756const char *Options::match_longopt(const char *opt, int len, int &ambiguous) const
757{
758 kwdmatch_t result;
759 const char *matched = NULLSTR;
760
761 ambiguous = 0;
762 if ((optvec == NULL) || (!*optvec))
763 return NULLSTR;
764
765 for (const char *const *optv = optvec; *optv; optv++)
766 {
767 OptionSpec optspec = *optv;
768 const char *longopt = optspec.LongOpt();
769 if (longopt == NULL)
770 continue;
771 result = kwdmatch(longopt, opt, len);
772 if (result == kwdmatch_t::EXACT_MATCH)
773 {
774 return optspec;
775 }
776 else if (result == kwdmatch_t::PARTIAL_MATCH)
777 {
778 if (matched)
779 {
780 ++ambiguous;
781 return NULLSTR;
782 }
783 else
784 {
785 matched = optspec;
786 }
787 }
788 } // for
789
790 return matched;
791}
792
793// ---------------------------------------------------------------------------
794// ^FUNCTION: Options::parse_opt - parse an option

Callers

nothing calls this directly

Calls 2

kwdmatchFunction · 0.85
LongOptMethod · 0.80

Tested by

no test coverage detected