From 8dc6f8e82b7c2f798263837d15bd2ccbb61c2933 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sun, 17 May 2020 15:44:44 +0100 Subject: [PATCH] Allow empty rules files. --- pcbnew/drc/drc_rule_parser.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/pcbnew/drc/drc_rule_parser.cpp b/pcbnew/drc/drc_rule_parser.cpp index 7f722103a2..cb93b6c355 100644 --- a/pcbnew/drc/drc_rule_parser.cpp +++ b/pcbnew/drc/drc_rule_parser.cpp @@ -49,28 +49,28 @@ void DRC_RULES_PARSER::Parse( std::vector& aSelectors, std::vector& aRules ) { std::vector< std::pair > selectorRules; + bool haveVersion = false; - T token; - - NeedLEFT(); - - if( NextTok() != T_version ) - Expecting( "version" ); - - NeedNUMBER( "version" ); - m_requiredVersion = (int)strtol( CurText(), NULL, 10 ); - m_tooRecent = ( m_requiredVersion > DRC_RULE_FILE_VERSION ); - NeedRIGHT(); - - for( token = NextTok(); token != T_EOF; token = NextTok() ) + for( T token = NextTok(); token != T_EOF; token = NextTok() ) { if( token != T_LEFT ) Expecting( T_LEFT ); token = NextTok(); + if( !haveVersion && token != T_version ) + Expecting( "version" ); + switch( token ) { + case T_version: + NeedNUMBER( "version" ); + m_requiredVersion = (int)strtol( CurText(), NULL, 10 ); + m_tooRecent = ( m_requiredVersion > DRC_RULE_FILE_VERSION ); + haveVersion = true; + NeedRIGHT(); + break; + case T_selector: { wxString ruleName;