From ab9dc75a183c7a46e38e957ee3192d5febcccb3c Mon Sep 17 00:00:00 2001 From: Jeff Garzik Date: Sun, 15 Apr 2012 16:47:24 -0400 Subject: [PATCH] The string class returns string::npos, when find() fails. Noticed when sign-comparison warnings were enabled. --- src/bitcoinrpc.cpp | 2 +- src/irc.cpp | 8 ++++---- src/net.cpp | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp index 63c51ad..f0d27fa 100644 --- a/src/bitcoinrpc.cpp +++ b/src/bitcoinrpc.cpp @@ -201,7 +201,7 @@ Value help(const Array& params, bool fHelp) // Help text is returned in an exception string strHelp = string(e.what()); if (strCommand == "") - if (strHelp.find('\n') != -1) + if (strHelp.find('\n') != string::npos) strHelp = strHelp.substr(0, strHelp.find('\n')); strRet += strHelp + "\n"; } diff --git a/src/irc.cpp b/src/irc.cpp index 09bacc1..d535f59 100644 --- a/src/irc.cpp +++ b/src/irc.cpp @@ -108,13 +108,13 @@ int RecvUntil(SOCKET hSocket, const char* psz1, const char* psz2=NULL, const cha if (!RecvLineIRC(hSocket, strLine)) return 0; printf("IRC %s\n", strLine.c_str()); - if (psz1 && strLine.find(psz1) != -1) + if (psz1 && strLine.find(psz1) != string::npos) return 1; - if (psz2 && strLine.find(psz2) != -1) + if (psz2 && strLine.find(psz2) != string::npos) return 2; - if (psz3 && strLine.find(psz3) != -1) + if (psz3 && strLine.find(psz3) != string::npos) return 3; - if (psz4 && strLine.find(psz4) != -1) + if (psz4 && strLine.find(psz4) != string::npos) return 4; } } diff --git a/src/net.cpp b/src/net.cpp index b0f3650..fb88891 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -162,14 +162,14 @@ bool GetMyExternalIP2(const CService& addrConnect, const char* pszGet, const cha } if (pszKeyword == NULL) break; - if (strLine.find(pszKeyword) != -1) + if (strLine.find(pszKeyword) != string::npos) { strLine = strLine.substr(strLine.find(pszKeyword) + strlen(pszKeyword)); break; } } closesocket(hSocket); - if (strLine.find("<") != -1) + if (strLine.find("<") != string::npos) strLine = strLine.substr(0, strLine.find("<")); strLine = strLine.substr(strspn(strLine.c_str(), " \t\n\r")); while (strLine.size() > 0 && isspace(strLine[strLine.size()-1])) -- 1.7.1