diff --git a/libtorrent/include/libtorrent/alert_types.hpp b/libtorrent/include/libtorrent/alert_types.hpp index f4dd134c5..b98debf3f 100644 --- a/libtorrent/include/libtorrent/alert_types.hpp +++ b/libtorrent/include/libtorrent/alert_types.hpp @@ -205,7 +205,8 @@ namespace libtorrent { static char const* state_str[] = {"checking (q)", "checking", "dl metadata" - , "downloading", "finished", "seeding", "allocating"}; + , "downloading", "finished", "seeding", "allocating" + , "checking (r)"}; return torrent_alert::message() + ": state changed to: " + state_str[state]; diff --git a/libtorrent/include/libtorrent/bencode.hpp b/libtorrent/include/libtorrent/bencode.hpp index b5b330d4d..cc4e5a220 100644 --- a/libtorrent/include/libtorrent/bencode.hpp +++ b/libtorrent/include/libtorrent/bencode.hpp @@ -80,17 +80,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/config.hpp" #include "libtorrent/assert.hpp" - -#if defined(_MSC_VER) -namespace std -{ - using ::isdigit; - using ::atoi; -}; - -#define for if (false) {} else for -#endif - +#include "libtorrent/escape_string.hpp" namespace libtorrent { @@ -341,7 +331,7 @@ namespace libtorrent // ---------------------------------------------- // string default: - if (isdigit((unsigned char)*in)) + if (is_digit((unsigned char)*in)) { std::string len_s = read_until(in, end, ':', err); if (err) diff --git a/libtorrent/include/libtorrent/escape_string.hpp b/libtorrent/include/libtorrent/escape_string.hpp index 9f141a923..f76939779 100644 --- a/libtorrent/include/libtorrent/escape_string.hpp +++ b/libtorrent/include/libtorrent/escape_string.hpp @@ -42,7 +42,9 @@ POSSIBILITY OF SUCH DAMAGE. namespace libtorrent { - boost::array::digits10> to_string(size_type n); + boost::array::digits10> TORRENT_EXPORT to_string(size_type n); + bool TORRENT_EXPORT is_digit(char c); + bool TORRENT_EXPORT isprint(char c); std::string TORRENT_EXPORT unescape_string(std::string const& s); std::string TORRENT_EXPORT escape_string(const char* str, int len); diff --git a/libtorrent/include/libtorrent/peer_id.hpp b/libtorrent/include/libtorrent/peer_id.hpp index 0ec096de3..d737fb4fb 100644 --- a/libtorrent/include/libtorrent/peer_id.hpp +++ b/libtorrent/include/libtorrent/peer_id.hpp @@ -42,6 +42,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/config.hpp" #include "libtorrent/assert.hpp" +#include "libtorrent/escape_string.hpp" namespace libtorrent { @@ -168,8 +169,6 @@ namespace libtorrent inline std::istream& operator>>(std::istream& is, big_number& peer) { - using namespace std; - for (big_number::iterator i = peer.begin(); i != peer.end(); ++i) { @@ -182,11 +181,11 @@ namespace libtorrent || ((c[1] < '0' || c[1] > '9') && (c[1] < 'a' || c[1] > 'f')) || is.fail()) { - is.setstate(ios_base::failbit); + is.setstate(std::ios_base::failbit); return is; } - *i = ((isdigit(c[0])?c[0]-'0':c[0]-'a'+10) << 4) - + (isdigit(c[1])?c[1]-'0':c[1]-'a'+10); + *i = ((is_digit(c[0])?c[0]-'0':c[0]-'a'+10) << 4) + + (is_digit(c[1])?c[1]-'0':c[1]-'a'+10); } return is; } diff --git a/libtorrent/src/escape_string.cpp b/libtorrent/src/escape_string.cpp index 40384e760..39c02a9a6 100755 --- a/libtorrent/src/escape_string.cpp +++ b/libtorrent/src/escape_string.cpp @@ -69,6 +69,16 @@ namespace libtorrent return ret; } + bool is_digit(char c) + { + return c >= '0' && c <= '9'; + } + + bool isprint(char c) + { + return c >= 32 && c < 127; + } + std::string unescape_string(std::string const& s) { std::string ret; diff --git a/libtorrent/src/identify_client.cpp b/libtorrent/src/identify_client.cpp index f5477e3a4..9ddfec612 100755 --- a/libtorrent/src/identify_client.cpp +++ b/libtorrent/src/identify_client.cpp @@ -48,28 +48,19 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/identify_client.hpp" #include "libtorrent/fingerprint.hpp" +#include "libtorrent/escape_string.hpp" namespace { using namespace libtorrent; - bool is_digit(char c) - { - return c >= '0' && c <= '9'; - } - int decode_digit(char c) { if (is_digit(c)) return c - '0'; return unsigned(c) - 'A' + 10; } - bool isprint(char c) - { - return c >= 32 && c < 127; - } - // takes a peer id and returns a valid boost::optional // object if the peer id matched the azureus style encoding // the returned fingerprint contains information about the diff --git a/libtorrent/src/lazy_bdecode.cpp b/libtorrent/src/lazy_bdecode.cpp index bc0beaab4..983b48a35 100644 --- a/libtorrent/src/lazy_bdecode.cpp +++ b/libtorrent/src/lazy_bdecode.cpp @@ -31,6 +31,7 @@ POSSIBILITY OF SUCH DAMAGE. */ #include "libtorrent/lazy_entry.hpp" +#include "libtorrent/escape_string.hpp" #include #include #include @@ -58,8 +59,7 @@ namespace libtorrent { while (start < end && *start != delimiter) { - using namespace std; - if (!isdigit(*start)) { return 0; } + if (!is_digit(*start)) { return 0; } val *= 10; val += *start - '0'; ++start; @@ -154,8 +154,7 @@ namespace libtorrent } default: { - using namespace std; - if (!isdigit(t)) return fail_bdecode(ret); + if (!is_digit(t)) return fail_bdecode(ret); boost::int64_t len = t - '0'; start = parse_int(start, end, ':', len); diff --git a/libtorrent/src/upnp.cpp b/libtorrent/src/upnp.cpp index 706ac6208..a91503b54 100644 --- a/libtorrent/src/upnp.cpp +++ b/libtorrent/src/upnp.cpp @@ -658,6 +658,7 @@ void upnp::update_map(rootdevice& d, int i) m_log << time_now_string() << " *** mapping (" << i << ") does not need update, skipping" << std::endl; #endif + m.action = mapping_t::action_none; next(d, i); return; } @@ -673,6 +674,7 @@ void upnp::update_map(rootdevice& d, int i) { if (m.failcount > 5) { + m.action = mapping_t::action_none; // giving up next(d, i); return;