Skip to content

Commit

Permalink
Merge pull request #1728 from berryzplus/feature/fix_sscanf_warnings
Browse files Browse the repository at this point in the history
Grepのビルド警告に対処する
  • Loading branch information
berryzplus authored Sep 25, 2021
2 parents 14335fd + e8f0e57 commit b4c152c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 17 deletions.
17 changes: 8 additions & 9 deletions sakura_core/CGrepAgent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,21 +300,20 @@ void CGrepAgent::AddTail( CEditView* pcEditView, const CNativeW& cmem, bool bAdd

int GetHwndTitle(HWND& hWndTarget, CNativeW* pmemTitle, WCHAR* pszWindowName, WCHAR* pszWindowPath, const WCHAR* pszFile)
{
if( 0 != wcsncmp(L":HWND:", pszFile, 6) ){
hWndTarget = nullptr; //out引数をクリアする

constexpr auto& szTargetPrefix = L":HWND:";
constexpr auto cchTargetPrefix = _countof(szTargetPrefix) - 1;
if( 0 != wcsncmp(pszFile, szTargetPrefix, cchTargetPrefix) ){
return 0; // ハンドルGrepではない
}
#ifdef _WIN64
_stscanf(pszFile + 6, L"%016I64x", &hWndTarget);
#else
_stscanf(pszFile + 6, L"%08x", &hWndTarget);
#endif
if( 0 >= ::swscanf_s(pszFile + cchTargetPrefix, L"%x", (size_t*)&hWndTarget) || !IsSakuraMainWindow(hWndTarget) ){
return -1; // ハンドルを読み取れなかった、または、対象ウインドウハンドルが存在しない
}
if( pmemTitle ){
const wchar_t* p = L"Window:[";
pmemTitle->SetStringHoldBuffer(p, 8);
}
if( !IsSakuraMainWindow(hWndTarget) ){
return -1;
}
::SendMessageAny(hWndTarget, MYWM_GETFILEINFO, 0, 0);
EditInfo* editInfo = &(GetDllShareData().m_sWorkBuffer.m_EditInfo_MYWM_GETFILEINFO);
if( '\0' == editInfo->m_szPath[0] ){
Expand Down
13 changes: 5 additions & 8 deletions sakura_core/view/CEditView_Command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,11 @@ bool CEditView::TagJumpSub(
// 予め絶対パスに変換する.(キーワードヘルプジャンプで用いる)
// 2007.05.19 ryoji 相対パスは設定ファイルからのパスを優先
WCHAR szJumpToFile[1024];
HWND hwndTarget = NULL;
if( 0 == wcsncmp(pszFileName, L":HWND:[", 7) ){
#ifdef _WIN64
_stscanf(pszFileName + 7, L"%016I64x", &hwndTarget);
#else
_stscanf(pszFileName + 7, L"%08x", &hwndTarget);
#endif
if( !IsSakuraMainWindow(hwndTarget) ){
HWND hwndTarget = nullptr;
constexpr auto& szTargetPrefix = L":HWND:[";
constexpr auto cchTargetPrefix = _countof(szTargetPrefix) - 1;
if( 0 == wcsncmp(pszFileName, szTargetPrefix, cchTargetPrefix) ){
if( 0 >= ::swscanf_s(pszFileName + cchTargetPrefix, L"%x", (size_t*)&hwndTarget) || !IsSakuraMainWindow(hwndTarget) ){
return false;
}
}else{
Expand Down

0 comments on commit b4c152c

Please sign in to comment.