===========================================================================
| 8134 | |
| 8135 | //=========================================================================== |
| 8136 | int FindCommand ( LPCTSTR pName, CmdFuncPtr_t & pFunction_, int * iCommand_ ) |
| 8137 | { |
| 8138 | g_vPotentialCommands.clear(); |
| 8139 | |
| 8140 | int nFound = 0; |
| 8141 | int nLen = (int) strlen( pName ); |
| 8142 | int iCommand = 0; |
| 8143 | |
| 8144 | if (! nLen) |
| 8145 | return nFound; |
| 8146 | |
| 8147 | char sCommand[ CONSOLE_WIDTH ]; |
| 8148 | strcpy( sCommand, pName ); |
| 8149 | _strupr( sCommand ); |
| 8150 | |
| 8151 | while ((iCommand < NUM_COMMANDS_WITH_ALIASES)) // && (name[0] >= g_aCommands[iCommand].aName[0])) Command no longer in Alphabetical order |
| 8152 | { |
| 8153 | char *pCommandName = g_aCommands[iCommand].m_sName; |
| 8154 | // int iCmp = strcasecmp( sCommand, pCommandName, nLen ) |
| 8155 | if (! strncmp(sCommand, pCommandName, nLen)) |
| 8156 | { |
| 8157 | pFunction_ = g_aCommands[iCommand].pFunction; |
| 8158 | if (pFunction_) |
| 8159 | { |
| 8160 | g_iCommand = g_aCommands[iCommand].iCommand; |
| 8161 | |
| 8162 | // Don't push the same comamnd/alias if already on the list |
| 8163 | if (std::find( g_vPotentialCommands.begin(), g_vPotentialCommands.end(), g_iCommand) == g_vPotentialCommands.end()) |
| 8164 | { |
| 8165 | nFound++; |
| 8166 | g_vPotentialCommands.push_back( g_iCommand ); |
| 8167 | |
| 8168 | if (iCommand_) |
| 8169 | *iCommand_ = iCommand; |
| 8170 | // !strcmp |
| 8171 | if (!_stricmp(sCommand, pCommandName)) // exact match? |
| 8172 | { |
| 8173 | // if (iCommand_) |
| 8174 | // *iCommand_ = iCommand; |
| 8175 | |
| 8176 | nFound = 1; // Exact match takes precidence over fuzzy matches |
| 8177 | g_vPotentialCommands.clear(); |
| 8178 | break; |
| 8179 | } |
| 8180 | } |
| 8181 | } |
| 8182 | } |
| 8183 | iCommand++; |
| 8184 | } |
| 8185 | |
| 8186 | // if (nFound == 1) |
| 8187 | // { |
| 8188 | // |
| 8189 | // } |
| 8190 | |
| 8191 | return nFound; |
| 8192 | } |
| 8193 |
no test coverage detected