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 21d2c4b..92321e8 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 f050e04..54b0bee 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 85e279f..739a20f 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 fc6d61f..f0474fd 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 097fea3..88497fa 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)