OSDN Git Service

Use std::stoi() instead of string_stoi()
authorsdottaka <sdottaka@users.sourceforge.net>
Sun, 20 Sep 2015 03:55:21 +0000 (12:55 +0900)
committersdottaka <sdottaka@users.sourceforge.net>
Sun, 20 Sep 2015 03:55:21 +0000 (12:55 +0900)
Src/Common/UnicodeString.cpp
Src/Common/UnicodeString.h
Src/MergeCmdLineInfo.cpp
Src/MergeEditView.cpp
Src/PatchDlg.cpp
Src/PropEditor.cpp
Src/TempFile.cpp

index 9305b0c..676c45b 100644 (file)
@@ -228,23 +228,3 @@ String string_format_string2(const String& fmt, const String& arg1, const String
        const String* args[] = {&arg1, &arg2};
        return string_format_strings(fmt, args, 2);
 }
-
-int string_stoi(const String& str, size_t *idx/* = 0*/, int base/* = 10*/)
-{
-       int val;
-       const TCHAR *begin = str.c_str();
-       TCHAR *endptr = NULL;
-#ifdef _UNICODE
-       val = wcstol(begin, &endptr, base);
-#else
-       val = strtol(begin, &endptr, base);
-#endif
-       if (endptr == begin)
-               throw std::invalid_argument("string_stoi");
-       else if (errno == ERANGE)
-               throw std::out_of_range("string_stoi");
-       if (idx)
-               *idx = endptr - begin;
-       return val;
-}
-
index 7828b6e..59639fe 100644 (file)
@@ -75,8 +75,6 @@ String string_format_strings(const String& fmt, const String *args[], size_t nar
 String string_format_string1(const String& fmt, const String& arg1);
 String string_format_string2(const String& fmt, const String& arg1, const String& arg2);
 
-int string_stoi(const String& str, size_t *idx = 0, int base = 10);
-
 template <class InputIterator>
 String string_join(const InputIterator& begin, const InputIterator& end, const String& delim)
 {
index 2beb444..a4b5655 100644 (file)
@@ -418,7 +418,7 @@ void MergeCmdLineInfo::ParseWinMergeCmdLine(const TCHAR *q)
                {
                        String codepage;
                        q = EatParam(q, codepage);
-                       try { m_nCodepage = string_stoi(codepage); } catch (...) { /* FIXME: */ }
+                       try { m_nCodepage = std::stoi(codepage); } catch (...) { /* FIXME: */ }
                }
                else if (param == _T("ignorews"))
                {
index d646783..05517f4 100644 (file)
@@ -2862,7 +2862,7 @@ void CMergeEditView::OnWMGoto()
                pCurrentView = GetGroupView(m_nThisPane);
 
                int num = 0;
-               try { num = string_stoi(dlg.m_strParam) - 1; } catch(...) {}
+               try { num = std::stoi(dlg.m_strParam) - 1; } catch(...) {}
 
                if (dlg.m_nGotoWhat == 0)
                {
index 3ddf451..1f6cbca 100644 (file)
@@ -181,7 +181,7 @@ void CPatchDlg::OnOK()
        {
                String contextText;
                m_comboContext.GetLBText(contextSel, PopString(contextText));
-               m_contextLines = string_stoi(contextText);
+               m_contextLines = std::stoi(contextText);
        }
        else
                m_contextLines = 0;
index 6db6416..c004080 100644 (file)
@@ -176,7 +176,7 @@ void PropEditor::OnEnKillfocusTabEdit()
        String valueAsText;
        pEdit->GetWindowText(PopString(valueAsText));
        int value = 0;
-       try { value = string_stoi(valueAsText); } catch (...) {};       
+       try { value = std::stoi(valueAsText); } catch (...) {}; 
        if (value < 1 || value > MAX_TABSIZE)
        {
                String msg = string_format_string1(
index 5b261be..7cca384 100644 (file)
@@ -177,7 +177,7 @@ static bool CleanupWMtempfolder(const vector <int>& processIDs)
                        // Check if this instance of WM is still running
                        try
                        {
-                               int pid = string_stoi(tempfolderPID);
+                               int pid = std::stoi(tempfolderPID);
                                if (!WMrunning(processIDs, pid))
                                {
                                        tempfolderPID = paths_ConcatPath(paths_GetParentPath(pattern), ff.cFileName);