diff --git a/bitmap2component/bitmap2cmp_gui.cpp b/bitmap2component/bitmap2cmp_gui.cpp index 5f570035cd..a63053e9ab 100644 --- a/bitmap2component/bitmap2cmp_gui.cpp +++ b/bitmap2component/bitmap2cmp_gui.cpp @@ -220,7 +220,7 @@ void BM2CMP_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg ) { EDA_BASE_FRAME::LoadSettings( aCfg ); - auto cfg = static_cast( aCfg ); + BITMAP2CMP_SETTINGS* cfg = static_cast( aCfg ); m_BitmapFileName = cfg->m_BitmapFileName; m_ConvertedFileName = cfg->m_ConvertedFileName; @@ -264,7 +264,7 @@ void BM2CMP_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg ) { EDA_BASE_FRAME::SaveSettings( aCfg ); - auto cfg = static_cast( aCfg ); + BITMAP2CMP_SETTINGS* cfg = static_cast( aCfg ); cfg->m_BitmapFileName = m_BitmapFileName; cfg->m_ConvertedFileName = m_ConvertedFileName; @@ -406,8 +406,8 @@ bool BM2CMP_FRAME::OpenProjectFiles( const std::vector& aFileSet, int m_outputSizeY.SetOriginalSizePixels( h ); // Update display to keep aspect ratio - auto fakeEvent = wxCommandEvent(); - OnSizeChangeX( fakeEvent ); + wxCommandEvent dummy; + OnSizeChangeX( dummy ); updateImageInfo(); @@ -589,11 +589,11 @@ void BM2CMP_FRAME::ToggleAspectRatioLock( wxCommandEvent& event ) if( m_AspectRatioLocked ) { m_AspectRatioLockButton->SetBitmap( KiBitmap( BITMAPS::locked ) ); - //Force display update when aspect ratio is locked - auto fakeEvent = wxCommandEvent(); - OnSizeChangeX( fakeEvent ); - } + //Force display update when aspect ratio is locked + wxCommandEvent dummy; + OnSizeChangeX( dummy ); + } else { m_AspectRatioLockButton->SetBitmap( KiBitmap( BITMAPS::unlocked ) ); @@ -609,12 +609,13 @@ void BM2CMP_FRAME::Binarize( double aThreshold ) unsigned char alpha_thresh = 0.7 * threshold; for( int y = 0; y < h; y++ ) + { for( int x = 0; x < w; x++ ) { unsigned char pixout; - auto pixin = m_Greyscale_Image.GetGreen( x, y ); - auto alpha = m_Greyscale_Image.HasAlpha() ? - m_Greyscale_Image.GetAlpha( x, y ) : wxALPHA_OPAQUE; + unsigned char pixin = m_Greyscale_Image.GetGreen( x, y ); + unsigned char alpha = m_Greyscale_Image.HasAlpha() ? m_Greyscale_Image.GetAlpha( x, y ) + : wxALPHA_OPAQUE; if( pixin < threshold && alpha > alpha_thresh ) pixout = 0; @@ -624,6 +625,7 @@ void BM2CMP_FRAME::Binarize( double aThreshold ) m_NB_Image.SetRGB( x, y, pixout, pixout, pixout ); } + } m_BN_Bitmap = wxBitmap( m_NB_Image ); @@ -632,17 +634,19 @@ void BM2CMP_FRAME::Binarize( double aThreshold ) void BM2CMP_FRAME::NegateGreyscaleImage( ) { - unsigned char pix; - int h = m_Greyscale_Image.GetHeight(); - int w = m_Greyscale_Image.GetWidth(); + unsigned char pix; + int h = m_Greyscale_Image.GetHeight(); + int w = m_Greyscale_Image.GetWidth(); for( int y = 0; y < h; y++ ) + { for( int x = 0; x < w; x++ ) { pix = m_Greyscale_Image.GetGreen( x, y ); pix = ~pix; m_Greyscale_Image.SetRGB( x, y, pix, pix, pix ); } + } } @@ -776,14 +780,10 @@ void BM2CMP_FRAME::exportPostScriptFormat() if( path.IsEmpty() || !wxDirExists( path ) ) path = ::wxGetCwd(); - wxFileDialog fileDlg( this, _( "Create PostScript File" ), - path, wxEmptyString, - PSFileWildcard(), - wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); + wxFileDialog fileDlg( this, _( "Create PostScript File" ), path, wxEmptyString, + PSFileWildcard(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); - int diag = fileDlg.ShowModal(); - - if( diag != wxID_OK ) + if( fileDlg.ShowModal() != wxID_OK ) return; fn = fileDlg.GetPath(); @@ -816,14 +816,10 @@ void BM2CMP_FRAME::exportEeschemaFormat() if( path.IsEmpty() || !wxDirExists(path) ) path = ::wxGetCwd(); - wxFileDialog fileDlg( this, _( "Create Symbol Library" ), - path, wxEmptyString, - KiCadSymbolLibFileWildcard(), - wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); + wxFileDialog fileDlg( this, _( "Create Symbol Library" ), path, wxEmptyString, + KiCadSymbolLibFileWildcard(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); - int diag = fileDlg.ShowModal(); - - if( diag != wxID_OK ) + if( fileDlg.ShowModal() != wxID_OK ) return; fn = fileDlg.GetPath(); @@ -855,14 +851,10 @@ void BM2CMP_FRAME::exportPcbnewFormat() if( path.IsEmpty() || !wxDirExists( path ) ) path = m_mruPath; - wxFileDialog fileDlg( this, _( "Create Footprint Library" ), - path, wxEmptyString, - KiCadFootprintLibFileWildcard(), - wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); + wxFileDialog fileDlg( this, _( "Create Footprint Library" ), path, wxEmptyString, + KiCadFootprintLibFileWildcard(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); - int diag = fileDlg.ShowModal(); - - if( diag != wxID_OK ) + if( fileDlg.ShowModal() != wxID_OK ) return; fn = fileDlg.GetPath(); @@ -907,7 +899,7 @@ void BM2CMP_FRAME::ExportToBuffer( std::string& aOutput, OUTPUT_FMT_ID aFormat ) { for( int x = 0; x < w; x++ ) { - auto pix = m_NB_Image.GetGreen( x, y ); + unsigned char pix = m_NB_Image.GetGreen( x, y ); BM_PUT( potrace_bitmap, x, y, pix ? 0 : 1 ); } } diff --git a/common/eda_base_frame.cpp b/common/eda_base_frame.cpp index a58a98a91d..6e8d7f9acb 100644 --- a/common/eda_base_frame.cpp +++ b/common/eda_base_frame.cpp @@ -407,7 +407,7 @@ void EDA_BASE_FRAME::HandleUpdateUIEvent( wxUpdateUIEvent& aEvent, EDA_BASE_FRAM // wxMenuItems don't want to be checked unless they actually are checkable, so we have to // check to see if they can be and can't just universally apply a check in this event. - if( auto menu = dynamic_cast( aEvent.GetEventObject() ) ) + if( wxMenu* menu = dynamic_cast( aEvent.GetEventObject() ) ) canCheck = menu->FindItem( aEvent.GetId() )->IsCheckable(); if( canCheck ) diff --git a/common/eda_draw_frame.cpp b/common/eda_draw_frame.cpp index fcd2fca627..bba6bb5c7f 100644 --- a/common/eda_draw_frame.cpp +++ b/common/eda_draw_frame.cpp @@ -654,10 +654,10 @@ void EDA_DRAW_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg ) m_findReplaceData->matchCase = aCfg->m_FindReplace.match_case; m_findReplaceData->searchAndReplace = aCfg->m_FindReplace.search_and_replace; - for( auto& s : aCfg->m_FindReplace.find_history ) + for( const wxString& s : aCfg->m_FindReplace.find_history ) m_findStringHistoryList.Add( s ); - for( auto& s : aCfg->m_FindReplace.replace_history ) + for( const wxString& s : aCfg->m_FindReplace.replace_history ) m_replaceStringHistoryList.Add( s ); } diff --git a/common/eda_pattern_match.cpp b/common/eda_pattern_match.cpp index 4ddf93ba5d..a7cf392f75 100644 --- a/common/eda_pattern_match.cpp +++ b/common/eda_pattern_match.cpp @@ -115,7 +115,7 @@ EDA_PATTERN_MATCH::FIND_RESULT EDA_PATTERN_MATCH_REGEX::Find( const wxString& aC m_regex.GetMatch( &start, &len, 0 ); return { static_cast( std::min( start, static_cast( INT_MAX ) ) ), - static_cast( std::min( len, static_cast( INT_MAX ) ) ) }; + static_cast( std::min( len, static_cast( INT_MAX ) ) ) }; } else { @@ -147,6 +147,7 @@ bool EDA_PATTERN_MATCH_WILDCARD::SetPattern( const wxString& aPattern ) for( wxString::const_iterator it = aPattern.begin(); it < aPattern.end(); ++it ) { wxUniChar c = *it; + if( c == '?' ) { regex += wxT( "." ); @@ -193,9 +194,11 @@ bool EDA_PATTERN_MATCH_WILDCARD_EXPLICIT::SetPattern( const wxString& aPattern ) const wxString to_replace = wxT( ".*+?^${}()|[]/\\" ); regex += wxT( "^" ); + for( wxString::const_iterator it = aPattern.begin(); it < aPattern.end(); ++it ) { wxUniChar c = *it; + if( c == '?' ) { regex += wxT( "." ); @@ -214,6 +217,7 @@ bool EDA_PATTERN_MATCH_WILDCARD_EXPLICIT::SetPattern( const wxString& aPattern ) regex += c; } } + regex += wxT( "$" ); return EDA_PATTERN_MATCH_REGEX::SetPattern( regex ); @@ -278,8 +282,7 @@ wxString const& EDA_PATTERN_MATCH_RELATIONAL::GetPattern() const } -EDA_PATTERN_MATCH::FIND_RESULT EDA_PATTERN_MATCH_RELATIONAL::Find( - const wxString& aCandidate ) const +EDA_PATTERN_MATCH::FIND_RESULT EDA_PATTERN_MATCH_RELATIONAL::Find( const wxString& aCandidate ) const { wxStringTokenizer tokenizer( aCandidate ); size_t lastpos = 0; @@ -332,11 +335,11 @@ int EDA_PATTERN_MATCH_RELATIONAL::FindOne( const wxString& aCandidate ) const switch( m_relation ) { - case LT: return val_parsed < m_value ? istart : EDA_PATTERN_NOT_FOUND; - case LE: return val_parsed <= m_value ? istart : EDA_PATTERN_NOT_FOUND; - case EQ: return val_parsed == m_value ? istart : EDA_PATTERN_NOT_FOUND; - case GE: return val_parsed >= m_value ? istart : EDA_PATTERN_NOT_FOUND; - case GT: return val_parsed > m_value ? istart : EDA_PATTERN_NOT_FOUND; + case LT: return val_parsed < m_value ? istart : EDA_PATTERN_NOT_FOUND; + case LE: return val_parsed <= m_value ? istart : EDA_PATTERN_NOT_FOUND; + case EQ: return val_parsed == m_value ? istart : EDA_PATTERN_NOT_FOUND; + case GE: return val_parsed >= m_value ? istart : EDA_PATTERN_NOT_FOUND; + case GT: return val_parsed > m_value ? istart : EDA_PATTERN_NOT_FOUND; case ANY: return istart; default: return EDA_PATTERN_NOT_FOUND; } @@ -364,8 +367,8 @@ const std::map EDA_PATTERN_MATCH_RELATIONAL::m_units = { EDA_COMBINED_MATCHER::EDA_COMBINED_MATCHER( const wxString& aPattern, - COMBINED_MATCHER_CONTEXT aContext ) - : m_pattern( aPattern ) + COMBINED_MATCHER_CONTEXT aContext ) : + m_pattern( aPattern ) { switch( aContext ) { @@ -392,7 +395,7 @@ bool EDA_COMBINED_MATCHER::Find( const wxString& aTerm, int& aMatchersTriggered, aPosition = EDA_PATTERN_NOT_FOUND; aMatchersTriggered = 0; - for( auto const& matcher : m_matchers ) + for( const std::unique_ptr& matcher : m_matchers ) { EDA_PATTERN_MATCH::FIND_RESULT local_find = matcher->Find( aTerm ); @@ -401,9 +404,7 @@ bool EDA_COMBINED_MATCHER::Find( const wxString& aTerm, int& aMatchersTriggered, aMatchersTriggered += 1; if( local_find.start < aPosition || aPosition == EDA_PATTERN_NOT_FOUND ) - { aPosition = local_find.start; - } } } @@ -417,12 +418,9 @@ wxString const& EDA_COMBINED_MATCHER::GetPattern() const } -void EDA_COMBINED_MATCHER::AddMatcher( - const wxString &aPattern, - std::unique_ptr aMatcher ) +void EDA_COMBINED_MATCHER::AddMatcher( const wxString &aPattern, + std::unique_ptr aMatcher ) { if ( aMatcher->SetPattern( aPattern ) ) - { m_matchers.push_back( std::move( aMatcher ) ); - } } diff --git a/common/footprint_filter.cpp b/common/footprint_filter.cpp index 8a679748b9..e8f2a5445d 100644 --- a/common/footprint_filter.cpp +++ b/common/footprint_filter.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -89,7 +89,7 @@ void FOOTPRINT_FILTER_IT::increment() int matches, position; bool exclude = false; - for( auto& matcher : m_filter->m_pattern_filters ) + for( std::unique_ptr& matcher : m_filter->m_pattern_filters ) { if( !matcher->Find( searchStr.Lower(), matches, position ) ) { @@ -132,7 +132,7 @@ bool FOOTPRINT_FILTER_IT::FootprintFilterMatch( FOOTPRINT_INFO& aItem ) // The matching is case insensitive wxString name; - for( auto const& each_filter : m_filter->m_footprint_filters ) + for( const std::unique_ptr& each_filter : m_filter->m_footprint_filters ) { name.Empty(); diff --git a/common/lib_tree_model_adapter.cpp b/common/lib_tree_model_adapter.cpp index 0443751327..78ee4d95ae 100644 --- a/common/lib_tree_model_adapter.cpp +++ b/common/lib_tree_model_adapter.cpp @@ -494,8 +494,8 @@ void LIB_TREE_MODEL_ADAPTER::RefreshTree() { size_t i = 0; - for( auto& it : m_colNameMap ) - m_colWidths[it.first] = widths[i++]; + for( const auto& [ colName, colPtr ] : m_colNameMap ) + m_colWidths[ colName ] = widths[i++]; } auto colIt = m_colWidths.begin(); @@ -506,13 +506,13 @@ void LIB_TREE_MODEL_ADAPTER::RefreshTree() if( colIt != m_colWidths.end() ) colIt->second -= walk; - for( auto& it : m_colNameMap ) + for( const auto& [ colName, colPtr ] : m_colNameMap ) { - if( it.second == m_columns[0] ) + if( colPtr == m_columns[0] ) continue; - wxASSERT( m_colWidths.count( it.first ) ); - it.second->SetWidth( m_colWidths[it.first] ); + wxASSERT( m_colWidths.count( colName ) ); + colPtr->SetWidth( m_colWidths[ colName ] ); } walk = -walk; diff --git a/common/lockfile.cpp b/common/lockfile.cpp index c6ec67793c..889e821318 100644 --- a/common/lockfile.cpp +++ b/common/lockfile.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2014-2015 SoftPLC Corporation, Dick Hollenbeck - * Copyright (C) 2014-2017 KiCad Developers, see AUTHORS.TXT for contributors. + * Copyright (C) 2014-2022 KiCad Developers, see AUTHORS.TXT for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -46,13 +46,10 @@ std::unique_ptr LockFile( const wxString& aFileName ) // We can have filenames coming from Windows, so also convert Windows separator lockFileName.Replace( "\\", "_" ); - auto p = std::make_unique( lockFileName, - GetKicadLockFilePath() ); + auto p = std::make_unique( lockFileName, GetKicadLockFilePath() ); if( p->IsAnotherRunning() ) - { p = nullptr; - } return p; } diff --git a/common/pg_properties.cpp b/common/pg_properties.cpp index b2e9ace5ab..44950a4ff6 100644 --- a/common/pg_properties.cpp +++ b/common/pg_properties.cpp @@ -2,6 +2,7 @@ * This program source code file is part of KICAD, a free EDA CAD application. * * Copyright (C) 2020 CERN + * Copyright (C) 2021-2022 KiCad Developers, see AUTHORS.TXT for contributors. * @author Maciej Suminski * * This program is free software; you can redistribute it and/or @@ -53,7 +54,7 @@ wxPGProperty* PGPropertyFactory( const PROPERTY_BASE* aProperty ) case PROPERTY_DISPLAY::PT_DECIDEGREE: case PROPERTY_DISPLAY::PT_DEGREE: { - auto prop = new PGPROPERTY_ANGLE(); + PGPROPERTY_ANGLE* prop = new PGPROPERTY_ANGLE(); if( display == PROPERTY_DISPLAY::PT_DECIDEGREE ) prop->SetScale( 10.0 ); diff --git a/common/wildcards_and_files_ext.cpp b/common/wildcards_and_files_ext.cpp index a189a62e97..6e5b91121e 100644 --- a/common/wildcards_and_files_ext.cpp +++ b/common/wildcards_and_files_ext.cpp @@ -3,7 +3,7 @@ * * Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2008 Wayne Stambaugh - * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -35,12 +35,13 @@ #include bool compareFileExtensions( const std::string& aExtension, - const std::vector& aReference, bool aCaseSensitive ) + const std::vector& aReference, bool aCaseSensitive ) { // Form the regular expression string by placing all possible extensions into it as alternatives std::string regexString = "("; bool first = true; - for( const auto& ext : aReference ) + + for( const std::string& ext : aReference ) { // The | separate goes between the extensions if( !first ) @@ -50,6 +51,7 @@ bool compareFileExtensions( const std::string& aExtension, regexString += ext; } + regexString += ")"; // Create the regex and see if it matches @@ -106,7 +108,8 @@ wxString AddFileExtListToFilter( const std::vector& aExts ) // Add extensions to the filter list, using a formatted string (GTK specific): bool first = true; - for( const auto& ext : aExts ) + + for( const std::string& ext : aExts ) { if( !first ) files_filter << ";*."; diff --git a/common/wxdataviewctrl_helpers.cpp b/common/wxdataviewctrl_helpers.cpp index a9cd9ba8b6..8b60c17c65 100644 --- a/common/wxdataviewctrl_helpers.cpp +++ b/common/wxdataviewctrl_helpers.cpp @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2017 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2017-2022 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -22,7 +22,7 @@ wxDataViewItem GetPrevItem( wxDataViewCtrl const& aView, wxDataViewItem const& aItem ) { - auto prevItem = GetPrevSibling( aView, aItem ); + wxDataViewItem prevItem = GetPrevSibling( aView, aItem ); if( !prevItem.IsOk() ) {