OSDN Git Service

Reduce Level 4 Build Warnings (6)
authorGreyMerlin <GreyMerlin@gmail.com>
Thu, 26 Jul 2018 22:00:17 +0000 (15:00 -0700)
committerGreyMerlin <GreyMerlin@gmail.com>
Thu, 26 Jul 2018 22:00:17 +0000 (15:00 -0700)
* cleanup a funny std::transform() warning by simply inlining the code
(DiffWrapper.cpp)
* Make Bomsize calculation less obscure (io.c)
* Misc casting

Externals/crystaledit/editlib/ccrystaltextview.cpp
Externals/poco/Foundation/include/Poco/String.h
Src/DiffWrapper.cpp
Src/diffutils/src/io.c

index 917d402..9327366 100644 (file)
@@ -1308,7 +1308,7 @@ GetParseCookie (int nLineIndex)
   if (m_ParseCookies->size() == 0)
     {
       // must be initialized to invalid value (DWORD) -1
-      m_ParseCookies->assign(nLineCount, -1);
+      m_ParseCookies->assign(nLineCount, (DWORD)-1);
     }
 
   if (nLineIndex < 0)
@@ -4384,7 +4384,7 @@ UpdateView (CCrystalTextView * pSource, CUpdateContext * pContext,
           ASSERT (cookiesSize == nLineCount);
           // must be reinitialized to invalid value (DWORD) - 1
           for (int i = nLineIndex; i < cookiesSize; ++i)
-            (*m_ParseCookies)[i] = -1;
+            (*m_ParseCookies)[i] = (DWORD)-1;
         }
       //  This line'th actual length must be recalculated
       if (m_pnActualLineLength->size())
@@ -4419,10 +4419,10 @@ UpdateView (CCrystalTextView * pSource, CUpdateContext * pContext,
               arrSize = nLineCount;
               // must be initialized to invalid value (DWORD) - 1
               for (size_t i = oldsize; i < arrSize; ++i)
-                (*m_ParseCookies)[i] = -1;
+                (*m_ParseCookies)[i] = (DWORD)-1;
             }
           for (size_t i = nLineIndex; i < arrSize; ++i)
-            (*m_ParseCookies)[i] = -1;
+            (*m_ParseCookies)[i] = (DWORD)-1;
         }
 
       //  Recalculate actual length for all lines below this
index 98f75a9..7f0a4f8 100644 (file)
@@ -228,8 +228,8 @@ int icompare(const S& str1, const S& str2)
        typename S::const_iterator end2(str2.end());
        while (it1 != end1 && it2 != end2)
        {
-        typename S::value_type c1(Ascii::toLower(*it1));
-        typename S::value_type c2(Ascii::toLower(*it2));
+        typename S::value_type c1(static_cast<typename S::value_type>(Ascii::toLower(*it1)));
+        typename S::value_type c2(static_cast<typename S::value_type>(Ascii::toLower(*it2)));
         if (c1 < c2)
             return -1;
         else if (c1 > c2)
index d5a9d9f..1cc61b3 100644 (file)
@@ -28,6 +28,8 @@
 #include <sys/stat.h>
 #include <algorithm>
 #include <string>
+#include <cctype>
+#include <cwctype>
 #include <map>
 #include <cassert>
 #include <exception>
@@ -286,7 +288,7 @@ bool CDiffWrapper::IsTrivialLine(const std::string &Line,
                return false;//In no Start and End pair, and no single in-line set, then it's not trivial
 
        if (StartOfComment == Line.c_str() &&
-               ((EndOfComment + filtercommentsset.EndMarker.size()) - StartOfComment) == Line.size())
+               static_cast<size_t>((EndOfComment + filtercommentsset.EndMarker.size()) - StartOfComment) == Line.size())
        {//If entire line is blocked by End and Start markers, then entire line is trivial
                return true;
        }
@@ -622,8 +624,12 @@ void CDiffWrapper::PostFilter(int LineNumberLeft, int QtyLinesLeft, int LineNumb
                        if (m_options.m_bIgnoreCase)
                        {
                                //ignore case
-                               std::transform(LineDataLeft.begin(),  LineDataLeft.end(),  LineDataLeft.begin(),  ::toupper);
-                               std::transform(LineDataRight.begin(), LineDataRight.end(), LineDataRight.begin(), ::toupper);
+                               // std::transform(LineDataLeft.begin(),  LineDataLeft.end(),  LineDataLeft.begin(),  ::toupper);
+                               for (std::basic_string<char>::iterator pb = LineDataLeft.begin(), pe = LineDataLeft.end(); pb != pe; ++pb) 
+                                       *pb = static_cast<char>(::toupper(*pb)); 
+                               // std::transform(LineDataRight.begin(), LineDataRight.end(), LineDataRight.begin(), ::toupper);
+                               for (std::basic_string<char>::iterator pb = LineDataRight.begin(), pe = LineDataRight.end(); pb != pe; ++pb) 
+                                       *pb = static_cast<char>(::toupper(*pb)); 
                        }
 
                        if (!LineDataLeft.empty())
index dc5b51f..1e0271c 100644 (file)
@@ -78,7 +78,7 @@ static DECL_TLS int equivs_alloc;
 static void find_and_hash_each_line (struct file_data *);
 static void find_identical_ends (struct file_data[]);
 static char *prepare_text_end (struct file_data *, short);
-static enum UNICODESET get_unicode_signature(struct file_data *, unsigned *bom);
+static enum UNICODESET get_unicode_signature(struct file_data *, int *pBomsize);
 
 /* Check for binary files and compare them for exact identity.  */
 
@@ -88,7 +88,7 @@ static enum UNICODESET get_unicode_signature(struct file_data *, unsigned *bom);
 #define binary_file_p(buf, size) (size != 0 && memchr (buf, '\0', size) != 0)
 
 /** @brief Get unicode signature from file_data. */
-static enum UNICODESET get_unicode_signature(struct file_data *current, unsigned *bom)
+static enum UNICODESET get_unicode_signature(struct file_data *current, int *pBomsize)
 {
   // initialize to a pattern that differs everywhere from all possible unicode signatures
   unsigned long sig = 0x3F3F3F3F;
@@ -96,7 +96,7 @@ static enum UNICODESET get_unicode_signature(struct file_data *current, unsigned
   memcpy(&sig, current->buffer, min(current->buffered_chars, 4));
   // check for the two possible 4 bytes signatures
   int tmp;
-  int *bomsize = bom ? bom : &tmp;
+  int *bomsize = pBomsize ? pBomsize : &tmp;
   
   if (sig == 0x0000FEFF)
     {
@@ -481,9 +481,9 @@ prepare_text_end (struct file_data *current, short side)
   char *const p = current->buffer;
   char *r = p; // receives the return value
   char *q0, *t;
-  unsigned bom = 0;
-  enum UNICODESET sig = get_unicode_signature(current, &bom);
-  char *const u0 = p + bom;
+  int bomsize = 0;
+  enum UNICODESET sig = get_unicode_signature(current, &bomsize);
+  char *const u0 = p + bomsize;
 
   if (sig == UCS4LE)
     {