]> xenbits.xensource.com Git - libvirt.git/commitdiff
util: fix virSkipSpaces
authorEric Blake <eblake@redhat.com>
Wed, 29 Jun 2011 17:30:43 +0000 (11:30 -0600)
committerEric Blake <eblake@redhat.com>
Wed, 6 Jul 2011 20:52:43 +0000 (14:52 -0600)
Most clients of virSkipSpaces don't want to omit backslashes.
Also, open-coding the list of spaces is not as nice as using
c_isspace.

* src/util/util.c (virSkipSpaces): Use c_isspace.
(virSkipSpacesAndBackslash): New function.
* src/util/util.h (virSkipSpacesAndBackslash): New prototype.
* src/xen/xend_internal.c (sexpr_to_xend_topology): Update caller.
* src/libvirt_private.syms (util.h): Export new function.

src/libvirt_private.syms
src/util/util.c
src/util/util.h
src/xen/xend_internal.c

index ae0d1995167fb183738f8f3077e5cfa4147310f2..0fab8a65c238bfc7ae77c85f6b96cb66b3a6e785 100644 (file)
@@ -1031,6 +1031,7 @@ virSetInherit;
 virSetNonBlock;
 virSetUIDGID;
 virSkipSpaces;
+virSkipSpacesAndBackslash;
 virStrToDouble;
 virStrToLong_i;
 virStrToLong_l;
index 0472e3944f6e4441ae7b71d0bb1848446c82e5f1..c0d8f57ec0dd477167e2620f3dca606e745c693e 100644 (file)
@@ -1532,16 +1532,31 @@ virHexToBin(unsigned char c)
  * @str: pointer to the char pointer used
  *
  * Skip potential blanks, this includes space tabs, line feed,
- * carriage returns and also '\\' which can be erronously emitted
- * by xend
+ * carriage returns.
  */
 void
 virSkipSpaces(const char **str)
 {
     const char *cur = *str;
 
-    while ((*cur == ' ') || (*cur == '\t') || (*cur == '\n') ||
-           (*cur == '\r') || (*cur == '\\'))
+    while (c_isspace(*cur))
+        cur++;
+    *str = cur;
+}
+
+/**
+ * virSkipSpacesAndBackslash:
+ * @str: pointer to the char pointer used
+ *
+ * Like virSkipSpaces, but also skip backslashes erroneously emitted
+ * by xend
+ */
+void
+virSkipSpacesAndBackslash(const char **str)
+{
+    const char *cur = *str;
+
+    while (c_isspace(*cur) || *cur == '\\')
         cur++;
     *str = cur;
 }
index 155565364f2e6a2020441d3b72973cd5fad42229..ccc32fed686d9373a16e802725e4bf95a7016ea7 100644 (file)
@@ -167,6 +167,7 @@ int virHexToBin(unsigned char c);
 int virMacAddrCompare (const char *mac1, const char *mac2);
 
 void virSkipSpaces(const char **str);
+void virSkipSpacesAndBackslash(const char **str);
 int virParseNumber(const char **str);
 int virParseVersionString(const char *str, unsigned long *version,
                           bool allowMissing);
index d41884755a8dfc002a2c76f572b5bc7415d0303d..d0eb32a02d2d28094da4a6c5737c447d2c2a07d2 100644 (file)
@@ -1199,11 +1199,11 @@ sexpr_to_xend_topology(const struct sexpr *root,
         cell = virParseNumber(&cur);
         if (cell < 0)
             goto parse_error;
-        virSkipSpaces(&cur);
+        virSkipSpacesAndBackslash(&cur);
         if (*cur != ':')
             goto parse_error;
         cur++;
-        virSkipSpaces(&cur);
+        virSkipSpacesAndBackslash(&cur);
         if (STRPREFIX(cur, "no cpus")) {
             nb_cpus = 0;
             for (cpu = 0; cpu < numCpus; cpu++)