bool CRecentFile::TextToDataType( EditInfo* dst, LPCTSTR pszText ) const { if( _countof(dst->m_szPath) < auto_strlen(pszText) + 1 ){ return false; } _tcscpy(dst->m_szPath, pszText); return true; }
bool COutputAdapterDiff::OutputA(const ACHAR* pBuf, int size) { if( size == -1 ){ size = auto_strlen(pBuf); } //@@@ 2003.05.31 MIK // 先頭がBinary filesならバイナリファイルのため意味のある差分が取られなかった if( bFirst ) { bFirst = false; if( strncmp( pBuf, "Binary files ", strlen( "Binary files " ) ) == 0 ) { WarningMessage( NULL, LS(STR_ERR_DLGEDITVWDIFF4) ); return false; } } //読み出した文字列をチェックする int j; for( j = 0; j < (int)size/*-1*/; j++ ) { if( bLineHead ) { if( pBuf[j] != '\n' && pBuf[j] != '\r' ) { bLineHead = false; //DIFF情報の始まりか? if( pBuf[j] >= '0' && pBuf[j] <= '9' ) { bDiffInfo = true; nDiffLen = 0; szDiffData[nDiffLen++] = pBuf[j]; } /* else if( pBuf[j] == '<' || pBuf[j] == '>' || pBuf[j] == '-' ) { bDiffInfo = false; nDiffLen = 0; } */ } } else { //行末に達したか? if( pBuf[j] == '\n' || pBuf[j] == '\r' ) { //DIFF情報があれば解析する if( bDiffInfo == true && nDiffLen > 0 ) { szDiffData[nDiffLen] = '\0'; m_view->AnalyzeDiffInfo( szDiffData, nFlgFile12 ); nDiffLen = 0; } bDiffInfo = false; bLineHead = true; } else if( bDiffInfo == true ) { //DIFF情報に追加する szDiffData[nDiffLen++] = pBuf[j]; if( nDiffLen >= 99 ) { nDiffLen = 0; bDiffInfo = false; } } } } return true; }
/* TRUE==正常 FALSE==入力エラー */ int CDlgGrep::GetData( void ) { /* サブフォルダからも検索する*/ m_bSubFolder = ::IsDlgButtonChecked( GetHwnd(), IDC_CHK_SUBFOLDER ); m_pShareData->m_Common.m_sSearch.m_bGrepSubFolder = m_bSubFolder; /* Grep:サブフォルダも検索 */ /* この編集中のテキストから検索する */ m_bFromThisText = ::IsDlgButtonChecked( GetHwnd(), IDC_CHK_FROMTHISTEXT ); /* 英大文字と英小文字を区別する */ m_sSearchOption.bLoHiCase = (0!=::IsDlgButtonChecked( GetHwnd(), IDC_CHK_LOHICASE )); //2001/06/23 N.Nakatani /* 単語単位で検索 */ m_sSearchOption.bWordOnly = (0!=::IsDlgButtonChecked( GetHwnd(), IDC_CHK_WORD )); /* 正規表現 */ m_sSearchOption.bRegularExp = (0!=::IsDlgButtonChecked( GetHwnd(), IDC_CHK_REGULAREXP )); /* 文字コード自動判別 */ // m_bKanjiCode_AutoDetect = ::IsDlgButtonChecked( GetHwnd(), IDC_CHK_KANJICODEAUTODETECT ); /* 文字コードセット */ { int nIdx; HWND hWndCombo = ::GetDlgItem( GetHwnd(), IDC_COMBO_CHARSET ); nIdx = Combo_GetCurSel( hWndCombo ); m_nGrepCharSet = (ECodeType)Combo_GetItemData( hWndCombo, nIdx ); } /* 行を出力/該当部分/否マッチ行 を出力 */ if( ::IsDlgButtonChecked( GetHwnd(), IDC_RADIO_OUTPUTLINE ) ){ m_nGrepOutputLineType = 1; }else if( ::IsDlgButtonChecked( GetHwnd(), IDC_RADIO_NOHIT ) ){ m_nGrepOutputLineType = 2; }else{ m_nGrepOutputLineType = 0; } /* Grep: 出力形式 */ if( FALSE != ::IsDlgButtonChecked( GetHwnd(), IDC_RADIO_OUTPUTSTYLE1 ) ){ m_nGrepOutputStyle = 1; /* Grep: 出力形式 */ } if( FALSE != ::IsDlgButtonChecked( GetHwnd(), IDC_RADIO_OUTPUTSTYLE2 ) ){ m_nGrepOutputStyle = 2; /* Grep: 出力形式 */ } if( FALSE != ::IsDlgButtonChecked( GetHwnd(), IDC_RADIO_OUTPUTSTYLE3 ) ){ m_nGrepOutputStyle = 3; } m_bGrepOutputFileOnly = IsDlgButtonCheckedBool( GetHwnd(), IDC_CHECK_FILE_ONLY ); m_bGrepOutputBaseFolder = IsDlgButtonCheckedBool( GetHwnd(), IDC_CHECK_BASE_PATH ); m_bGrepSeparateFolder = IsDlgButtonCheckedBool( GetHwnd(), IDC_CHECK_SEP_FOLDER ); /* 検索文字列 */ int nBufferSize = ::GetWindowTextLength( GetItemHwnd(IDC_COMBO_TEXT) ) + 1; std::vector<TCHAR> vText(nBufferSize); ::DlgItem_GetText( GetHwnd(), IDC_COMBO_TEXT, &vText[0], nBufferSize); m_strText = to_wchar(&vText[0]); m_bSetText = true; /* 検索ファイル */ ::DlgItem_GetText( GetHwnd(), IDC_COMBO_FILE, m_szFile, _countof2(m_szFile) ); /* 検索フォルダ */ ::DlgItem_GetText( GetHwnd(), IDC_COMBO_FOLDER, m_szFolder, _countof2(m_szFolder) ); m_pShareData->m_Common.m_sSearch.m_nGrepCharSet = m_nGrepCharSet; // 文字コード自動判別 m_pShareData->m_Common.m_sSearch.m_nGrepOutputLineType = m_nGrepOutputLineType; // 行を出力/該当部分/否マッチ行 を出力 m_pShareData->m_Common.m_sSearch.m_nGrepOutputStyle = m_nGrepOutputStyle; // Grep: 出力形式 m_pShareData->m_Common.m_sSearch.m_bGrepOutputFileOnly = m_bGrepOutputFileOnly; m_pShareData->m_Common.m_sSearch.m_bGrepOutputBaseFolder = m_bGrepOutputBaseFolder; m_pShareData->m_Common.m_sSearch.m_bGrepSeparateFolder = m_bGrepSeparateFolder; //やめました // if( 0 == wcslen( m_szText ) ){ // WarningMessage( GetHwnd(), _T("検索のキーワードを指定してください。") ); // return FALSE; // } if( 0 != auto_strlen( m_szFile ) ){ CGrepEnumKeys enumKeys; int nErrorNo = enumKeys.SetFileKeys( m_szFile ); if( 1 == nErrorNo ){ WarningMessage( GetHwnd(), LS(STR_DLGGREP2) ); return FALSE; }else if( nErrorNo == 2 ){ WarningMessage( GetHwnd(), LS(STR_DLGGREP3) ); return FALSE; } } /* この編集中のテキストから検索する */ if( m_szFile[0] == _T('\0') ){ // Jun. 16, 2003 Moca // 検索パターンが指定されていない場合のメッセージ表示をやめ、 // 「*.*」が指定されたものと見なす. _tcscpy( m_szFile, _T("*.*") ); } if( m_szFolder[0] == _T('\0') ){ WarningMessage( GetHwnd(), LS(STR_DLGGREP4) ); return FALSE; } { //カレントディレクトリを保存。このブロックから抜けるときに自動でカレントディレクトリは復元される。 CCurrentDirectoryBackupPoint cCurDirBackup; // 2011.11.24 Moca 複数フォルダ指定 std::vector<std::tstring> vPaths; CGrepAgent::CreateFolders( m_szFolder, vPaths ); int nFolderLen = 0; TCHAR szFolder[_MAX_PATH]; szFolder[0] = _T('\0'); for( int i = 0 ; i < (int)vPaths.size(); i ++ ){ // 相対パス→絶対パス if( !::SetCurrentDirectory( vPaths[i].c_str() ) ){ WarningMessage( GetHwnd(), LS(STR_DLGGREP5) ); return FALSE; } TCHAR szFolderItem[_MAX_PATH]; ::GetCurrentDirectory( _MAX_PATH, szFolderItem ); // ;がフォルダ名に含まれていたら""で囲う if( auto_strchr( szFolderItem, _T(';') ) ){ szFolderItem[0] = _T('"'); ::GetCurrentDirectory( _MAX_PATH, szFolderItem + 1 ); auto_strcat(szFolderItem, _T("\"")); } int nFolderItemLen = auto_strlen( szFolderItem ); if( _MAX_PATH < nFolderLen + nFolderItemLen + 1 ){ WarningMessage( GetHwnd(), LS(STR_DLGGREP6) ); return FALSE; } if( i ){ auto_strcat( szFolder, _T(";") ); } auto_strcat( szFolder, szFolderItem ); nFolderLen = auto_strlen( szFolder ); } auto_strcpy( m_szFolder, szFolder ); } //@@@ 2002.2.2 YAZAKI CShareData.AddToSearchKeyArr()追加に伴う変更 /* 検索文字列 */ if( 0 < m_strText.size() ){ // From Here Jun. 26, 2001 genta // 正規表現ライブラリの差し替えに伴う処理の見直し int nFlag = 0; nFlag |= m_sSearchOption.bLoHiCase ? 0x01 : 0x00; if( m_sSearchOption.bRegularExp && !CheckRegexpSyntax( m_strText.c_str(), GetHwnd(), true, nFlag) ){ return FALSE; } // To Here Jun. 26, 2001 genta 正規表現ライブラリ差し替え if( m_strText.size() < _MAX_PATH ){ CSearchKeywordManager().AddToSearchKeyArr( m_strText.c_str() ); m_pShareData->m_Common.m_sSearch.m_sSearchOption = m_sSearchOption; // 検索オプション } }else{ // 2014.07.01 空キーも登録する CSearchKeywordManager().AddToSearchKeyArr( L"" ); } // この編集中のテキストから検索する場合、履歴に残さない Uchi 2008/5/23 if (!m_bFromThisText) { /* 検索ファイル */ CSearchKeywordManager().AddToGrepFileArr( m_szFile ); /* 検索フォルダ */ CSearchKeywordManager().AddToGrepFolderArr( m_szFolder ); } return TRUE; }