MCPcopy Create free account
hub / github.com/AppleWin/AppleWin / FindParam

Function FindParam

source/Debugger/Debug.cpp:8071–8133  ·  view source on GitHub ↗

Note: Range is [iParamBegin,iParamEnd], not the usually (STL) expected [iParamBegin,iParamEnd) ===========================================================================

Source from the content-addressed store, hash-verified

8069// Note: Range is [iParamBegin,iParamEnd], not the usually (STL) expected [iParamBegin,iParamEnd)
8070//===========================================================================
8071int FindParam (LPCTSTR pLookupName, Match_e eMatch, int & iParam_, int iParamBegin, int iParamEnd, const bool bCaseSensitive /* false */ )
8072{
8073 int nFound = 0;
8074 int nLen = (int) strlen( pLookupName );
8075 int iParam = 0;
8076
8077 if (! nLen)
8078 return nFound;
8079
8080#if ALLOW_INPUT_LOWERCASE
8081 if (! bCaseSensitive) // HACK: Until We fixup all callers using MATCH_EXACT with MATCH_ANYCASE we need to preserve behavior of ALLOW_INPUT_LOWERCASE always being MATCH_FUZZY
8082 eMatch = MATCH_FUZZY;
8083#endif
8084
8085 if (eMatch == MATCH_EXACT)
8086 {
8087// while (iParam < NUM_PARAMS )
8088 for (iParam = iParamBegin; iParam <= iParamEnd; iParam++ )
8089 {
8090 char *pParamName = g_aParameters[iParam].m_sName;
8091 int eCompare = strcmp(pLookupName, pParamName);
8092 if (! eCompare) // exact match?
8093 {
8094 nFound++;
8095 iParam_ = g_aParameters[iParam].iCommand;
8096 break;
8097 }
8098 }
8099 }
8100 else
8101 if (eMatch == MATCH_FUZZY)
8102 {
8103#if ALLOW_INPUT_LOWERCASE
8104 char aLookup[ 256 ] = "";
8105 for ( int i = 0; i < nLen; i++ )
8106 {
8107 aLookup[ i ] = toupper( pLookupName[ i ] );
8108 }
8109#endif
8110 for (iParam = iParamBegin; iParam <= iParamEnd; iParam++ )
8111 {
8112 char *pParamName = g_aParameters[ iParam ].m_sName;
8113// _tcsnccmp
8114
8115#if ALLOW_INPUT_LOWERCASE
8116 if (! strncmp(aLookup, pParamName ,nLen))
8117#else
8118 if (! strncmp(pLookupName, pParamName ,nLen))
8119#endif
8120 {
8121 nFound++;
8122 iParam_ = g_aParameters[iParam].iCommand;
8123
8124 if (!_stricmp(pLookupName, pParamName)) // exact match?
8125 {
8126 nFound = 1; // Exact match takes precidence over fuzzy matches
8127 break;
8128 }

Callers 15

CmdHelpSpecificFunction · 0.85
CmdConfigFontFunction · 0.85
CmdConfigSetFontFunction · 0.85
_CmdSymbolsCommonFunction · 0.85
CmdProfileFunction · 0.85
CmdBreakInvalidFunction · 0.85
CmdBreakOnInterruptFunction · 0.85
CmdBreakpointAddRegFunction · 0.85
CmdBreakpointAddPCFunction · 0.85
CmdBreakpointChangeFunction · 0.85
CmdConfigColorMonoFunction · 0.85
CmdConfigDisasmFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected