]> code.citadel.org Git - citadel.git/blobdiff - citadel/tools.c
WebCit 7.13
[citadel.git] / citadel / tools.c
index a19f5c68e567626eb9c7876379452ad99ed034d2..5f225ccbddc03e814a3a02bb53e1eade2f7150a7 100644 (file)
@@ -82,15 +82,22 @@ int strncasecmp(char *lstr, char *rstr, int len)
 /*
  * num_tokens()  -  discover number of parameters/tokens in a string
  */
-int num_tokens(const char *source, char tok) {
-       int a;
+int num_tokens(const char *source, char tok)
+{
        int count = 1;
+       const char *ptr = source;
+
+       if (source == NULL) {
+               return (0);
+       }
 
-       if (source == NULL) return(0);
-       for (a=0; a<strlen(source); ++a) {
-               if (source[a]==tok) ++count;
+       while (*ptr != '\0') {
+               if (*ptr++ == tok) {
+                       ++count;
+               }
        }
-       return(count);
+       
+       return (count);
 }