Code enhancement

Fix parentheses, misleading-indentation, sign-compare, some conversion-null warnings.

Fix #12139, close #12140
This commit is contained in:
ozone10 2022-09-10 14:53:19 +02:00 committed by Don Ho
parent 42d863dd9f
commit 2da5c5b393
12 changed files with 39 additions and 39 deletions

View File

@ -333,7 +333,7 @@ const wchar_t * WcharMbcsConvertor::char2wchar(const char * mbcs2Convert, size_t
return nullptr;
// Do not process empty strings
if (lenMbcs == 0 || lenMbcs == -1 && mbcs2Convert[0] == 0)
if (lenMbcs == 0 || (lenMbcs == -1 && mbcs2Convert[0] == 0))
{
_wideCharStr.empty();
return _wideCharStr;

View File

@ -509,7 +509,7 @@ private:
}
void bookmarkDelete(size_t lineno) const {
if (lineno == -1)
if (lineno == static_cast<size_t>(-1))
lineno = _pEditView->getCurrentLineNumber();
while (bookmarkPresent(lineno))
_pEditView->execute(SCI_MARKERDELETE, lineno, MARK_BOOKMARK);

View File

@ -42,7 +42,7 @@ namespace // anonymous
{
static EolType getEOLFormatForm(const char* const data, size_t length, EolType defvalue = EolType::osdefault)
{
assert(length == 0 or data != nullptr && "invalid buffer for getEOLFormatForm()");
assert(length == 0 || (data != nullptr && "invalid buffer for getEOLFormatForm()"));
for (size_t i = 0; i != length; ++i)
{

View File

@ -329,7 +329,7 @@ size_t Printer::doPrint(bool justDoIt)
while (lengthPrinted < lengthDoc)
{
bool printPage = (!(_pdlg.Flags & PD_PAGENUMS) ||
(pageNum >= _pdlg.nFromPage) && (pageNum <= _pdlg.nToPage));
((pageNum >= _pdlg.nFromPage) && (pageNum <= _pdlg.nToPage)));
if (!justDoIt)
printPage = false;

View File

@ -2227,7 +2227,7 @@ void ScintillaEditView::fold(size_t line, bool mode)
{
execute(SCI_TOGGLEFOLD, headerLine);
SCNotification scnN;
SCNotification scnN{};
scnN.nmhdr.code = SCN_FOLDINGSTATECHANGED;
scnN.nmhdr.hwndFrom = _hSelf;
scnN.nmhdr.idFrom = 0;

View File

@ -635,12 +635,12 @@ void Utf16_Iter::operator++()
m_eState = eStart;
} else if (m_nCur16 < 0x800) {
pushout(static_cast<ubyte>(0xC0 | m_nCur16 >> 6));
pushout(0x80 | m_nCur16 & 0x3f);
pushout(0x80 | (m_nCur16 & 0x3f));
m_eState = eStart;
} else {
pushout(0xE0 | (m_nCur16 >> 12));
pushout(0x80 | (m_nCur16 >> 6) & 0x3f);
pushout(0x80 | m_nCur16 & 0x3f);
pushout(0x80 | ((m_nCur16 >> 6) & 0x3f));
pushout(0x80 | (m_nCur16 & 0x3f));
m_eState = eStart;
}
break;
@ -649,10 +649,10 @@ void Utf16_Iter::operator++()
if ((m_nCur16 >= 0xDC00) && (m_nCur16 < 0xE000))
{ // valid surrogate pair
UINT code = 0x10000 + ((m_highSurrogate & 0x3ff) << 10) + (m_nCur16 & 0x3ff);
pushout(0xf0 | (code >> 18) & 0x07);
pushout(0x80 | (code >> 12) & 0x3f);
pushout(0x80 | (code >> 6) & 0x3f);
pushout(0x80 | code & 0x3f);
pushout(0xf0 | ((code >> 18) & 0x07));
pushout(0x80 | ((code >> 12) & 0x3f));
pushout(0x80 | ((code >> 6) & 0x3f));
pushout(0x80 | (code & 0x3f));
}
m_eState = eStart;
break;

View File

@ -926,7 +926,7 @@ intptr_t CALLBACK EditingSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
{
svp._currentLineFrameWidth = static_cast<unsigned char>(::SendMessage(hCaretLineFrameSlider, TBM_GETPOS, 0, 0));
::SetDlgItemInt(_hSelf, IDC_CARETLINEFRAME_WIDTH_DISPLAY, svp._currentLineFrameWidth, FALSE);
::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_CARETLINEFRAME, NULL, svp._currentLineFrameWidth);
::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_CARETLINEFRAME, 0, svp._currentLineFrameWidth);
}
return 0; //return zero when handled

View File

@ -40,7 +40,7 @@ public:
virtual void init(HINSTANCE hInst, HWND parent, int treeViewID);
virtual void destroy();
HTREEITEM addItem(const TCHAR *itemName, HTREEITEM hParentItem, int iImage, LPARAM lParam = NULL);
HTREEITEM addItem(const TCHAR *itemName, HTREEITEM hParentItem, int iImage, LPARAM lParam = 0);
bool setItemParam(HTREEITEM Item2Set, LPARAM param);
LPARAM getItemParam(HTREEITEM Item2Get) const;
generic_string getItemDisplayName(HTREEITEM Item2Set) const;

View File

@ -195,8 +195,8 @@ float JapaneseContextAnalysis::GetConfidence(void)
PRInt32 SJISContextAnalysis::GetOrder(const char* str, PRUint32 *charLen)
{
//find out current char's byte length
if ((unsigned char)*str >= (unsigned char)0x81 && (unsigned char)*str <= (unsigned char)0x9f ||
(unsigned char)*str >= (unsigned char)0xe0 && (unsigned char)*str <= (unsigned char)0xfc )
if (((unsigned char)*str >= (unsigned char)0x81 && (unsigned char)*str <= (unsigned char)0x9f) ||
((unsigned char)*str >= (unsigned char)0xe0 && (unsigned char)*str <= (unsigned char)0xfc))
*charLen = 2;
else
*charLen = 1;
@ -213,8 +213,8 @@ PRInt32 EUCJPContextAnalysis::GetOrder(const char* str, PRUint32 *charLen)
{
//find out current char's byte length
if ((unsigned char)*str == (unsigned char)0x8e ||
(unsigned char)*str >= (unsigned char)0xa1 &&
(unsigned char)*str <= (unsigned char)0xfe)
((unsigned char)*str >= (unsigned char)0xa1 &&
(unsigned char)*str <= (unsigned char)0xfe))
*charLen = 2;
else if ((unsigned char)*str == (unsigned char)0x8f)
*charLen = 3;