OSDN Git Service

Cppcheck: The scope of the variable '...' can be reduced.
authorTakashi Sawanaka <sdottaka@users.sourceforge.net>
Tue, 14 Apr 2020 22:58:23 +0000 (07:58 +0900)
committerTakashi Sawanaka <sdottaka@users.sourceforge.net>
Tue, 14 Apr 2020 22:58:23 +0000 (07:58 +0900)
Externals/crystaledit/editlib/ccrystaltextview.cpp
Externals/crystaledit/editlib/crystalparser.cpp
Externals/crystaledit/editlib/cs2cs.cpp
Src/Common/RegOptionsMgr.cpp

index 43747ca..588f23a 100644 (file)
@@ -3803,7 +3803,7 @@ ClientToText (const CPoint & point)
   if (nPos < 0)
     nPos = 0;
 
-  int nIndex = 0, nPrevIndex = 0;
+  int nIndex = 0;
   int nCurPos = 0;
   int n = 0;
   int i = 0;
@@ -3829,8 +3829,6 @@ ClientToText (const CPoint & point)
       if (n > nPos && i == nSubLineOffset)
         break;
 
-      nPrevIndex = nIndex;
-
       nIndex = pIterChar->next();
     }
 
index dd6d389..ee1856d 100644 (file)
@@ -62,14 +62,13 @@ void CCrystalParser::WrapLine( int nLineIndex, int nMaxLineWidth, int *anBreaks,
        int                     nLastBreakPos = 0;
        int                     nLastCharBreakPos = 0;
        bool            bBreakable = false;
-       TCHAR           ch;
        WORD            wCharType;
 
 //    m_iterChar.setText(reinterpret_cast<const UChar *>(szLine), nLineLength);
 //    for( int i = 0; i < nLineLength; i = m_iterChar.next())
     for( int i = 0; i < nLineLength; i += U16_IS_SURROGATE(szLine[i]) ? 2 : 1)
        {
-               ch = szLine[i]; 
+               TCHAR ch = szLine[i]; 
                // remember position of whitespace for wrap
                if( bBreakable )
                {
index 7057115..afeacb0 100644 (file)
@@ -110,10 +110,8 @@ skip_word (LPCTSTR s)
 ptrdiff_t
 get_coding (LPCTSTR name, type_codes *codes, int *coding)
 {
-  size_t pos;
-
   for (int i = 0; i < codes_count; i++)
-    if ((pos = str_pos (name, codes[i].name)) >= 0)
+    if (size_t pos; (pos = str_pos (name, codes[i].name)) >= 0)
       {
         *coding = i;
         return pos;
@@ -180,7 +178,6 @@ TCHAR iconvert_char (TCHAR ch, int source_coding, int destination_coding, bool a
 int
 iconvert (LPTSTR string, int source_coding, int destination_coding, bool alphabet_only)
   {
-    ptrdiff_t posit = -2;
     LPCTSTR source_chars, destination_chars, cod_pos = nullptr;
     TCHAR ch;
     LPTSTR s = string;
@@ -189,7 +186,7 @@ iconvert (LPTSTR string, int source_coding, int destination_coding, bool alphabe
       return -1;
     if (source_coding < 0)
       {
-        posit = fget_coding (string, &source_coding);
+        ptrdiff_t posit = fget_coding (string, &source_coding);
         if (posit != 0)
           cod_pos = string + posit;
       }
index c3831d2..d93d819 100644 (file)
@@ -306,12 +306,14 @@ int CRegOptionsMgr::InitOption(const String& name, const varprop::VariantValue&
        // This just checks if the value exists, LoadValueFromReg() below actually
        // loads the value.
        DWORD type = 0;
-       BYTE dataBuf[MAX_PATH_FULL] = {0};
        DWORD size = MAX_PATH_FULL;
        LONG retValReg;
        if (hKey)
+       {
+               BYTE dataBuf[MAX_PATH_FULL] = {0};
                retValReg = RegQueryValueEx(hKey, strValueName.c_str(),
                        0, &type, dataBuf, &size);
+       }
        else
                retValReg = ERROR_FILE_NOT_FOUND;