Skip to content

Commit

Permalink
Remove return value for EditReplace*() functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
zufuliu committed Dec 9, 2024
1 parent 5bbf685 commit d32be51
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 33 deletions.
48 changes: 18 additions & 30 deletions src/Edit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3613,9 +3613,8 @@ void EditStripTrailingBlanks(HWND hwnd, bool bIgnoreSelection) noexcept {
efrTrim.hwnd = hwnd;
efrTrim.fuFlags = SCFIND_REGEXP;
memcpy(efrTrim.szFind, "[ \t]+$", CSTRLEN("[ \t]+$"));
if (EditReplaceAllInSelection(hwnd, &efrTrim, false)) {
return;
}
EditReplaceAllInSelection(hwnd, &efrTrim);
return;
}
}

Expand Down Expand Up @@ -3654,9 +3653,8 @@ void EditStripLeadingBlanks(HWND hwnd, bool bIgnoreSelection) noexcept {
efrTrim.hwnd = hwnd;
efrTrim.fuFlags = SCFIND_REGEXP;
memcpy(efrTrim.szFind, "^[ \t]+", CSTRLEN("^[ \t]+"));
if (EditReplaceAllInSelection(hwnd, &efrTrim, false)) {
return;
}
EditReplaceAllInSelection(hwnd, &efrTrim);
return;
}
}

Expand Down Expand Up @@ -5048,7 +5046,7 @@ static INT_PTR CALLBACK EditFindReplaceDlgProc(HWND hwnd, UINT umsg, WPARAM wPar
EditFindAll(lpefr, true);
} else {
bReplaceInitialized = true;
EditReplaceAll(lpefr->hwnd, lpefr, true);
EditReplaceAll(lpefr->hwnd, lpefr);
}
break;

Expand Down Expand Up @@ -5365,13 +5363,13 @@ void EditFindPrev(const EDITFINDREPLACE *lpefr, bool fExtendSelection) noexcept
//
// EditReplace()
//
bool EditReplace(HWND hwnd, const EDITFINDREPLACE *lpefr) noexcept {
void EditReplace(HWND hwnd, const EDITFINDREPLACE *lpefr) noexcept {
BOOL bReplaceRE;
char szFind2[NP2_FIND_REPLACE_LIMIT];
char *pszReplace2;
const int searchFlags = EditPrepareReplace(hwnd, szFind2, &pszReplace2, &bReplaceRE, lpefr);
if (searchFlags == NP2_InvalidSearchFlags) {
return false;
return;
}

const Sci_Position iSelStart = SciCall_GetSelectionStart();
Expand All @@ -5396,17 +5394,18 @@ bool EditReplace(HWND hwnd, const EDITFINDREPLACE *lpefr) noexcept {
if (!bSuppressNotFound) {
InfoBoxWarn(MB_OK, L"MsgNotFound", IDS_NOTFOUND);
}
return false;
return;
}

if (iSelStart != ttf.chrgText.cpMin || iSelEnd != ttf.chrgText.cpMax) {
LocalFree(pszReplace2);
EditSelectEx(ttf.chrgText.cpMin, ttf.chrgText.cpMax);
return false;
return;
}

SciCall_SetTargetRange(ttf.chrgText.cpMin, ttf.chrgText.cpMax);
SciCall_ReplaceTargetEx(bReplaceRE, -1, pszReplace2);
LocalFree(pszReplace2);

ttf.chrg.cpMin = SciCall_GetTargetEnd();
ttf.chrg.cpMax = SciCall_GetLength();
Expand All @@ -5432,9 +5431,6 @@ bool EditReplace(HWND hwnd, const EDITFINDREPLACE *lpefr) noexcept {
InfoBoxWarn(MB_OK, L"MsgNotFound", IDS_NOTFOUND);
}
}

LocalFree(pszReplace2);
return true;
}

