fix bug whereby spice params with capital letters no longer cause an error and data loss

Spice parameters were converted to lower-case before comparison. This is incorrect, as it
is legal and common for spice parameters to contain capital letters (e.g. potentiometers
typically use Rt and SET as their parameters).
Spice parameters are not case sensitive, so the correct behaviour is to instead do a
case-insensitive comparison on the parameter name.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/14793

(cherry picked from commit 0d235ac64b)
(cherry picked from commit 888a35bbde)
This commit is contained in:
Mark Visser 2023-05-21 17:50:35 -04:00 committed by Seth Hillbrand
parent dfd11b7596
commit f9c2f03a44
1 changed files with 2 additions and 4 deletions

View File

@ -44,7 +44,7 @@
#include <sim/sim_lib_mgr.h> #include <sim/sim_lib_mgr.h>
#include <sim/sim_library_kibis.h> #include <sim/sim_library_kibis.h>
#include <boost/algorithm/string/case_conv.hpp> #include <boost/algorithm/string.hpp>
#include <fmt/core.h> #include <fmt/core.h>
#include <pegtl/contrib/parse_tree.hpp> #include <pegtl/contrib/parse_tree.hpp>
@ -816,13 +816,11 @@ const SIM_MODEL::PARAM& SIM_MODEL::GetParam( unsigned aParamIndex ) const
int SIM_MODEL::doFindParam( const std::string& aParamName ) const int SIM_MODEL::doFindParam( const std::string& aParamName ) const
{ {
std::string lowerParamName = boost::to_lower_copy( aParamName );
std::vector<std::reference_wrapper<const PARAM>> params = GetParams(); std::vector<std::reference_wrapper<const PARAM>> params = GetParams();
for( int ii = 0; ii < (int) params.size(); ++ii ) for( int ii = 0; ii < (int) params.size(); ++ii )
{ {
if( params[ii].get().info.name == lowerParamName ) if( boost::iequals( params[ii].get().info.name, aParamName ) )
return ii; return ii;
} }