What changed
Bitcoin v0.2.7 → v0.2.8
Release commit message: Mac OS build fixes by laszlo -- version 0.2.8
Previous diff: v0.2.6 → v0.2.7. Next: v0.2.8 → v0.2.9.
- headers.h modified · +4 −4
- init.cpp modified · +7 −1
- irc.cpp modified · +4 −1
- main.cpp modified · +4 −4
- makefile.vc modified · +9 −9
- net.cpp modified · +1 −3
- net.h modified · +28 −17
- rpc.cpp modified · +15 −10
- serialize.h modified · +1 −1
- ui.cpp modified · +12 −3
- uibase.cpp modified · +7 −7
- uibase.h modified · +22 −23
- util.cpp modified · +20 −8
- util.h modified · +1 −0
headers.h (modified)
1--- v0.2.7/headers.h2+++ v0.2.8/headers.h3@@ -19,11 +19,11 @@4 #define WIN32_LEAN_AND_MEAN 15 #define __STDC_LIMIT_MACROS // to enable UINT64_MAX from stdint.h6 #include <wx/wx.h>7+#include <wx/stdpaths.h>8+#include <wx/snglinst.h>9+#if wxUSE_GUI10+#include <wx/utils.h>11 #include <wx/clipbrd.h>12-#include <wx/snglinst.h>13-#include <wx/stdpaths.h>14-#include <wx/utils.h>15-#if wxUSE_GUI16 #include <wx/taskbar.h>17 #endif18 #include <openssl/ecdsa.h>
init.cpp (modified)
1--- v0.2.7/init.cpp2+++ v0.2.8/init.cpp3@@ -284,6 +284,10 @@4 _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);5 _CrtSetReportFile(_CRT_WARN, CreateFileA("NUL", GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0));6 #endif7+#if _MSC_VER >= 14008+ // Disable confusing "helpful" text message on abort, ctrl-c9+ _set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT);10+#endif11 #if defined(__WXMSW__) && defined(__WXDEBUG__) && wxUSE_GUI12 // Disable malfunctioning wxWidgets debug assertion13 g_isPainting = 10000;14@@ -291,10 +295,12 @@15 #if wxUSE_GUI16 wxImage::AddHandler(new wxPNGHandler);17 #endif18-#ifdef __WXMSW__19+#if defined(__WXMSW__ ) || defined(__WXMAC__)20 SetAppName("Bitcoin");21 #else22 SetAppName("bitcoin");23+#endif24+#ifndef __WXMSW__25 umask(077);26 #endif27 #ifdef __WXMSW__
irc.cpp (modified)
1--- v0.2.7/irc.cpp2+++ v0.2.8/irc.cpp3@@ -76,6 +76,8 @@4 if (c == '\r')5 return true;6 strLine += c;7+ if (strLine.size() >= 9000)8+ return true;9 }10 else if (nBytes <= 0)11 {12@@ -109,7 +111,7 @@13 return false;14 vector<string> vWords;15 ParseString(strLine, ' ', vWords);16- if (vWords[0] == "PING")17+ if (vWords.size() >= 1 && vWords[0] == "PING")18 {19 strLine[1] = 'O';20 strLine += '\r';21@@ -156,6 +158,7 @@22 23 void ThreadIRCSeed(void* parg)24 {25+ printf("ThreadIRCSeed started\n");26 SetThreadPriority(THREAD_PRIORITY_NORMAL);27 int nErrorWait = 10;28 int nRetryWait = 10;
main.cpp (modified)
1--- v0.2.7/main.cpp2+++ v0.2.8/main.cpp3@@ -1338,7 +1338,7 @@4 5 // Don't relay old inventory during initial block download.6 // Please keep this number updated to a few thousand below current block count.7- if (hashBestChain == hash && nBestHeight > 40000)8+ if (hashBestChain == hash && nBestHeight > 55000)9 RelayInventory(CInv(MSG_BLOCK, hash));10 11 // // Add atoms to user reviews for coins created12@@ -2255,9 +2255,9 @@13 // Delay tx inv messages to protect privacy,14 // trickle them out to a few nodes at a time.15 bool fSendTxInv = false;16- if (GetTimeMillis() - pto->nLastSentTxInv > 1800 + GetRand(200))17- {18- pto->nLastSentTxInv = GetTimeMillis();19+ if (GetTimeMillis() > pto->nNextSendTxInv)20+ {21+ pto->nNextSendTxInv = GetTimeMillis() + 3000 + GetRand(2000);22 fSendTxInv = true;23 }24
makefile.vc (modified)
1--- v0.2.7/makefile.vc2+++ v0.2.8/makefile.vc3@@ -36,7 +36,7 @@4 5 6 .cpp{obj}.obj:7- cl $(CFLAGS) /Fo$@ %s8+ cl $(CFLAGS) /Fo$@ %s9 10 obj\util.obj: $(HEADERS)11 12@@ -59,10 +59,10 @@13 obj\uibase.obj: $(HEADERS)14 15 obj\sha.obj: sha.cpp sha.h16- cl $(CFLAGS) /O2 /Fo$@ %s17+ cl $(CFLAGS) /O2 /Fo$@ %s18 19 obj\ui.res: ui.rc rc/bitcoin.ico rc/check.ico rc/send16.bmp rc/send16mask.bmp rc/send16masknoshadow.bmp rc/send20.bmp rc/send20mask.bmp rc/addressbook16.bmp rc/addressbook16mask.bmp rc/addressbook20.bmp rc/addressbook20mask.bmp20- rc $(INCLUDEPATHS) $(WXDEFS) /Fo$@ %s21+ rc $(INCLUDEPATHS) $(WXDEFS) /Fo$@ %s22 23 OBJS= \24 obj\util.obj \25@@ -75,11 +75,11 @@26 obj\init.obj27 28 bitcoin.exe: $(OBJS) obj\ui.obj obj\uibase.obj obj\sha.obj obj\ui.res29- link /nologo /DEBUG /SUBSYSTEM:WINDOWS /OUT:$@ $(LIBPATHS) $** $(LIBS)30+ link /nologo /DEBUG /SUBSYSTEM:WINDOWS /OUT:$@ $(LIBPATHS) $** $(LIBS)31 32 33 .cpp{obj\nogui}.obj:34- cl $(CFLAGS) /DwxUSE_GUI=0 /Fo$@ %s35+ cl $(CFLAGS) /DwxUSE_GUI=0 /Fo$@ %s36 37 obj\nogui\util.obj: $(HEADERS)38 39@@ -98,11 +98,11 @@40 obj\nogui\init.obj: $(HEADERS)41 42 bitcoind.exe: $(OBJS:obj\=obj\nogui\) obj\sha.obj obj\ui.res43- link /nologo /DEBUG /OUT:$@ $(LIBPATHS) $** $(LIBS)44+ link /nologo /DEBUG /OUT:$@ $(LIBPATHS) $** $(LIBS)45 46 47 clean:48- -del /Q obj\*49- -del *.ilk50- -del *.pdb51+ -del /Q obj\*52+ -del *.ilk53+ -del *.pdb54
net.cpp (modified)
1--- v0.2.7/net.cpp2+++ v0.2.8/net.cpp3@@ -927,9 +927,7 @@4 continue;5 6 // Only try the old stuff if we don't have enough connections7- if (vNodes.size() >= 2 && nSinceLastSeen > 7 * 24 * 60 * 60)8- continue;9- if (vNodes.size() >= 5 && nSinceLastSeen > 24 * 60 * 60)10+ if (vNodes.size() >= 8 && nSinceLastSeen > 24 * 60 * 60)11 continue;12 13 // If multiple addresses are ready, prioritize by time since
net.h (modified)
1--- v0.2.7/net.h2+++ v0.2.8/net.h3@@ -45,6 +45,7 @@4 // (4) message start5 // (12) command6 // (4) size7+// (4) checksum8 9 // The message start string is designed to be unlikely to occur in normal data.10 // The characters are rarely used upper ascii, not valid as UTF-8, and produce11@@ -58,6 +59,7 @@12 char pchMessageStart[sizeof(::pchMessageStart)];13 char pchCommand[COMMAND_SIZE];14 unsigned int nMessageSize;15+ //unsigned int nChecksum;16 17 CMessageHeader()18 {19@@ -65,6 +67,7 @@20 memset(pchCommand, 0, sizeof(pchCommand));21 pchCommand[1] = 1;22 nMessageSize = -1;23+ //nChecksum = 0;24 }25 26 CMessageHeader(const char* pszCommand, unsigned int nMessageSizeIn)27@@ -79,6 +82,8 @@28 READWRITE(FLATDATA(pchMessageStart));29 READWRITE(FLATDATA(pchCommand));30 READWRITE(nMessageSize);31+ //if (nVersion >= 209 && GetCommand() != "version")32+ // READWRITE(nChecksum);33 )34 35 string GetCommand()36@@ -484,7 +489,8 @@37 int64 nLastRecv;38 int64 nLastSendEmpty;39 int64 nTimeConnected;40- unsigned int nPushPos;41+ unsigned int nHeaderStart;42+ unsigned int nMessageStart;43 CAddress addr;44 int nVersion;45 bool fClient;46@@ -512,7 +518,7 @@47 vector<CInv> vInventoryToSend;48 CCriticalSection cs_inventory;49 multimap<int64, CInv> mapAskFor;50- int64 nLastSentTxInv;51+ int64 nNextSendTxInv;52 53 // publish and subscription54 vector<char> vfSubscribe;55@@ -528,7 +534,8 @@56 nLastRecv = 0;57 nLastSendEmpty = GetTime();58 nTimeConnected = GetTime();59- nPushPos = -1;60+ nHeaderStart = -1;61+ nMessageStart = -1;62 addr = addrIn;63 nVersion = 0;64 fClient = false; // set by version message65@@ -542,6 +549,7 @@66 pindexLastGetBlocksBegin = 0;67 hashLastGetBlocksEnd = 0;68 fGetAddr = false;69+ nNextSendTxInv = 0;70 vfSubscribe.assign(256, false);71 72 // Push a version message73@@ -639,10 +647,11 @@74 void BeginMessage(const char* pszCommand)75 {76 cs_vSend.Enter();77- if (nPushPos != -1)78- AbortMessage();79- nPushPos = vSend.size();80+ if (nHeaderStart != -1)81+ AbortMessage();82+ nHeaderStart = vSend.size();83 vSend << CMessageHeader(pszCommand, 0);84+ nMessageStart = vSend.size();85 if (fDebug)86 printf("%s ", DateTimeStrFormat("%x %H:%M:%S", GetTime()).c_str());87 printf("sending: %s ", pszCommand);88@@ -650,10 +659,11 @@89 90 void AbortMessage()91 {92- if (nPushPos == -1)93+ if (nHeaderStart == -1)94 return;95- vSend.resize(nPushPos);96- nPushPos = -1;97+ vSend.resize(nHeaderStart);98+ nHeaderStart = -1;99+ nMessageStart = -1;100 cs_vSend.Leave();101 printf("(aborted)\n");102 }103@@ -667,25 +677,26 @@104 return;105 }106 107- if (nPushPos == -1)108+ if (nHeaderStart == -1)109 return;110 111 // Patch in the size112- unsigned int nSize = vSend.size() - nPushPos - sizeof(CMessageHeader);113- memcpy((char*)&vSend[nPushPos] + offsetof(CMessageHeader, nMessageSize), &nSize, sizeof(nSize));114+ unsigned int nSize = vSend.size() - nMessageStart;115+ memcpy((char*)&vSend[nHeaderStart] + offsetof(CMessageHeader, nMessageSize), &nSize, sizeof(nSize));116 117 printf("(%d bytes) ", nSize);118 printf("\n");119 120- nPushPos = -1;121+ nHeaderStart = -1;122+ nMessageStart = -1;123 cs_vSend.Leave();124 }125 126 void EndMessageAbortIfEmpty()127 {128- if (nPushPos == -1)129+ if (nHeaderStart == -1)130 return;131- int nSize = vSend.size() - nPushPos - sizeof(CMessageHeader);132+ int nSize = vSend.size() - nMessageStart;133 if (nSize > 0)134 EndMessage();135 else136@@ -694,9 +705,9 @@137 138 const char* GetMessageCommand() const139 {140- if (nPushPos == -1)141+ if (nHeaderStart == -1)142 return "";143- return &vSend[nPushPos] + offsetof(CMessageHeader, pchCommand);144+ return &vSend[nHeaderStart] + offsetof(CMessageHeader, pchCommand);145 }146 147
rpc.cpp (modified)
1--- v0.2.7/rpc.cpp2+++ v0.2.8/rpc.cpp3@@ -77,22 +77,26 @@4 }5 6 7-Value getdifficulty(const Array& params)8-{9- if (params.size() != 0)10- throw runtime_error(11- "getdifficulty (no parameters)\n"12- "Returns the proof-of-work difficulty as a multiple of the minimum difficulty.");13-14- if (pindexBest == NULL)15- throw runtime_error("block chain not loaded");16-17+double GetDifficulty()18+{19 // Floating point number that is a multiple of the minimum difficulty,20 // minimum difficulty = 1.0.21+ if (pindexBest == NULL)22+ return 1.0;23 int nShift = 256 - 32 - 31; // to fit in a uint24 double dMinimum = (CBigNum().SetCompact(bnProofOfWorkLimit.GetCompact()) >> nShift).getuint();25 double dCurrently = (CBigNum().SetCompact(pindexBest->nBits) >> nShift).getuint();26 return dMinimum / dCurrently;27+}28+29+Value getdifficulty(const Array& params)30+{31+ if (params.size() != 0)32+ throw runtime_error(33+ "getdifficulty (no parameters)\n"34+ "Returns the proof-of-work difficulty as a multiple of the minimum difficulty.");35+36+ return GetDifficulty();37 }38 39 40@@ -157,6 +161,7 @@41 obj.push_back(Pair("proxy", (fUseProxy ? addrProxy.ToStringIPPort() : string())));42 obj.push_back(Pair("generate", (bool)fGenerateBitcoins));43 obj.push_back(Pair("genproclimit", (int)(fLimitProcessors ? nLimitProcessors : -1)));44+ obj.push_back(Pair("difficulty", (double)GetDifficulty()));45 return obj;46 }47
serialize.h (modified)
1--- v0.2.7/serialize.h2+++ v0.2.8/serialize.h3@@ -19,7 +19,7 @@4 class CDataStream;5 class CAutoFile;6 7-static const int VERSION = 207;8+static const int VERSION = 208;9 static const char* pszSubVer = ".0";10 11
ui.cpp (modified)
1--- v0.2.7/ui.cpp2+++ v0.2.8/ui.cpp3@@ -256,11 +256,20 @@4 m_staticTextBalance->SetLabel(FormatMoney(GetBalance()) + " ");5 m_listCtrl->SetFocus();6 ptaskbaricon = new CMyTaskBarIcon();7+#ifdef __WXMAC__8+ // Mac automatically moves wxID_EXIT, wxID_PREFERENCES and wxID_ABOUT9+ // to their standard places, leaving these menus empty.10+ GetMenuBar()->Remove(2); // remove Help menu11+ GetMenuBar()->Remove(0); // remove File menu12+#endif13 14 // Init column headers15 int nDateWidth = DateTimeStr(1229413914).size() * 6 + 8;16 if (!strstr(DateTimeStr(1229413914).c_str(), "2008"))17 nDateWidth += 12;18+#ifdef __WXMAC__19+ nDateWidth += 2;20+#endif21 wxListCtrl* pplistCtrl[] = {m_listCtrlAll, m_listCtrlSentReceived, m_listCtrlSent, m_listCtrlReceived};22 foreach(wxListCtrl* p, pplistCtrl)23 {24@@ -274,7 +283,7 @@25 }26 27 // Init status bar28- int pnWidths[3] = { -100, 88, 290 };29+ int pnWidths[3] = { -100, 88, 300 };30 #ifndef __WXMSW__31 pnWidths[1] = pnWidths[1] * 1.1 * dResize;32 pnWidths[2] = pnWidths[2] * 1.1 * dResize;33@@ -2157,7 +2166,7 @@34 bool fMine = (AddressToHash160(strAddress, hash160) && mapPubKeys.count(hash160));35 wxListCtrl* plistCtrl = fMine ? m_listCtrlReceiving : m_listCtrlSending;36 int nIndex = InsertLine(plistCtrl, strName, strAddress);37- if (strAddress == (fMine ? strDefaultReceiving : strInitSelected))38+ if (strAddress == (fMine ? strDefaultReceiving : string(strInitSelected)))39 plistCtrl->SetItemState(nIndex, wxLIST_STATE_SELECTED|wxLIST_STATE_FOCUSED, wxLIST_STATE_SELECTED|wxLIST_STATE_FOCUSED);40 }41 }42@@ -2444,7 +2453,7 @@43 void CMyTaskBarIcon::OnMenuOptions(wxCommandEvent& event)44 {45 // Since it's modal, get the main window to do it46- wxCommandEvent event2(wxEVT_COMMAND_MENU_SELECTED, wxID_MENUOPTIONSOPTIONS);47+ wxCommandEvent event2(wxEVT_COMMAND_MENU_SELECTED, wxID_PREFERENCES);48 pframeMain->GetEventHandler()->AddPendingEvent(event2);49 }50
uibase.cpp (modified)
1--- v0.2.7/uibase.cpp2+++ v0.2.8/uibase.cpp3@@ -24,7 +24,7 @@4 5 m_menuFile = new wxMenu();6 wxMenuItem* m_menuFileExit;7- m_menuFileExit = new wxMenuItem( m_menuFile, wxID_ANY, wxString( _("E&xit") ) , wxEmptyString, wxITEM_NORMAL );8+ m_menuFileExit = new wxMenuItem( m_menuFile, wxID_EXIT, wxString( _("E&xit") ) , wxEmptyString, wxITEM_NORMAL );9 m_menuFile->Append( m_menuFileExit );10 11 m_menubar->Append( m_menuFile, _("&File") );12@@ -39,14 +39,14 @@13 m_menuOptions->Append( m_menuOptionsChangeYourAddress );14 15 wxMenuItem* m_menuOptionsOptions;16- m_menuOptionsOptions = new wxMenuItem( m_menuOptions, wxID_MENUOPTIONSOPTIONS, wxString( _("&Options...") ) , wxEmptyString, wxITEM_NORMAL );17+ m_menuOptionsOptions = new wxMenuItem( m_menuOptions, wxID_PREFERENCES, wxString( _("&Options...") ) , wxEmptyString, wxITEM_NORMAL );18 m_menuOptions->Append( m_menuOptionsOptions );19 20 m_menubar->Append( m_menuOptions, _("&Settings") );21 22 m_menuHelp = new wxMenu();23 wxMenuItem* m_menuHelpAbout;24- m_menuHelpAbout = new wxMenuItem( m_menuHelp, wxID_ANY, wxString( _("&About...") ) , wxEmptyString, wxITEM_NORMAL );25+ m_menuHelpAbout = new wxMenuItem( m_menuHelp, wxID_ABOUT, wxString( _("&About...") ) , wxEmptyString, wxITEM_NORMAL );26 m_menuHelp->Append( m_menuHelpAbout );27 28 m_menubar->Append( m_menuHelp, _("&Help") );29@@ -133,7 +133,7 @@30 wxBoxSizer* bSizer11;31 bSizer11 = new wxBoxSizer( wxVERTICAL );32 33- m_listCtrlAll = new wxListCtrl( m_panel9, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_NO_SORT_HEADER|wxLC_REPORT|wxLC_SORT_DESCENDING|wxVSCROLL );34+ m_listCtrlAll = new wxListCtrl( m_panel9, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_NO_SORT_HEADER|wxLC_REPORT|wxLC_SORT_DESCENDING );35 bSizer11->Add( m_listCtrlAll, 1, wxEXPAND, 5 );36 37 m_panel9->SetSizer( bSizer11 );38@@ -144,7 +144,7 @@39 wxBoxSizer* bSizer111;40 bSizer111 = new wxBoxSizer( wxVERTICAL );41 42- m_listCtrlSentReceived = new wxListCtrl( m_panel91, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_NO_SORT_HEADER|wxLC_REPORT|wxLC_SORT_DESCENDING|wxVSCROLL );43+ m_listCtrlSentReceived = new wxListCtrl( m_panel91, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_NO_SORT_HEADER|wxLC_REPORT|wxLC_SORT_DESCENDING );44 bSizer111->Add( m_listCtrlSentReceived, 1, wxEXPAND, 5 );45 46 m_panel91->SetSizer( bSizer111 );47@@ -155,7 +155,7 @@48 wxBoxSizer* bSizer112;49 bSizer112 = new wxBoxSizer( wxVERTICAL );50 51- m_listCtrlSent = new wxListCtrl( m_panel92, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_NO_SORT_HEADER|wxLC_REPORT|wxLC_SORT_DESCENDING|wxVSCROLL );52+ m_listCtrlSent = new wxListCtrl( m_panel92, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_NO_SORT_HEADER|wxLC_REPORT|wxLC_SORT_DESCENDING );53 bSizer112->Add( m_listCtrlSent, 1, wxEXPAND, 5 );54 55 m_panel92->SetSizer( bSizer112 );56@@ -166,7 +166,7 @@57 wxBoxSizer* bSizer113;58 bSizer113 = new wxBoxSizer( wxVERTICAL );59 60- m_listCtrlReceived = new wxListCtrl( m_panel93, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_NO_SORT_HEADER|wxLC_REPORT|wxLC_SORT_DESCENDING|wxVSCROLL );61+ m_listCtrlReceived = new wxListCtrl( m_panel93, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_NO_SORT_HEADER|wxLC_REPORT|wxLC_SORT_DESCENDING );62 bSizer113->Add( m_listCtrlReceived, 1, wxEXPAND, 5 );63 64 m_panel93->SetSizer( bSizer113 );
uibase.h (modified)
1--- v0.2.7/uibase.h2+++ v0.2.8/uibase.h3@@ -42,29 +42,28 @@4 5 #define wxID_MAINFRAME 10006 #define wxID_OPTIONSGENERATEBITCOINS 10017-#define wxID_MENUOPTIONSOPTIONS 10028-#define wxID_BUTTONSEND 10039-#define wxID_BUTTONRECEIVE 100410-#define wxID_TEXTCTRLADDRESS 100511-#define wxID_BUTTONNEW 100612-#define wxID_BUTTONCOPY 100713-#define wxID_TRANSACTIONFEE 100814-#define wxID_PROXYIP 100915-#define wxID_PROXYPORT 101016-#define wxID_TEXTCTRLPAYTO 101117-#define wxID_BUTTONPASTE 101218-#define wxID_BUTTONADDRESSBOOK 101319-#define wxID_TEXTCTRLAMOUNT 101420-#define wxID_CHOICETRANSFERTYPE 101521-#define wxID_LISTCTRL 101622-#define wxID_BUTTONRENAME 101723-#define wxID_PANELSENDING 101824-#define wxID_LISTCTRLSENDING 101925-#define wxID_PANELRECEIVING 102026-#define wxID_LISTCTRLRECEIVING 102127-#define wxID_BUTTONDELETE 102228-#define wxID_BUTTONEDIT 102329-#define wxID_TEXTCTRL 102430+#define wxID_BUTTONSEND 100231+#define wxID_BUTTONRECEIVE 100332+#define wxID_TEXTCTRLADDRESS 100433+#define wxID_BUTTONNEW 100534+#define wxID_BUTTONCOPY 100635+#define wxID_TRANSACTIONFEE 100736+#define wxID_PROXYIP 100837+#define wxID_PROXYPORT 100938+#define wxID_TEXTCTRLPAYTO 101039+#define wxID_BUTTONPASTE 101140+#define wxID_BUTTONADDRESSBOOK 101241+#define wxID_TEXTCTRLAMOUNT 101342+#define wxID_CHOICETRANSFERTYPE 101443+#define wxID_LISTCTRL 101544+#define wxID_BUTTONRENAME 101645+#define wxID_PANELSENDING 101746+#define wxID_LISTCTRLSENDING 101847+#define wxID_PANELRECEIVING 101948+#define wxID_LISTCTRLRECEIVING 102049+#define wxID_BUTTONDELETE 102150+#define wxID_BUTTONEDIT 102251+#define wxID_TEXTCTRL 102352 53 ///////////////////////////////////////////////////////////////////////////////54 /// Class CMainFrameBase
util.cpp (modified)
1--- v0.2.7/util.cpp2+++ v0.2.8/util.cpp3@@ -282,15 +282,21 @@4 5 void ParseString(const string& str, char c, vector<string>& v)6 {7- unsigned int i1 = 0;8- unsigned int i2;9- do10+ if (str.empty())11+ return;12+ string::size_type i1 = 0;13+ string::size_type i2;14+ loop15 {16 i2 = str.find(c, i1);17+ if (i2 == str.npos)18+ {19+ v.push_back(str.substr(i1));20+ return;21+ }22 v.push_back(str.substr(i1, i2-i1));23 i1 = i2+1;24 }25- while (i2 != str.npos);26 }27 28 29@@ -306,6 +312,12 @@30 else if (fPlus && n > 0)31 str.insert((unsigned int)0, 1, '+');32 return str;33+}34+35+36+bool ParseMoney(const string& str, int64& nRet)37+{38+ return ParseMoney(str.c_str(), nRet);39 }40 41 bool ParseMoney(const char* pszIn, int64& nRet)42@@ -445,17 +457,17 @@43 return (*mi).second;44 45 // wxWidgets translation46- const char* pszTranslated = wxGetTranslation(wxString(pszEnglish, wxConvUTF8)).utf8_str();47+ wxString strTranslated = wxGetTranslation(wxString(pszEnglish, wxConvUTF8));48 49 // We don't cache unknown strings because caller might be passing in a50 // dynamic string and we would keep allocating memory for each variation.51- if (strcmp(pszEnglish, pszTranslated) == 0)52+ if (strcmp(pszEnglish, strTranslated.utf8_str()) == 0)53 return pszEnglish;54 55 // Add to cache, memory doesn't need to be freed. We only cache because56 // we must pass back a pointer to permanently allocated memory.57- char* pszCached = new char[strlen(pszTranslated)+1];58- strcpy(pszCached, pszTranslated);59+ char* pszCached = new char[strlen(strTranslated.utf8_str())+1];60+ strcpy(pszCached, strTranslated.utf8_str());61 mapCache[pszEnglish] = pszCached;62 return pszCached;63 }
util.h (modified)
1--- v0.2.7/util.h2+++ v0.2.8/util.h3@@ -133,6 +133,7 @@4 void LogException(std::exception* pex, const char* pszThread);5 void ParseString(const string& str, char c, vector<string>& v);6 string FormatMoney(int64 n, bool fPlus=false);7+bool ParseMoney(const string& str, int64& nRet);8 bool ParseMoney(const char* pszIn, int64& nRet);9 vector<unsigned char> ParseHex(const char* psz);10 vector<unsigned char> ParseHex(const std::string& str);
