Do not mix loading file data with regex validation.

This commit is contained in:
Bartosz Taudul
2026-06-01 00:44:11 +02:00
parent 0b4128f76c
commit f113bbb212
3 changed files with 5 additions and 15 deletions

View File

@@ -243,10 +243,9 @@ void UserData::SaveAnnotations( const std::vector<std::unique_ptr<Annotation>>&
}
}
bool UserData::LoadSourceSubstitutions( std::vector<SourceRegex>& data )
void UserData::LoadSourceSubstitutions( std::vector<SourceRegex>& data )
{
assert( Valid() );
bool regexValid = true;
FILE* f = OpenFile( FileSourceSubstitutions, false );
if( f )
{
@@ -276,21 +275,11 @@ bool UserData::LoadSourceSubstitutions( std::vector<SourceRegex>& data )
fread( buf, 1, tsz, f );
target.assign( buf, tsz );
}
std::regex regex;
try
{
regex.assign( pattern );
}
catch( std::regex_error& )
{
regexValid = false;
}
data.emplace_back( SourceRegex { std::move( pattern ), std::move( target ), std::move( regex ) } );
data.emplace_back( SourceRegex { std::move( pattern ), std::move( target ) } );
}
}
fclose( f );
}
return regexValid;
}
void UserData::SaveSourceSubstitutions( const std::vector<SourceRegex>& data )

View File

@@ -33,7 +33,7 @@ public:
void LoadAnnotations( std::vector<std::unique_ptr<Annotation>>& data );
void SaveAnnotations( const std::vector<std::unique_ptr<Annotation>>& data );
bool LoadSourceSubstitutions( std::vector<SourceRegex>& data );
void LoadSourceSubstitutions( std::vector<SourceRegex>& data );
void SaveSourceSubstitutions( const std::vector<SourceRegex>& data );
const char* GetConfigLocation() const;

View File

@@ -104,7 +104,8 @@ View::View( void(*cbMainThread)(const std::function<void()>&, bool), FileRead& f
m_userData.StateShouldBePreserved();
m_userData.LoadState( m_vd );
m_userData.LoadAnnotations( m_annotations );
m_sourceRegexValid = m_userData.LoadSourceSubstitutions( m_sourceSubstitutions );
m_userData.LoadSourceSubstitutions( m_sourceSubstitutions );
ValidateSourceRegex();
if( m_worker.GetCallstackSampleCount() == 0 ) m_showAllSymbols = true;