[libvirt] [PATCH 2/6] conf: Convert ParseString to use STRPREFIX

Cole Robinson crobinso at redhat.com
Mon Nov 22 17:28:22 UTC 2010


Signed-off-by: Cole Robinson <crobinso at redhat.com>
---
 src/util/conf.c |   19 +++++++++++--------
 1 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/src/util/conf.c b/src/util/conf.c
index ba1a384..a31bbc4 100644
--- a/src/util/conf.c
+++ b/src/util/conf.c
@@ -394,17 +394,20 @@ virConfParseString(virConfParserCtxtPtr ctxt)
             return NULL;
         }
         NEXT;
-    } else if ((ctxt->cur + 6 < ctxt->end) && (ctxt->cur[0] == '"') &&
-               (ctxt->cur[1] == '"') && (ctxt->cur[2] == '"')) {
+    } else if ((ctxt->cur + 6 < ctxt->end) &&
+               (STRPREFIX(ctxt->cur, "\"\"\""))) {
+        /* String starts with python-style triple quotes """ */
         ctxt->cur += 3;
         base = ctxt->cur;
-        while ((ctxt->cur + 2 < ctxt->end) && (ctxt->cur[0] == '"') &&
-               (ctxt->cur[1] == '"') && (ctxt->cur[2] == '"')) {
-               if (CUR == '\n') ctxt->line++;
-               NEXT;
+
+        while ((ctxt->cur + 2 < ctxt->end) &&
+               (STRPREFIX(ctxt->cur, "\"\"\""))) {
+            if (CUR == '\n')
+                ctxt->line++;
+            NEXT;
         }
-        if ((ctxt->cur[0] != '"') || (ctxt->cur[1] != '"') ||
-            (ctxt->cur[2] != '"')) {
+
+        if (!STRPREFIX(ctxt->cur, "\"\"\"")) {
             virConfError(ctxt, VIR_ERR_CONF_SYNTAX, _("unterminated string"));
             return(NULL);
         }
-- 
1.7.3.2




More information about the libvir-list mailing list