replace unsgined int with string::size_type where comparisons to

string::npos take place.
pull/1/head
Tatsuhiro Tsujikawa 2006-02-18 16:19:25 +00:00
parent e37985acb4
commit 6d6f25b75c
3 changed files with 9 additions and 9 deletions

View File

@ -130,7 +130,7 @@ int HttpConnection::receiveResponse(HttpHeader& headers) {
} }
// OK, i got all headers. // OK, i got all headers.
logger->info(MSG_RECEIVE_RESPONSE, cuid, header.c_str()); logger->info(MSG_RECEIVE_RESPONSE, cuid, header.c_str());
unsigned int p, np; string::size_type p, np;
p = np = 0; p = np = 0;
np = header.find("\r\n", p); np = header.find("\r\n", p);
if(np == string::npos) { if(np == string::npos) {

View File

@ -63,7 +63,7 @@ bool Request::parseUrl(string url) {
if(url.find_first_not_of(SAFE_CHARS) != string::npos) { if(url.find_first_not_of(SAFE_CHARS) != string::npos) {
return false; return false;
} }
unsigned int hp = url.find("://"); string::size_type hp = url.find("://");
if(hp == string::npos) return false; if(hp == string::npos) return false;
protocol = url.substr(0, hp); protocol = url.substr(0, hp);
int defPort; int defPort;
@ -72,7 +72,7 @@ bool Request::parseUrl(string url) {
} }
hp += 3; hp += 3;
if(url.size() <= hp) return false; if(url.size() <= hp) return false;
unsigned int hep = url.find("/", hp); string::size_type hep = url.find("/", hp);
if(hep == string::npos) { if(hep == string::npos) {
hep = url.size(); hep = url.size();
} }
@ -90,7 +90,7 @@ bool Request::parseUrl(string url) {
// If port is not specified, then we leave it 0. // If port is not specified, then we leave it 0.
port = defPort; port = defPort;
} }
unsigned int direp = url.find_last_of("/"); string::size_type direp = url.find_last_of("/");
if(direp == string::npos || direp <= hep) { if(direp == string::npos || direp <= hep) {
dir = "/"; dir = "/";
direp = hep; direp = hep;

View File

@ -54,8 +54,8 @@ string Util::llitos(long long int value, bool comma)
} }
string Util::trim(string src) { string Util::trim(string src) {
unsigned int sp = src.find_first_not_of(" "); string::size_type sp = src.find_first_not_of(" ");
unsigned int ep = src.find_last_not_of(" "); string::size_type ep = src.find_last_not_of(" ");
if(sp == string::npos || ep == string::npos) { if(sp == string::npos || ep == string::npos) {
return ""; return "";
} else { } else {
@ -66,7 +66,7 @@ string Util::trim(string src) {
void Util::split(pair<string, string>& hp, string src, char delim) { void Util::split(pair<string, string>& hp, string src, char delim) {
hp.first = ""; hp.first = "";
hp.second = ""; hp.second = "";
unsigned int p = src.find(delim); string::size_type p = src.find(delim);
if(p == string::npos) { if(p == string::npos) {
hp.first = src; hp.first = src;
hp.second = ""; hp.second = "";
@ -93,9 +93,9 @@ long long int Util::difftv(struct timeval tv1, struct timeval tv2) {
} }
void Util::slice(vector<string>& result, string src, char delim) { void Util::slice(vector<string>& result, string src, char delim) {
int p = 0; string::size_type p = 0;
while(1) { while(1) {
unsigned int np = src.find(delim, p); string::size_type np = src.find(delim, p);
if(np == string::npos) { if(np == string::npos) {
string term = trim(src.substr(p)); string term = trim(src.substr(p));
if(term.size() > 0) { if(term.size() > 0) {