Directly take a Mask instead of a String in BanEntry
[clinton/bobotpp.git] / source / StringTokenizer.C
index c4dfeb7..f45b67c 100644 (file)
 
 // You should have received a copy of the GNU General Public License
 // along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307, USA.
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
 #include "StringTokenizer.H"
+
 #include <string>
+
 #include <cstring>
 
 StringTokenizer::StringTokenizer(std::string s)
@@ -30,7 +32,7 @@ StringTokenizer::more_tokens_p ()
   if (pos == st.length())
     return false;
 
-  for (int i = pos; i < st.length(); i++)
+  for (std::string::size_type i = pos; i < st.length(); i++)
     if (st[i] != ' ' && st[i] != '\t')
       return true;
 
@@ -43,17 +45,17 @@ StringTokenizer::more_tokens_p (char c)
   if (pos == st.length())
     return false;
 
-  for (int i = pos; i < st.length(); i++)
+  for (std::string::size_type i = pos; i < st.length(); i++)
     if (st[i] != c)
       return true;
 
   return false;
 }
 
-int
+unsigned int
 StringTokenizer::count_tokens ()
 {
-  int i = 0;
+  unsigned int i = 0;
   StringTokenizer s (st);
   
   while (s.more_tokens_p ())
@@ -65,10 +67,10 @@ StringTokenizer::count_tokens ()
   return i;
 }
 
-int
+unsigned int
 StringTokenizer::count_tokens (char c)
 {
-  int i = 0;
+  unsigned int i = 0;
   StringTokenizer s(st);
   
   while (s.more_tokens_p (c))
@@ -83,41 +85,47 @@ StringTokenizer::count_tokens (char c)
 std::string
 StringTokenizer::next_token()
 {
-  int i = pos;
+  std::string::size_type i = pos;
   
   while (i < st.length() && (st[i] == ' ' || st[i] == '\t'))
     i++;
   
-  for (int j = i; j < st.length(); j++)
+  for (std::string::size_type j = i; j < st.length(); j++)
     if (st[j] == ' ' || st[j] == '\t') 
       {
        pos = j + 1;
-       return st.substr (i, j - 1);
+       return st.substr (i, j - i);
       }
 
   pos = st.length();
-  return st.substr (i, st.length() - 1);
+  return st.substr (i, st.length() - i);
 }
 
 std::string
 StringTokenizer::next_token (char c, bool empty)
 {
-  int i = pos;
+  std::string::size_type i = pos;
+  std::string::size_type j = 0;
 
   while (i < st.length() && (st[i] == c))
-    i++;
-  for (int j = i; j < st.length(); j++)
-    if (st[j] == c)
-      {
-       pos = j + 1;
-       return st.substr (i, j - 1);
-      }
+    {
+      i++;
+    }
+
+  for (j = i; j < st.length(); j++)
+    {
+      if (st[j] == c)
+       {
+         pos = j + 1;
+         return st.substr (i, j - i);
+       }
+    }
 
   if (empty)
     return "";
   
   pos = st.length();
-  return st.substr (i, st.length() - 1);
+  return st.substr (i, st.length() - i);
 }
 
 std::string
@@ -130,5 +138,5 @@ StringTokenizer::rest()
   while (pos < st.length() && (std::isspace (st[pos])))
     pos++;
 
-  return st.substr (pos, st.length() - 1);
+  return st.substr (pos, st.length() - pos);
 }