Be more flexible with user input; more multibyte safety.
This commit is contained in:
parent
dd7d8218f0
commit
f27661fa39
|
@ -230,42 +230,15 @@ LINE_READER* DSNLEXER::PopReader()
|
|||
}
|
||||
|
||||
|
||||
#if 0
|
||||
static int compare( const void* a1, const void* a2 )
|
||||
{
|
||||
const KEYWORD* k1 = (const KEYWORD*) a1;
|
||||
const KEYWORD* k2 = (const KEYWORD*) a2;
|
||||
|
||||
int ret = strcmp( k1->name, k2->name );
|
||||
return ret;
|
||||
}
|
||||
|
||||
int DSNLEXER::findToken( const std::string& tok )
|
||||
{
|
||||
KEYWORD search;
|
||||
|
||||
search.name = tok.c_str();
|
||||
|
||||
const KEYWORD* findings = (const KEYWORD*) bsearch( &search,
|
||||
keywords, keywordCount,
|
||||
sizeof(KEYWORD), compare );
|
||||
if( findings )
|
||||
return findings->token;
|
||||
else
|
||||
return DSN_SYMBOL; // not a keyword, some arbitrary symbol.
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
inline int DSNLEXER::findToken( const std::string& tok )
|
||||
{
|
||||
KEYWORD_MAP::const_iterator it = keyword_hash.find( tok.c_str() );
|
||||
|
||||
if( it != keyword_hash.end() )
|
||||
return it->second;
|
||||
|
||||
return DSN_SYMBOL; // not a keyword, some arbitrary symbol.
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
const char* DSNLEXER::Syntax( int aTok )
|
||||
|
|
|
@ -490,6 +490,15 @@ public:
|
|||
return curText;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function GetCurStrAsToken
|
||||
* Used to support "loose" matches (quoted tokens)
|
||||
*/
|
||||
int GetCurStrAsToken()
|
||||
{
|
||||
return findToken( curText );
|
||||
}
|
||||
|
||||
/**
|
||||
* Function FromUTF8
|
||||
* returns the current token text as a wxString, assuming that the input
|
||||
|
|
|
@ -56,23 +56,6 @@ namespace LIBEVAL
|
|||
|
||||
class COMPILER;
|
||||
|
||||
struct ERROR_STATUS
|
||||
{
|
||||
bool pendingError = false;
|
||||
|
||||
enum STAGE
|
||||
{
|
||||
CST_PARSE = 0,
|
||||
CST_CODEGEN,
|
||||
CST_RUNTIME
|
||||
};
|
||||
|
||||
STAGE stage;
|
||||
wxString message; // Note: use wxString for GUI-related strings
|
||||
int srcPos;
|
||||
};
|
||||
|
||||
|
||||
enum VAR_TYPE_T
|
||||
{
|
||||
VT_STRING = 1,
|
||||
|
|
|
@ -151,6 +151,9 @@ void DRC_RULES_PARSER::Parse( std::vector<DRC_RULE*>& aRules, REPORTER* aReporte
|
|||
}
|
||||
}
|
||||
|
||||
if( !m_reporter->HasMessage() )
|
||||
m_reporter->Report( _( "No errors found." ), RPT_SEVERITY_INFO );
|
||||
|
||||
m_reporter = nullptr;
|
||||
}
|
||||
|
||||
|
@ -184,6 +187,10 @@ DRC_RULE* DRC_RULES_PARSER::parseDRC_RULE()
|
|||
"'blind_via', 'pad', 'zone', 'text', 'graphic' or 'hole'." ) );
|
||||
break;
|
||||
}
|
||||
else if( (int) token == DSN_STRING )
|
||||
{
|
||||
token = GetCurStrAsToken();
|
||||
}
|
||||
|
||||
switch( token )
|
||||
{
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
|
||||
|
||||
#include <cstdio>
|
||||
#include <boost/algorithm/string/case_conv.hpp>
|
||||
#include <memory>
|
||||
#include <reporter.h>
|
||||
#include <class_board.h>
|
||||
|
@ -207,10 +206,7 @@ LIBEVAL::UCODE::FUNC_PTR PCB_EXPR_UCODE::CreateFuncCall( const char* aName )
|
|||
{
|
||||
PCB_EXPR_BUILTIN_FUNCTIONS& registry = PCB_EXPR_BUILTIN_FUNCTIONS::Instance();
|
||||
|
||||
std::string lowerName( aName );
|
||||
boost::to_lower( lowerName );
|
||||
|
||||
return registry.Get( lowerName );
|
||||
return registry.Get( wxString::FromUTF8( aName ).Lower() );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -121,7 +121,7 @@ public:
|
|||
return self;
|
||||
}
|
||||
|
||||
LIBEVAL::UCODE::FUNC_PTR Get( const std::string &name )
|
||||
LIBEVAL::UCODE::FUNC_PTR Get( const wxString &name )
|
||||
{
|
||||
return m_funcs[ name ];
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
std::map<std::string, LIBEVAL::UCODE::FUNC_PTR> m_funcs;
|
||||
std::map<wxString, LIBEVAL::UCODE::FUNC_PTR> m_funcs;
|
||||
|
||||
wxArrayString m_funcSigs;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue