← Back to team overview

linuxdcpp-team team mailing list archive

[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2595: Show country codes next to country names

 

------------------------------------------------------------
revno: 2595
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Sat 2011-08-20 16:45:57 +0200
message:
  Show country codes next to country names
modified:
  changelog.txt
  dcpp/Util.cpp


--
lp:dcplusplus
https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk

Your team Dcplusplus-team is subscribed to branch lp:dcplusplus.
To unsubscribe from this branch go to https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk/+edit-subscription
=== modified file 'changelog.txt'
--- changelog.txt	2011-08-11 13:02:19 +0000
+++ changelog.txt	2011-08-20 14:45:57 +0000
@@ -40,6 +40,8 @@
 * Update MiniUPnPc to version 1.6
 * [L#309402] Initial IPv6 support
 * Update boost to version 1.47
+* COM initialization fix for the Windows UPnP mapper (thanks bigmuscle)
+* Show country codes next to country names (poy)
 
 -- 0.782 2011-03-05 --
 * Prevent a remote crash triggered via malformed user commands (poy)

=== modified file 'dcpp/Util.cpp'
--- dcpp/Util.cpp	2011-08-11 13:02:19 +0000
+++ dcpp/Util.cpp	2011-08-20 14:45:57 +0000
@@ -204,11 +204,9 @@
 		string data = File(file, File::READ, File::OPEN).read();
 
 		const char* start = data.c_str();
-		string::size_type linestart = 0;
-		string::size_type lineend = 0;
+		string::size_type linestart = 0, lineend, pos, pos2;
 		auto last = countries.end();
-		uint32_t startIP = 0;
-		uint32_t endIP = 0, endIPprev = 0;
+		uint32_t startIP = 0, endIP = 0, endIPprev = 0;
 
 		countryNames.push_back(_("Unknown"));
 		auto addCountry = [](const string& countryName) -> size_t {
@@ -221,7 +219,7 @@
 		};
 
 		while(true) {
-			auto pos = data.find(',', linestart);
+			pos = data.find(',', linestart);
 			if(pos == string::npos) break;
 			pos = data.find(',', pos + 1);
 			if(pos == string::npos) break;
@@ -233,15 +231,19 @@
 
 			pos = data.find(',', pos + 1);
 			if(pos == string::npos) break;
-			pos = data.find(',', pos + 1);
-			if(pos == string::npos) break;
-			lineend = data.find('\n', pos);
+
+			pos2 = data.find(',', pos + 1);
+			if(pos2 == string::npos) break;
+
+			lineend = data.find('\n', pos2);
 			if(lineend == string::npos) break;
 
 			if(startIP != endIPprev)
 				last = countries.insert(last, make_pair(startIP, 0));
 			pos += 2;
-			last = countries.insert(last, make_pair(endIP, addCountry(data.substr(pos, lineend - 1 - pos))));
+			pos2 += 2;
+			last = countries.insert(last, make_pair(endIP, addCountry(str(F_("%1% - %2%") %
+				data.substr(pos, 2) % data.substr(pos2, lineend - 1 - pos2)))));
 
 			endIPprev = endIP;
 			linestart = lineend + 1;