]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
addr_parsing: make , and ; and ' ' all delimiters
authorSage Weil <sage@inktank.com>
Thu, 18 Oct 2012 00:44:12 +0000 (17:44 -0700)
committerSage Weil <sage@inktank.com>
Thu, 18 Oct 2012 06:00:10 +0000 (23:00 -0700)
Instead of just ,.  Currently "foo.com, bar.com" will fail because of the
space after the comma.  This patches fixes that, and makes all delim
chars interchangeable.

Signed-off-by: Sage Weil <sage@inktank.com>
src/include/addr_parsing.c

index 2a469f9a9b7bfba9917340024dc8dd2d1da6ccda..f21f637e91f8dc42dbb8ed15f7b3e5f8e6e596c6 100644 (file)
@@ -52,6 +52,7 @@ char *resolve_addrs(const char *orig_str)
   char *tok, *port_str, *saveptr = NULL;
   int len, pos;
   char *buf = strdup(orig_str);
+  const char *delim = ",; ";
 
   len = BUF_SIZE;
   new_str = (char *)malloc(len);
@@ -62,7 +63,7 @@ char *resolve_addrs(const char *orig_str)
 
   pos = 0;
 
-  tok = strtok_r(buf, ",", &saveptr);
+  tok = strtok_r(buf, delim, &saveptr);
 
   while (tok) {
     struct addrinfo hint;
@@ -141,7 +142,7 @@ char *resolve_addrs(const char *orig_str)
     }
     freeaddrinfo(ores);
 
-    tok = strtok_r(NULL, ",", &saveptr);
+    tok = strtok_r(NULL, delim, &saveptr);
     if (tok)
       pos = safe_cat(&new_str, &len, pos, ",");