Code enhancement
Fix parentheses, misleading-indentation, sign-compare, some conversion-null warnings. Fix #12139, close #12140pull/12152/head
parent
42d863dd9f
commit
2da5c5b393
|
@ -130,8 +130,8 @@ int EncodingMapper::getIndexFromEncoding(int encoding) const
|
|||
|
||||
int EncodingMapper::getEncodingFromString(const char *encodingAlias) const
|
||||
{
|
||||
if (isInListA(encodingAlias, "utf-8 utf8"))
|
||||
return SC_CP_UTF8;
|
||||
if (isInListA(encodingAlias, "utf-8 utf8"))
|
||||
return SC_CP_UTF8;
|
||||
|
||||
size_t nbItem = sizeof(encodings)/sizeof(EncodingUnit);
|
||||
int enc = -1;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -1245,7 +1245,7 @@ void Notepad_plus::wsTabConvert(spaceTab whichWay)
|
|||
char * source = new char[docLength];
|
||||
if (source == NULL)
|
||||
return;
|
||||
_pEditView->execute(SCI_GETTEXT, docLength, reinterpret_cast<LPARAM>(source));
|
||||
_pEditView->execute(SCI_GETTEXT, docLength, reinterpret_cast<LPARAM>(source));
|
||||
|
||||
if (whichWay == tab2Space)
|
||||
{
|
||||
|
@ -5648,7 +5648,7 @@ void Notepad_plus::doSynScorll(HWND whichView)
|
|||
intptr_t pixel;
|
||||
intptr_t mainColumn, subColumn;
|
||||
|
||||
if (whichView == _mainEditView.getHSelf())
|
||||
if (whichView == _mainEditView.getHSelf())
|
||||
{
|
||||
if (_syncInfo._isSynScollV)
|
||||
{
|
||||
|
@ -5670,9 +5670,9 @@ void Notepad_plus::doSynScorll(HWND whichView)
|
|||
column = mainColumn - _syncInfo._column - subColumn;
|
||||
}
|
||||
pView = &_subEditView;
|
||||
}
|
||||
else if (whichView == _subEditView.getHSelf())
|
||||
{
|
||||
}
|
||||
else if (whichView == _subEditView.getHSelf())
|
||||
{
|
||||
if (_syncInfo._isSynScollV)
|
||||
{
|
||||
// Compute for Line
|
||||
|
@ -5693,9 +5693,9 @@ void Notepad_plus::doSynScorll(HWND whichView)
|
|||
column = subColumn + _syncInfo._column - mainColumn;
|
||||
}
|
||||
pView = &_mainEditView;
|
||||
}
|
||||
else
|
||||
return;
|
||||
}
|
||||
else
|
||||
return;
|
||||
|
||||
pView->scroll(column, line);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -329,10 +329,10 @@ 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;
|
||||
printPage = false;
|
||||
|
||||
TCHAR pageString[32];
|
||||
wsprintf(pageString, TEXT("%0d"), pageNum);
|
||||
|
|
|
@ -2205,11 +2205,11 @@ bool ScintillaEditView::isCurrentLineFolded() const
|
|||
|
||||
void ScintillaEditView::fold(size_t line, bool mode)
|
||||
{
|
||||
auto endStyled = execute(SCI_GETENDSTYLED);
|
||||
auto len = execute(SCI_GETTEXTLENGTH);
|
||||
auto endStyled = execute(SCI_GETENDSTYLED);
|
||||
auto len = execute(SCI_GETTEXTLENGTH);
|
||||
|
||||
if (endStyled < len)
|
||||
execute(SCI_COLOURISE, 0, -1);
|
||||
if (endStyled < len)
|
||||
execute(SCI_COLOURISE, 0, -1);
|
||||
|
||||
intptr_t headerLine;
|
||||
auto level = execute(SCI_GETFOLDLEVEL, line);
|
||||
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -130,11 +130,11 @@ nsresult nsUniversalDetector::HandleData(const char* aBuf, PRUint32 aLen)
|
|||
break;
|
||||
} // switch
|
||||
|
||||
if (mDetectedCharset)
|
||||
{
|
||||
mDone = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
if (mDetectedCharset)
|
||||
{
|
||||
mDone = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
PRUint32 i;
|
||||
|
|
Loading…
Reference in New Issue