Skip to content

Commit 2ff385d

Browse files
committed
PatchUnicode-1051 v0.8 タグジャンプに対応 sakura-editor#1607
1 parent 2d49817 commit 2ff385d

File tree

2 files changed

+17
-21
lines changed

2 files changed

+17
-21
lines changed

sakura_core/cmd/CViewCommander_TagJump.cpp

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ static bool IsFileExists2( const wchar_t* pszFile )
7171
return IsFileExists(pszFile, true);
7272
}
7373

74-
static bool IsHWNDTag( const wchar_t* pLine, wchar_t* pFile, int* pnLen = NULL )
74+
static bool IsHWNDTag( const wchar_t* pLine, std::wstring& str, int* pnLen = NULL )
7575
{
7676
if( 0 == wcsncmp(pLine, L":HWND:[", 7) ){
7777
const wchar_t* pFileEnd = wcsstr( pLine, L"]" );
@@ -84,12 +84,11 @@ static bool IsHWNDTag( const wchar_t* pLine, wchar_t* pFile, int* pnLen = NULL )
8484
}
8585
}
8686
if( i != nLen && nLen <= 16 + 8 ){
87-
if( pFile ){
88-
wmemcpy(szJumpToFile, pLine, nLen);
89-
}
9087
if( pnLen ){
9188
*pnLen = nLen;
89+
return true;
9290
}
91+
str.assign(pLine, nLen);
9392
return true;
9493
}
9594
}
@@ -291,15 +290,12 @@ bool CViewCommander::Command_TagJumpNoMessage( bool bClose )
291290
break;
292291
}else if (!GetQuoteFilePath(&pLine[2], strFile, MAX_TAG_PATH)) {
293292
break;
294-
}else if( IsHWNDTag(&pLine[2], szJumpToFile) ){
295-
break;
296293
}
297294
searchMode = TAGLIST_ROOT;
298295
}else if( 0 == wmemcmp( pLine, L"\"", 2 ) ){
299296
if (!GetQuoteFilePath(&pLine[2], strFile, MAX_TAG_PATH)) {
300297
break;
301-
}
302-
if( IsHWNDTag(&pLine[2], szJumpToFile) ){
298+
}else if( IsHWNDTag(&pLine[2], strJumpToFile) ){
303299
break;
304300
}
305301
searchMode = TAGLIST_SUBPATH;
@@ -309,6 +305,9 @@ bool CViewCommander::Command_TagJumpNoMessage( bool bClose )
309305
if (!GetQuoteFilePath(&pLine[2], strFile, MAX_TAG_PATH)) {
310306
break;
311307
}
308+
if( IsHWNDTag(&pLine[2], strJumpToFile) ){
309+
break;
310+
}
312311
searchMode = TAGLIST_SUBPATH;
313312
}else if( pLine[1] == L'(' ){
314313
// ファイル毎(WZ風)
@@ -322,11 +321,10 @@ bool CViewCommander::Command_TagJumpNoMessage( bool bClose )
322321
// ・subpath\FileName.ext(123,45): str
323322
// ・:HWND:[01234567](無題)2(123,45): str
324323
int fileEnd = GetLineColumnPos(pLine);
325-
if( 0 < fileEnd && fileEnd - 1 < (int)_countof(szFile) ){
326-
wmemcpy( szFile, pLine + 1, fileEnd - 1 );
327-
szFile[fileEnd - 1] = L'\0';
324+
if (1 < fileEnd && L'(' == pLine[fileEnd] && fileEnd - 1 < MAX_TAG_PATH) {
325+
strFile.assign(pLine + 1, fileEnd - 1);
328326
GetLineColumn( &pLine[fileEnd + 1], &nJumpToLine, &nJumpToColumn );
329-
if( IsHWNDTag(pLine + 1, szJumpToFile) ){
327+
if( IsHWNDTag(pLine + 1, strJumpToFile) ){
330328
break;
331329
}
332330
searchMode = TAGLIST_SUBPATH;
@@ -350,7 +348,7 @@ bool CViewCommander::Command_TagJumpNoMessage( bool bClose )
350348
if( searchMode == TAGLIST_SUBPATH || searchMode == TAGLIST_ROOT ){
351349
continue;
352350
}
353-
if( IsHWNDTag(&pLine[2], szJumpToFile) ){
351+
if( IsHWNDTag(&pLine[2], strJumpToFile) ){
354352
break;
355353
}
356354
// フォルダ毎:ファイル名
@@ -369,7 +367,7 @@ bool CViewCommander::Command_TagJumpNoMessage( bool bClose )
369367
if( searchMode == TAGLIST_ROOT ){
370368
continue;
371369
}
372-
if( IsHWNDTag(&pLine[2], szJumpToFile) ){
370+
if( IsHWNDTag(&pLine[2], strJumpToFile) ){
373371
break;
374372
}
375373
// ファイル毎(WZ風):フルパス
@@ -424,16 +422,16 @@ bool CViewCommander::Command_TagJumpNoMessage( bool bClose )
424422
return false;
425423
}
426424
int nLen = 0;
427-
if( IsHWNDTag(pLine, NULL, &nLen) ){
425+
std::wstring test;
426+
if (IsHWNDTag(pLine, test, &nLen)) {
428427
int nFileEnd = GetLineColumnPos(pLine);
429428
if( nFileEnd ){
430-
auto_memcpy(szJumpToFile, pLine, nLen);
431-
szJumpToFile[nLen] = L'\0';
429+
strJumpToFile.assign(pLine, nLen);
432430
GetLineColumn(&pLine[nFileEnd + 1], &nJumpToLine, &nJumpToColumn);
433431
}
434432
}
435433
}
436-
if( szJumpToFile[0] == L'\0' ){
434+
if (strJumpToFile.empty()) {
437435
//@@@ 2001.12.31 YAZAKI
438436
const wchar_t *p = pLine;
439437
const wchar_t *p_end = p + nLineLen;
@@ -470,8 +468,6 @@ bool CViewCommander::Command_TagJumpNoMessage( bool bClose )
470468
// Apr. 21, 2003 genta bClose追加
471469
if (strJumpToFile.empty() == false &&
472470
m_pCommanderView->TagJumpSub(strJumpToFile.c_str(), CMyPoint(nJumpToColumn, nJumpToLine), bClose ) ){ //@@@ 2003.04.13
473-
std::wstring tstrFile = szJumpToFile;
474-
if( m_pCommanderView->TagJumpSub( tstrFile.c_str(), CMyPoint(nJumpToColumn, nJumpToLine), bClose ) ){ //@@@ 2003.04.13
475471
return true;
476472
}
477473

sakura_core/view/CEditView_Command.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ bool CEditView::TagJumpSub(
6161
bool* pbJumpToSelf //!< [out] オプションNULL可。自分にジャンプしたか
6262
)
6363
{
64-
HWND hwndOwner;
64+
HWND hwndOwner = NULL;
6565
POINT poCaret;
6666
// 2004/06/21 novice タグジャンプ機能追加
6767
TagJump tagJump;

0 commit comments

Comments
 (0)