//=============================================================================
Expand Down Expand Up @@ -5778,13 +5774,13 @@ static void ShwowReplaceCount(Sci_Position iCount) noexcept {
//
// EditReplaceAll()
//
bool EditReplaceAll(HWND hwnd, const EDITFINDREPLACE *lpefr, bool bShowInfo) noexcept {
void EditReplaceAll(HWND hwnd, const EDITFINDREPLACE *lpefr) noexcept {
BOOL bReplaceRE;
char szFind2[NP2_FIND_REPLACE_LIMIT];
char *pszReplace2;
const int searchFlags = EditPrepareReplace(hwnd, szFind2, &pszReplace2, &bReplaceRE, lpefr);
if (searchFlags == NP2_InvalidSearchFlags) {
return false;
return;
}

// Show wait cursor...
Expand Down Expand Up @@ -5845,31 +5841,26 @@ bool EditReplaceAll(HWND hwnd, const EDITFINDREPLACE *lpefr, bool bShowInfo) noe

// Remove wait cursor
EndWaitCursor();

if (bShowInfo) {
ShwowReplaceCount(iCount);
}

LocalFree(pszReplace2);
return true;
ShwowReplaceCount(iCount);
}

//=============================================================================
//
// EditReplaceAllInSelection()
//
bool EditReplaceAllInSelection(HWND hwnd, const EDITFINDREPLACE *lpefr, bool bShowInfo) noexcept {
void EditReplaceAllInSelection(HWND hwnd, const EDITFINDREPLACE *lpefr, bool bShowInfo) noexcept {
if (SciCall_IsRectangleSelection()) {
NotifyRectangleSelection();
return false;
return;
}

BOOL bReplaceRE;
char szFind2[NP2_FIND_REPLACE_LIMIT];
char *pszReplace2;
const int searchFlags = EditPrepareReplace(hwnd, szFind2, &pszReplace2, &bReplaceRE, lpefr);
if (searchFlags == NP2_InvalidSearchFlags) {
return false;
return;
}

// Show wait cursor...
Expand Down Expand Up @@ -5939,13 +5930,10 @@ bool EditReplaceAllInSelection(HWND hwnd, const EDITFINDREPLACE *lpefr, bool bSh

// Remove wait cursor
EndWaitCursor();

LocalFree(pszReplace2);
if (bShowInfo) {
ShwowReplaceCount(iCount);
}

LocalFree(pszReplace2);
return true;
}

//=============================================================================
Expand Down Expand Up @@ -6635,7 +6623,7 @@ void EditUpdateTimestampMatchTemplate(HWND hwnd) noexcept {
if (!SciCall_IsSelectionEmpty()) {
EditReplaceAllInSelection(hwnd, &efrTS, true);
} else {
EditReplaceAll(hwnd, &efrTS, true);
EditReplaceAll(hwnd, &efrTS);
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/Edit.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,9 @@ HWND EditFindReplaceDlg(HWND hwnd, EDITFINDREPLACE *lpefr, bool bReplace) noexce
void EditFindNext(const EDITFINDREPLACE *lpefr, bool fExtendSelection) noexcept;
void EditFindPrev(const EDITFINDREPLACE *lpefr, bool fExtendSelection) noexcept;
void EditFindAll(const EDITFINDREPLACE *lpefr, bool selectAll) noexcept;
bool EditReplace(HWND hwnd, const EDITFINDREPLACE *lpefr) noexcept;
bool EditReplaceAll(HWND hwnd, const EDITFINDREPLACE *lpefr, bool bShowInfo) noexcept;
bool EditReplaceAllInSelection(HWND hwnd, const EDITFINDREPLACE *lpefr, bool bShowInfo) noexcept;
void EditReplace(HWND hwnd, const EDITFINDREPLACE *lpefr) noexcept;
void EditReplaceAll(HWND hwnd, const EDITFINDREPLACE *lpefr) noexcept;
void EditReplaceAllInSelection(HWND hwnd, const EDITFINDREPLACE *lpefr, bool bShowInfo = false) noexcept;
bool EditLineNumDlg(HWND hwnd) noexcept;
void EditModifyLinesDlg(HWND hwnd) noexcept;
void EditEncloseSelectionDlg(HWND hwnd) noexcept;
Expand Down

0 comments on commit d32be51

Please sign in to comment.