@@ -3618,22 +3618,25 @@ void CSearchDlg::SearchFile(CSearchInfo sInfo, const std::wstring& searchRoot, b
3618
3618
// we keep it simple:
3619
3619
// files bigger than 30MB are considered binary. Binary files are searched
3620
3620
// as if they're ANSI text files.
3621
- std::wstring localSearchString = searchString;
3621
+ std::wstring localSearchString = searchString;
3622
+ std::wstring fileNameFull = sInfo .filePath .substr (sInfo .filePath .find_last_of (' \\ ' ) + 1 );
3622
3623
3623
- SearchReplace (localSearchString, L" ${filepath}" , sInfo .filePath );
3624
- std::wstring fileNameFull = sInfo .filePath .substr (sInfo .filePath .find_last_of (' \\ ' ) + 1 );
3625
- auto dotPos = fileNameFull.find_last_of (' .' );
3626
- if (dotPos != std::string::npos)
3624
+ if (bUseRegex)
3627
3625
{
3628
- std::wstring filename = fileNameFull. substr ( 0 , dotPos );
3629
- SearchReplace (localSearchString, L" ${filename} " , filename );
3630
- if (fileNameFull. size () > dotPos )
3626
+ SearchReplace (localSearchString, L" ${filepath} " , sInfo . filePath );
3627
+ auto dotPos = fileNameFull. find_last_of ( ' . ' );
3628
+ if (dotPos != std::string::npos )
3631
3629
{
3632
- std::wstring fileExt = fileNameFull.substr (dotPos + 1 );
3633
- SearchReplace (localSearchString, L" ${fileext}" , fileExt);
3630
+ std::wstring filename = fileNameFull.substr (0 , dotPos);
3631
+ SearchReplace (localSearchString, L" ${filename}" , filename);
3632
+ if (fileNameFull.size () > dotPos)
3633
+ {
3634
+ std::wstring fileExt = fileNameFull.substr (dotPos + 1 );
3635
+ SearchReplace (localSearchString, L" ${fileext}" , fileExt);
3636
+ }
3634
3637
}
3635
3638
}
3636
- if (!bUseRegex)
3639
+ else
3637
3640
{
3638
3641
using namespace std ::string_literals;
3639
3642
for (const auto & c : {L" \\ " s, L" ^" s, L" $" s, L" ." s, L" |" s, L" ?" s, L" *" s, L" +" s, L" (" s, L" )" s, L" [" s, L" {" s})
@@ -3779,17 +3782,20 @@ void CSearchDlg::SearchFile(CSearchInfo sInfo, const std::wstring& searchRoot, b
3779
3782
flags &= ~boost::match_prev_avail;
3780
3783
flags &= ~boost::match_not_bob;
3781
3784
RegexReplaceFormatter replaceFmt (m_replaceString);
3782
- replaceFmt.SetReplacePair (L" ${filepath}" , sInfo .filePath );
3783
- std::wstring fileNameFullW = sInfo .filePath .substr (sInfo .filePath .find_last_of (' \\ ' ) + 1 );
3784
- auto dotPosW = fileNameFullW.find_last_of (' .' );
3785
- if (dotPosW != std::string::npos)
3785
+ if (bUseRegex)
3786
3786
{
3787
- std::wstring filename = fileNameFullW.substr (0 , dotPosW);
3788
- replaceFmt.SetReplacePair (L" ${filename}" , filename);
3789
- if (fileNameFullW.size () > dotPosW)
3787
+ replaceFmt.SetReplacePair (L" ${filepath}" , sInfo .filePath );
3788
+ std::wstring fileNameFullW = sInfo .filePath .substr (sInfo .filePath .find_last_of (' \\ ' ) + 1 );
3789
+ auto dotPosW = fileNameFullW.find_last_of (' .' );
3790
+ if (dotPosW != std::string::npos)
3790
3791
{
3791
- std::wstring fileExt = fileNameFullW.substr (dotPosW + 1 );
3792
- replaceFmt.SetReplacePair (L" ${fileext}" , fileExt);
3792
+ std::wstring filename = fileNameFullW.substr (0 , dotPosW);
3793
+ replaceFmt.SetReplacePair (L" ${filename}" , filename);
3794
+ if (fileNameFullW.size () > dotPosW)
3795
+ {
3796
+ std::wstring fileExt = fileNameFullW.substr (dotPosW + 1 );
3797
+ replaceFmt.SetReplacePair (L" ${fileext}" , fileExt);
3798
+ }
3793
3799
}
3794
3800
}
3795
3801
std::wstring replaced = regex_replace (textFile.GetFileString (), expression, replaceFmt, flags);
@@ -4054,16 +4060,19 @@ void CSearchDlg::SearchFile(CSearchInfo sInfo, const std::wstring& searchRoot, b
4054
4060
flags &= ~boost::match_not_bob;
4055
4061
RegexReplaceFormatterA replaceFmt (CUnicodeUtils::StdGetUTF8 (m_replaceString));
4056
4062
replaceFmt.SetReplacePair (" ${filepath}" , CUnicodeUtils::StdGetUTF8 (sInfo .filePath ));
4057
- std::string fileNameFullA = CUnicodeUtils::StdGetUTF8 (sInfo .filePath .substr (sInfo .filePath .find_last_of (' \\ ' ) + 1 ));
4058
- auto dotPosA = fileNameFullA.find_last_of (' .' );
4059
- if (dotPosA != std::string::npos)
4063
+ if (bUseRegex)
4060
4064
{
4061
- std::string filename = fileNameFullA. substr (0 , dotPosA );
4062
- replaceFmt. SetReplacePair ( " ${filename} " , filename );
4063
- if (fileNameFull. size () > dotPosA )
4065
+ std::string fileNameFullA = CUnicodeUtils::StdGetUTF8 ( sInfo . filePath . substr (sInfo . filePath . find_last_of ( ' \\ ' ) + 1 ) );
4066
+ auto dotPosA = fileNameFullA. find_last_of ( ' . ' );
4067
+ if (dotPosA != std::string::npos )
4064
4068
{
4065
- std::string fileExt = fileNameFullA.substr (dotPosA + 1 );
4066
- replaceFmt.SetReplacePair (" ${fileext}" , fileExt);
4069
+ std::string filename = fileNameFullA.substr (0 , dotPosA);
4070
+ replaceFmt.SetReplacePair (" ${filename}" , filename);
4071
+ if (fileNameFull.size () > dotPosA)
4072
+ {
4073
+ std::string fileExt = fileNameFullA.substr (dotPosA + 1 );
4074
+ replaceFmt.SetReplacePair (" ${fileext}" , fileExt);
4075
+ }
4067
4076
}
4068
4077
}
4069
4078
0 commit comments