Use string::size_type to store string offsets
authorMikko Rasa <tdb@tdb.fi>
Mon, 16 May 2016 15:15:10 +0000 (18:15 +0300)
committerMikko Rasa <tdb@tdb.fi>
Mon, 16 May 2016 15:16:33 +0000 (18:16 +0300)
source/http/message.cpp
source/http/request.cpp
source/http/response.cpp
source/http/server.cpp
source/net/resolve.cpp

index 21d2c4b5a4ee955d7e8cd24177347ecedcd5f25d..92321e8a87bd4c953f039141724c621c2d977ac2 100644 (file)
@@ -97,7 +97,7 @@ unsigned Message::parse_content(const string &d)
 
 unsigned Message::parse_headers(const string &d)
 {
-       unsigned start = 0;
+       string::size_type start = 0;
        while(1)
        {
                string::size_type lf = d.find('\n', start);
@@ -106,7 +106,7 @@ unsigned Message::parse_headers(const string &d)
                if(lf==start || (d[start]=='\r' && lf==start+1))
                        return lf+1;
 
-               unsigned colon = d.find(':', start);
+               string::size_type colon = d.find(':', start);
                if(colon>lf)
                        throw invalid_argument("Message::parse_headers");
 
index f050e0440084d0a0b447875fec014d7ef4940dee..54b0beeaa9cb4f7e908f995a2d0d328bc1bf91a0 100644 (file)
@@ -27,7 +27,7 @@ string Request::str() const
 
 Request Request::parse(const string &str)
 {
-       unsigned lf = str.find('\n');
+       string::size_type lf = str.find('\n');
        vector<string> parts = split(str.substr(0, lf-(str[lf-1]=='\r')), ' ', 2);
        if(parts.size()<3)
                throw invalid_argument("Request::parse");
index 85e279f579a35cd08a6e4ad446ef1836771a282e..739a20f3da2fa2ba6503e13b216ba842b9403ec3 100644 (file)
@@ -23,7 +23,7 @@ Response Response::parse(const string &str)
 {
        Response result;
 
-       unsigned lf = str.find('\n');
+       string::size_type lf = str.find('\n');
        vector<string> parts = split(str.substr(0, lf), ' ', 2);
        if(parts.size()<2)
                throw invalid_argument("Response::parse");
index fc6d61f14c8c065e43bf951a4cc8f52b5a7eac48..f0474fd18e993c57de16b1a3f51c07dc260f069f 100644 (file)
@@ -106,7 +106,7 @@ void Server::client_data_available(Client &cl)
                                cl.request = new Request(Request::parse(cl.in_buf));
 
                                string addr_str = cl.sock->get_peer_address().str();
-                               unsigned colon = addr_str.find(':');
+                               string::size_type colon = addr_str.find(':');
                                cl.request->set_header("-Client-Host", addr_str.substr(0, colon));
 
                                if(cl.request->get_method()!="GET" && cl.request->get_method()!="POST")
index 097fea355111e82b34020a8c867f7821da0f202d..88497faa4b2dead177bcb72f54dceee72713ee77 100644 (file)
@@ -54,7 +54,7 @@ SockAddr *resolve(const string &str, Family family)
        string host, serv;
        if(str[0]=='[')
        {
-               unsigned bracket = str.find(']');
+               string::size_type bracket = str.find(']');
                host = str.substr(1, bracket-1);
                string::size_type colon = str.find(':', bracket);
                if(colon!=string::npos)