src/main.cpp
/*
* find a proc by name.
* if the name is incomplete, it will attempt to search
* for matches - until exhausted, or a non-ambigious match
* is found.
*/
find a proc by name.
if the name is incomplete, it will attempt to search
for matches - until exhausted, or a non-ambigious match
is found.
find a proc by name . if the name is incomplete it will attempt to search for matches - until exhausted or a non - ambigious match is found .
static Bits::ProcInfo* findproc(const std::string& findme)
{
    size_t ambig;
    std::string tmp;
    std::string procname;
    Bits::ProcDefinition currentproc;
    Bits::ProcDefinition procdef;
    ambig = 0;
    for(auto pair: Bits::DefinedProcs::procs)
    {
        procname = pair.first;
        procdef = pair.second;
        if(procdef.longname == findme)
        {
            return procdef.funcinfo();
        }
        else if(findme.size() <= procname.size())
        {
            tmp = procname.substr(0, findme.size());
            if(tmp == findme)
            {
                currentproc = procdef;
                ambig++;
            }
        }
    }
    if(ambig > 1)
    {
        std::cerr << "command '" << findme << "' is too ambigious: matched " << ambig << " potential commands." << std::endl;
    }
    else
    {
        return currentproc.funcinfo();
    }
    return nullptr;
}
static Bits :: ProcInfo * findproc ( const std :: string & findme ) { size_t ambig ; std :: string tmp ; std :: string procname ; Bits :: ProcDefinition currentproc ; Bits :: ProcDefinition procdef ; ambig = 0 ; for ( auto pair : Bits :: DefinedProcs :: procs ) { procname = pair . first ; procdef = pair . second ; if ( procdef . longname == findme ) { return procdef . funcinfo ( ) ; } else if ( findme . size ( ) <= procname . size ( ) ) { tmp = procname . substr ( 0 , findme . size ( ) ) ; if ( tmp == findme ) { currentproc = procdef ; ambig ++ ; } } } if ( ambig > 1 ) { std :: cerr << " " << findme << " " << ambig << " " << std :: endl ; } else { return currentproc . funcinfo ( ) ; } return nullptr ; }
find a proc by name.
find a proc by name .
// straight-forward, if the full name matches, we're good to go. /*
        * "d"   ?= "[d]ump"
        * "du"  ?= "[du]mp"
        * "dum" ?= "[dum]p"
        * and so forth.
        * however:
        * "c" ?= "[c]ount" | "[c]ase"
        * which would be ambigious!
        *
        * so, count ambigious abbreviations, and if ambig is more than 1, then
        * the abbr is too ambigious to use.
        * otherwise, the last good proc is $currentproc.
        */