Browse Source

replace unsgined int with string::size_type where comparisons to
string::npos take place.

Tatsuhiro Tsujikawa 19 years ago
parent
commit
6d6f25b75c
3 changed files with 9 additions and 9 deletions
  1. 1 1
      src/HttpConnection.cc
  2. 3 3
      src/Request.cc
  3. 5 5
      src/Util.cc

+ 1 - 1
src/HttpConnection.cc

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

+ 3 - 3
src/Request.cc

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

+ 5 - 5
src/Util.cc

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