OSDN Git Service

Remove warning C4239: nonstandard extension used
authorGreyMerlin <GreyMerlin7@gmail.com>
Wed, 27 Dec 2017 22:31:07 +0000 (14:31 -0800)
committerGreyMerlin <GreyMerlin7@gmail.com>
Wed, 27 Dec 2017 23:00:10 +0000 (15:00 -0800)
 * Eliminate warnings such as ...
`warning C4239: nonstandard extension used: 'argument': conversion
from 'DirItemIterator' to 'DirItemIterator &'`
`note: A non-const reference may only be bound to an lvalue`
 * These are warnings that only occur with Warning Level == 4.

 * This commit only deals with issues with mixing CString and String
data.
 * Discard the PopString class, a self-admitted hack from
stackoverflow.com, that was simply confusing and not all that "pretty"
anyway.

Src/Common/BCMenu.cpp
Src/DDXHelper.h
Src/DirCmpReportDlg.cpp
Src/MergeDoc.cpp
Src/OpenView.cpp
Src/PatchDlg.cpp
Src/SelectUnpackerDlg.cpp
Src/TrDialogs.h

index 1c673c5..0a18c67 100644 (file)
@@ -399,7 +399,8 @@ void BCMenu::DrawItem_Win9xNT2000 (LPDRAWITEMSTRUCT lpDIS)
                        }
                        else{
                                if(state&ODS_CHECKED){
-                                       pDC->FillRect(rect2,&CBrush(LightenColor(clrBack,0.6)));
+                                       CBrush cbTemp = LightenColor(clrBack, 0.6);
+                                       pDC->FillRect(rect2,&cbTemp);
                                        rect2.SetRect(rect.left,rect.top+dy,rect.left+m_iconX+4,
                         rect.top+m_iconY+4+dy);
                                        pDC->Draw3dRect(rect2,GetSysColor(COLOR_3DSHADOW),
@@ -1668,7 +1669,8 @@ void BCMenu::GetTransparentBitmap(CBitmap &bmp)
        col=RGB(255,0,255); // Original was RGB(192,192,192)
        CBitmap * pddcOldBmp2 = ddc2.SelectObject(&bmp2);
        CRect rect(0,0,BitMap.bmWidth,BitMap.bmHeight);
-       ddc2.FillRect(rect,&CBrush(col));
+       CBrush cbTemp = col;
+       ddc2.FillRect(rect, &cbTemp);
        ddc2.SelectObject(pddcOldBmp2);
        newcol=GetSysColor(COLOR_3DFACE);
 
@@ -1708,7 +1710,8 @@ void BCMenu::GetDisabledBitmap(CBitmap &bmp,COLORREF background)
        bmp2.CreateCompatibleBitmap(&ddc,BitMap.bmWidth,BitMap.bmHeight);
        CBitmap * pddcOldBmp2 = ddc2.SelectObject(&bmp2);
        CRect rect(0,0,BitMap.bmWidth,BitMap.bmHeight);
-       ddc2.FillRect(rect,&CBrush(GetSysColor(COLOR_3DFACE)));
+       CBrush cbTemp = GetSysColor(COLOR_3DFACE);
+       ddc2.FillRect(rect, &cbTemp);
        ddc2.SelectObject(pddcOldBmp2);
        discol=GetSysColor(COLOR_BTNSHADOW);
 
@@ -1793,7 +1796,8 @@ BOOL BCMenu::Draw3DCheckmark(CDC *dc, const CRect& rc,
        CRect rcDest = rc;
        COLORREF col=GetSysColor(COLOR_MENU);
        if(!bSelected)col = LightenColor(col,0.6);
-       dc->FillRect(rcDest,&CBrush(col));
+       CBrush cbTemp = col;
+       dc->FillRect(rcDest, &cbTemp);
        dc->DrawEdge(&rcDest, BDR_SUNKENOUTER, BF_RECT);
        if (!hbmCheck)DrawCheckMark(dc,rc.left+4,rc.top+4,GetSysColor(COLOR_MENUTEXT));
        else DrawRadioDot(dc,rc.left+5,rc.top+4,GetSysColor(COLOR_MENUTEXT));
index 89c6ff8..90899c5 100644 (file)
@@ -2,24 +2,6 @@
 \r
 #include "UnicodeString.h"\r
 \r
-// from http://stackoverflow.com/questions/6117270/mfc-stdstring-vs-cstring\r
-class PopString : public CString\r
-{\r
-public:\r
-       explicit PopString(String & final) : CString(final.c_str()), m_final(final)\r
-       {\r
-       }\r
-\r
-       ~PopString()\r
-       {\r
-               m_final = (PCTSTR) *this;\r
-       }\r
-private:\r
-       PopString(const PopString &);  // private copy constructor to prevent copying\r
-       PopString & operator=(const PopString &);  // private copy operator\r
-\r
-       String & m_final;\r
-};\r
 \r
 inline void DDX_Check(CDataExchange* pDX, int nIDC, bool& value)\r
 {\r
@@ -37,16 +19,22 @@ inline void DDX_Radio(CDataExchange* pDX, int nIDC, bool& value)
 \r
 inline void DDX_Text(CDataExchange* pDX, int nIDC, String& value)\r
 {\r
-       DDX_Text(pDX, nIDC, PopString(value));\r
+       CString cstrValue = value.c_str();\r
+       DDX_Text(pDX, nIDC, cstrValue);\r
+       value = cstrValue;\r
 }\r
 \r
 inline void DDX_CBString(CDataExchange* pDX, int nIDC, String& value)\r
 {\r
-       DDX_CBString(pDX, nIDC, PopString(value));\r
+       CString cstrValue = value.c_str();\r
+       DDX_CBString(pDX, nIDC, cstrValue);\r
+       value = cstrValue;\r
 }\r
 \r
 inline void DDX_CBStringExact(CDataExchange* pDX, int nIDC, String& value)\r
 {\r
-       DDX_CBStringExact(pDX, nIDC, PopString(value));\r
+       CString cstrValue = value.c_str();\r
+       DDX_CBStringExact(pDX, nIDC, cstrValue);\r
+       value = cstrValue;\r
 }\r
 \r
index 5c05b76..410d5d2 100644 (file)
@@ -117,7 +117,9 @@ BOOL DirCmpReportDlg::OnInitDialog()
 
        // Set selected path to variable so file selection dialog shows
        // correct filename and path.
-       m_ctlReportFile.GetWindowText(PopString(m_sReportFile));
+       CString cstrReportFile;
+       m_ctlReportFile.GetWindowText(cstrReportFile);
+       m_sReportFile = cstrReportFile;
 
        UpdateData(FALSE);
 
index fe8b0fa..573e2cc 100644 (file)
@@ -3177,8 +3177,7 @@ bool CMergeDoc::GenerateReport(const String& sFileName) const
 
        file.SetCodepage(ucr::CP_UTF_8);
 
-       String header = 
-               strutils::format(
+       CString headerText =
                _T("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"\n")
                _T("\t\"http://www.w3.org/TR/html4/loose.dtd\">\n")
                _T("<html>\n")
@@ -3200,8 +3199,9 @@ bool CMergeDoc::GenerateReport(const String& sFileName) const
                _T("<div class=\"border\">")
                _T("<table cellspacing=\"0\" cellpadding=\"0\" style=\"width: 100%%; margin: 0; border: none;\">\n")
                _T("<thead>\n")
-               _T("<tr>\n"),
-               nFontSize, m_pView[0]->GetHTMLStyles());
+               _T("<tr>\n");
+       String header = 
+               strutils::format((LPCTSTR)headerText, nFontSize, (LPCTSTR)m_pView[0]->GetHTMLStyles());
        file.WriteString(header);
 
        // Get paths
index 823b805..4da3bd8 100644 (file)
@@ -744,8 +744,10 @@ void COpenView::OnSelchangeCombo(int index)
        int sel = m_ctlPath[index].GetCurSel();
        if (sel != CB_ERR)
        {
-               m_ctlPath[index].GetLBText(sel, PopString(m_strPath[index]));
-               m_ctlPath[index].SetWindowText(m_strPath[index].c_str());
+               CString cstrPath;
+               m_ctlPath[index].GetLBText(sel, cstrPath);
+               m_strPath[index] = cstrPath;
+               m_ctlPath[index].SetWindowText(cstrPath);
                UpdateData(TRUE);
        }
        UpdateButtonStates();
index 6173386..720676f 100644 (file)
@@ -173,9 +173,9 @@ void CPatchDlg::OnOK()
        int contextSel = m_comboContext.GetCurSel();
        if (contextSel != CB_ERR)
        {
-               String contextText;
-               m_comboContext.GetLBText(contextSel, PopString(contextText));
-               m_contextLines = std::stoi(contextText);
+               CString contextText;
+               m_comboContext.GetLBText(contextSel, contextText);
+               m_contextLines = std::stoi((String)contextText);
        }
        else
                m_contextLines = 0;
@@ -349,8 +349,10 @@ void CPatchDlg::OnSelchangeFile1Combo()
        int sel = m_ctlFile1.GetCurSel();
        if (sel != CB_ERR)
        {
-               m_ctlFile1.GetLBText(sel, PopString(m_file1));
-               m_ctlFile1.SetWindowText(m_file1.c_str());
+               CString cstrFile1 = m_file1.c_str();
+               m_ctlFile1.GetLBText(sel, cstrFile1);
+               m_ctlFile1.SetWindowText(cstrFile1);
+               m_file1 = cstrFile1;
                ChangeFile(m_file1, true);
        }
 }
@@ -363,8 +365,10 @@ void CPatchDlg::OnSelchangeFile2Combo()
        int sel = m_ctlFile2.GetCurSel();
        if (sel != CB_ERR)
        {
-               m_ctlFile2.GetLBText(sel, PopString(m_file2));
-               m_ctlFile2.SetWindowText(m_file2.c_str());
+               CString cstrFile2 = m_file1.c_str();
+               m_ctlFile1.GetLBText(sel, cstrFile2);
+               m_ctlFile1.SetWindowText(cstrFile2);
+               m_file2 = cstrFile2;
                ChangeFile(m_file2, false);
        }
 }
@@ -377,8 +381,10 @@ void CPatchDlg::OnSelchangeResultCombo()
        int sel = m_ctlResult.GetCurSel();
        if (sel != CB_ERR)
        {
-               m_ctlResult.GetLBText(sel, PopString(m_fileResult));
-               m_ctlResult.SetWindowText(m_fileResult.c_str());
+               CString cstrFileResult = m_fileResult.c_str();
+               m_ctlResult.GetLBText(sel, cstrFileResult);
+               m_ctlResult.SetWindowText(cstrFileResult);
+               m_fileResult = cstrFileResult;
        }
 }
 
@@ -415,11 +421,13 @@ void CPatchDlg::OnDiffSwapFiles()
 {
        PATCHFILES files;
 
-       m_ctlFile1.GetWindowText(PopString(m_file1));
-       m_ctlFile2.GetWindowText(PopString(m_file2));
+       CString cstrFile1 = m_file1.c_str();
+       CString cstrFile2 = m_file2.c_str();
+       m_ctlFile1.GetWindowText(cstrFile1);
+       m_ctlFile2.GetWindowText(cstrFile2);
 
-       m_ctlFile1.SetWindowText(m_file2.c_str());
-       m_ctlFile2.SetWindowText(m_file1.c_str());
+       m_ctlFile1.SetWindowText(cstrFile2);
+       m_ctlFile2.SetWindowText(cstrFile1);
 
        //  swapped files
        Swap();
index 4619e60..bd94af9 100644 (file)
@@ -259,7 +259,9 @@ void CSelectUnpackerDlg::OnSelchangeUnpackerName()
                // initialize with the default unpacker
                m_pPlugin = static_cast<PluginInfo*> (m_UnpackerPlugins.GetAt(0));
                PluginInfo * pPlugin;
-               m_cboUnpackerName.GetWindowText(PopString(m_strPluginName));
+               CString cstrPluginName;
+               m_cboUnpackerName.GetWindowText(cstrPluginName);
+               m_strPluginName = cstrPluginName;
                for (int j = 0 ; j < m_UnpackerPlugins.GetSize() ; j++)
                {
                        pPlugin = static_cast<PluginInfo*> (m_UnpackerPlugins.GetAt(j));
index 6eba09e..425d67a 100644 (file)
@@ -23,7 +23,10 @@ public:
 \r
        unsigned GetDlgItemText(unsigned id, String& text)\r
        {\r
-               return dlg()->GetDlgItemTextW(id, PopString(text));\r
+               CString cstrText = text.c_str();\r
+               unsigned uResult = dlg()->GetDlgItemTextW(id, cstrText);\r
+               text = cstrText;\r
+               return uResult;\r
        }\r
 \r
        void SetDlgItemText(unsigned id, const String& text)\r