Convert strings to UTF8 before they are input to PEGTL
Otherwise there are QA failures under non-UTF-8 locales.
This commit is contained in:
parent
962546436d
commit
0040ffc567
|
@ -180,7 +180,7 @@ void NETLIST_EXPORTER_SPICE::ReadDirectives()
|
||||||
else
|
else
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
tao::pegtl::string_input<> in( text.ToStdString() + "\n", "from_content" );
|
tao::pegtl::string_input<> in( ( text + "\n" ).ToUTF8(), "from_content" );
|
||||||
std::unique_ptr<tao::pegtl::parse_tree::node> root;
|
std::unique_ptr<tao::pegtl::parse_tree::node> root;
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -320,8 +320,8 @@ bool NETLIST_EXPORTER_SPICE::readModel( SCH_SYMBOL& aSymbol, SPICE_ITEM& aItem )
|
||||||
catch( const IO_ERROR& e )
|
catch( const IO_ERROR& e )
|
||||||
{
|
{
|
||||||
DisplayErrorMessage( nullptr,
|
DisplayErrorMessage( nullptr,
|
||||||
wxString::Format( "Failed reading %s simulation model.", aItem.refName ),
|
wxString::Format( _( "Failed reading %s simulation model." ), aItem.refName ),
|
||||||
e.What() );
|
e.What() );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -380,9 +380,9 @@ SIM_MODEL::SPICE_INFO SIM_MODEL::SpiceInfo( TYPE aType )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TYPE SIM_MODEL::ReadTypeFromSpiceCode( const std::string& aSpiceCode )
|
TYPE SIM_MODEL::ReadTypeFromSpiceCode( const wxString& aSpiceCode )
|
||||||
{
|
{
|
||||||
tao::pegtl::string_input<> in( aSpiceCode, "Spice_Code" );
|
tao::pegtl::string_input<> in( aSpiceCode.ToUTF8(), "Spice_Code" );
|
||||||
std::unique_ptr<tao::pegtl::parse_tree::node> root;
|
std::unique_ptr<tao::pegtl::parse_tree::node> root;
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -584,7 +584,7 @@ TYPE SIM_MODEL::InferTypeFromRefAndValue( const wxString& aRef, const wxString&
|
||||||
case TYPE::TLINE_Z0:
|
case TYPE::TLINE_Z0:
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
tao::pegtl::string_input<> in( aValue.ToStdString(), "Value" );
|
tao::pegtl::string_input<> in( aValue.ToUTF8(), "Value" );
|
||||||
auto root = tao::pegtl::parse_tree::parse<
|
auto root = tao::pegtl::parse_tree::parse<
|
||||||
SIM_MODEL_PARSER::fieldParamValuePairsGrammar,
|
SIM_MODEL_PARSER::fieldParamValuePairsGrammar,
|
||||||
SIM_MODEL_PARSER::fieldParamValuePairsSelector>
|
SIM_MODEL_PARSER::fieldParamValuePairsSelector>
|
||||||
|
@ -700,7 +700,7 @@ std::unique_ptr<SIM_MODEL> SIM_MODEL::Create( TYPE aType, unsigned aSymbolPinCou
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::unique_ptr<SIM_MODEL> SIM_MODEL::Create( const std::string& aSpiceCode )
|
std::unique_ptr<SIM_MODEL> SIM_MODEL::Create( const wxString& aSpiceCode )
|
||||||
{
|
{
|
||||||
std::unique_ptr<SIM_MODEL> model = create( ReadTypeFromSpiceCode( aSpiceCode ) );
|
std::unique_ptr<SIM_MODEL> model = create( ReadTypeFromSpiceCode( aSpiceCode ) );
|
||||||
|
|
||||||
|
@ -837,12 +837,12 @@ void SIM_MODEL::SetFieldValue( std::vector<T>& aFields, const wxString& aFieldNa
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SIM_MODEL::ReadSpiceCode( const std::string& aSpiceCode )
|
void SIM_MODEL::ReadSpiceCode( const wxString& aSpiceCode )
|
||||||
{
|
{
|
||||||
// The default behavior is to treat the Spice param=value pairs as the model parameters and
|
// The default behavior is to treat the Spice param=value pairs as the model parameters and
|
||||||
// values (for many models the correspondence is not exact, so this function is overridden).
|
// values (for many models the correspondence is not exact, so this function is overridden).
|
||||||
|
|
||||||
tao::pegtl::string_input<> in( aSpiceCode, "Spice_Code" );
|
tao::pegtl::string_input<> in( aSpiceCode.ToUTF8(), "Spice_Code" );
|
||||||
std::unique_ptr<tao::pegtl::parse_tree::node> root;
|
std::unique_ptr<tao::pegtl::parse_tree::node> root;
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -1260,7 +1260,7 @@ void SIM_MODEL::ParseParamsField( const wxString& aParamsField )
|
||||||
{
|
{
|
||||||
LOCALE_IO toggle;
|
LOCALE_IO toggle;
|
||||||
|
|
||||||
tao::pegtl::string_input<> in( aParamsField.ToStdString(), "Sim_Params" );
|
tao::pegtl::string_input<> in( aParamsField.ToUTF8(), "Sim_Params" );
|
||||||
std::unique_ptr<tao::pegtl::parse_tree::node> root;
|
std::unique_ptr<tao::pegtl::parse_tree::node> root;
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -1329,7 +1329,7 @@ void SIM_MODEL::ParsePinsField( unsigned aSymbolPinCount, const wxString& aPinsF
|
||||||
|
|
||||||
LOCALE_IO toggle;
|
LOCALE_IO toggle;
|
||||||
|
|
||||||
tao::pegtl::string_input<> in( aPinsField.ToStdString(), PINS_FIELD );
|
tao::pegtl::string_input<> in( aPinsField.ToUTF8(), PINS_FIELD );
|
||||||
std::unique_ptr<tao::pegtl::parse_tree::node> root;
|
std::unique_ptr<tao::pegtl::parse_tree::node> root;
|
||||||
|
|
||||||
try
|
try
|
||||||
|
|
|
@ -373,7 +373,7 @@ public:
|
||||||
DIR aDir = DIR_INOUT,
|
DIR aDir = DIR_INOUT,
|
||||||
SIM_VALUE::TYPE aType = SIM_VALUE::TYPE_FLOAT,
|
SIM_VALUE::TYPE aType = SIM_VALUE::TYPE_FLOAT,
|
||||||
FLAGS aFlags = {},
|
FLAGS aFlags = {},
|
||||||
std::string aUnit = "",
|
const wxString& aUnit = "",
|
||||||
CATEGORY aCategory = CATEGORY::PRINCIPAL,
|
CATEGORY aCategory = CATEGORY::PRINCIPAL,
|
||||||
const wxString& aDefaultValue = "",
|
const wxString& aDefaultValue = "",
|
||||||
const wxString& aDefaultValueOfOtherVariant = "",
|
const wxString& aDefaultValueOfOtherVariant = "",
|
||||||
|
@ -415,7 +415,7 @@ public:
|
||||||
static SPICE_INFO SpiceInfo( TYPE aType );
|
static SPICE_INFO SpiceInfo( TYPE aType );
|
||||||
|
|
||||||
|
|
||||||
static TYPE ReadTypeFromSpiceCode( const std::string& aSpiceCode );
|
static TYPE ReadTypeFromSpiceCode( const wxString& aSpiceCode );
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
static TYPE ReadTypeFromFields( const std::vector<T>& aFields );
|
static TYPE ReadTypeFromFields( const std::vector<T>& aFields );
|
||||||
|
@ -427,7 +427,7 @@ public:
|
||||||
|
|
||||||
|
|
||||||
static std::unique_ptr<SIM_MODEL> Create( TYPE aType, unsigned aSymbolPinCount = 0 );
|
static std::unique_ptr<SIM_MODEL> Create( TYPE aType, unsigned aSymbolPinCount = 0 );
|
||||||
static std::unique_ptr<SIM_MODEL> Create( const std::string& aSpiceCode );
|
static std::unique_ptr<SIM_MODEL> Create( const wxString& aSpiceCode );
|
||||||
static std::unique_ptr<SIM_MODEL> Create( const SIM_MODEL& aBaseModel,
|
static std::unique_ptr<SIM_MODEL> Create( const SIM_MODEL& aBaseModel,
|
||||||
unsigned aSymbolPinCount );
|
unsigned aSymbolPinCount );
|
||||||
|
|
||||||
|
@ -456,7 +456,7 @@ public:
|
||||||
SIM_MODEL& operator=(SIM_MODEL&& aOther ) = delete;
|
SIM_MODEL& operator=(SIM_MODEL&& aOther ) = delete;
|
||||||
|
|
||||||
|
|
||||||
virtual void ReadSpiceCode( const std::string& aSpiceCode );
|
virtual void ReadSpiceCode( const wxString& aSpiceCode );
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void ReadDataFields( unsigned aSymbolPinCount, const std::vector<T>* aFields );
|
void ReadDataFields( unsigned aSymbolPinCount, const std::vector<T>* aFields );
|
||||||
|
|
|
@ -127,7 +127,7 @@ void SIM_MODEL_IDEAL::inferredReadDataFields( unsigned aSymbolPinCount, const st
|
||||||
{
|
{
|
||||||
wxString value = GetFieldValue( aFields, VALUE_FIELD );
|
wxString value = GetFieldValue( aFields, VALUE_FIELD );
|
||||||
|
|
||||||
tao::pegtl::string_input<> in( value.ToStdString(), "Value" );
|
tao::pegtl::string_input<> in( value.ToUTF8(), "Value" );
|
||||||
auto root = tao::pegtl::parse_tree::parse<
|
auto root = tao::pegtl::parse_tree::parse<
|
||||||
SIM_MODEL_PARSER::fieldFloatValueGrammar,
|
SIM_MODEL_PARSER::fieldFloatValueGrammar,
|
||||||
SIM_MODEL_PARSER::fieldFloatValueSelector>
|
SIM_MODEL_PARSER::fieldFloatValueSelector>
|
||||||
|
|
|
@ -113,7 +113,7 @@ wxString SIM_MODEL_SOURCE::GenerateSpiceItemLine( const wxString& aRefName,
|
||||||
case TYPE::V_PWL:
|
case TYPE::V_PWL:
|
||||||
case TYPE::I_PWL:
|
case TYPE::I_PWL:
|
||||||
{
|
{
|
||||||
tao::pegtl::string_input<> in( GetParam( 0 ).value->ToString().ToStdString(),
|
tao::pegtl::string_input<> in( GetParam( 0 ).value->ToString().ToUTF8(),
|
||||||
"from_content" );
|
"from_content" );
|
||||||
std::unique_ptr<tao::pegtl::parse_tree::node> root;
|
std::unique_ptr<tao::pegtl::parse_tree::node> root;
|
||||||
|
|
||||||
|
|
|
@ -52,9 +52,9 @@ SIM_MODEL_SUBCKT::SIM_MODEL_SUBCKT( TYPE aType )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SIM_MODEL_SUBCKT::ReadSpiceCode( const std::string& aSpiceCode )
|
void SIM_MODEL_SUBCKT::ReadSpiceCode( const wxString& aSpiceCode )
|
||||||
{
|
{
|
||||||
tao::pegtl::string_input<> in( aSpiceCode, "from_content" );
|
tao::pegtl::string_input<> in( aSpiceCode.ToUTF8(), "from_content" );
|
||||||
std::unique_ptr<tao::pegtl::parse_tree::node> root;
|
std::unique_ptr<tao::pegtl::parse_tree::node> root;
|
||||||
|
|
||||||
try
|
try
|
||||||
|
|
|
@ -33,7 +33,7 @@ class SIM_MODEL_SUBCKT : public SIM_MODEL
|
||||||
public:
|
public:
|
||||||
SIM_MODEL_SUBCKT( TYPE aType );
|
SIM_MODEL_SUBCKT( TYPE aType );
|
||||||
|
|
||||||
void ReadSpiceCode( const std::string& aSpiceCode ) override;
|
void ReadSpiceCode( const wxString& aSpiceCode ) override;
|
||||||
wxString GenerateSpiceModelLine( const wxString& aModelName ) const override;
|
wxString GenerateSpiceModelLine( const wxString& aModelName ) const override;
|
||||||
std::vector<wxString> GenerateSpiceCurrentNames( const wxString& aRefName ) const override;
|
std::vector<wxString> GenerateSpiceCurrentNames( const wxString& aRefName ) const override;
|
||||||
void SetBaseModel( const SIM_MODEL& aBaseModel ) override;
|
void SetBaseModel( const SIM_MODEL& aBaseModel ) override;
|
||||||
|
|
|
@ -128,7 +128,7 @@ bool SIM_VALUE_GRAMMAR::IsValid( const wxString& aString,
|
||||||
SIM_VALUE::TYPE aValueType,
|
SIM_VALUE::TYPE aValueType,
|
||||||
NOTATION aNotation )
|
NOTATION aNotation )
|
||||||
{
|
{
|
||||||
tao::pegtl::string_input<> in( aString.ToStdString(), "from_content" );
|
tao::pegtl::string_input<> in( aString.ToUTF8(), "from_content" );
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -192,7 +192,7 @@ SIM_VALUE_PARSER::PARSE_RESULT SIM_VALUE_PARSER::Parse( const wxString& aString,
|
||||||
{
|
{
|
||||||
LOCALE_IO toggle;
|
LOCALE_IO toggle;
|
||||||
|
|
||||||
tao::pegtl::string_input<> in( aString.ToStdString(), "from_content" );
|
tao::pegtl::string_input<> in( aString.ToUTF8(), "from_content" );
|
||||||
std::unique_ptr<tao::pegtl::parse_tree::node> root;
|
std::unique_ptr<tao::pegtl::parse_tree::node> root;
|
||||||
PARSE_RESULT result;
|
PARSE_RESULT result;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue