]> xenbits.xensource.com Git - libvirt.git/commitdiff
util: define IS_BLANK instead of using c_isblank from gnulib
authorPavel Hrdina <phrdina@redhat.com>
Mon, 18 Nov 2019 14:07:06 +0000 (15:07 +0100)
committerPavel Hrdina <phrdina@redhat.com>
Tue, 10 Dec 2019 12:49:23 +0000 (13:49 +0100)
The same way how we have IS_EOL in two files where we actually need it
defince IS_BLANK so we can drop usage of c_isblank.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
src/util/virconf.c
src/util/virkeyfile.c

index cc88000387c0f5e8dc9379711778da85784440ae..42c847f9992e7c06055fa35865b4431d98b89fe5 100644 (file)
@@ -56,13 +56,14 @@ struct _virConfParserCtxt {
 #define CUR (*ctxt->cur)
 #define NEXT if (ctxt->cur < ctxt->end) ctxt->cur++;
 #define IS_EOL(c) (((c) == '\n') || ((c) == '\r'))
+#define IS_BLANK(c) (((c) == ' ') || ((c) == '\t'))
 
 #define SKIP_BLANKS_AND_EOL \
-  do { while ((ctxt->cur < ctxt->end) && (c_isblank(CUR) || IS_EOL(CUR))) { \
+  do { while ((ctxt->cur < ctxt->end) && (IS_BLANK(CUR) || IS_EOL(CUR))) { \
          if (CUR == '\n') ctxt->line++; \
          ctxt->cur++; } } while (0)
 #define SKIP_BLANKS \
-  do { while ((ctxt->cur < ctxt->end) && (c_isblank(CUR))) \
+  do { while ((ctxt->cur < ctxt->end) && (IS_BLANK(CUR))) \
           ctxt->cur++; } while (0)
 
 VIR_ENUM_IMPL(virConf,
@@ -428,7 +429,7 @@ virConfParseString(virConfParserCtxtPtr ctxt)
         while ((ctxt->cur < ctxt->end) && (!IS_EOL(CUR)))
             NEXT;
         /* Reverse to exclude the trailing blanks from the value */
-        while ((ctxt->cur > base) && (c_isblank(CUR)))
+        while ((ctxt->cur > base) && (IS_BLANK(CUR)))
             ctxt->cur--;
         if (VIR_STRNDUP(ret, base, ctxt->cur - base) < 0)
             return NULL;
index dc7a558c6f759ed46ff09361ffdb5ce695270edc..705a193910e6709f29578d0cc13d52cf9977e5ec 100644 (file)
@@ -77,6 +77,7 @@ struct _virKeyFileParserCtxt {
 
 #define IS_EOF (ctxt->cur >= ctxt->end)
 #define IS_EOL(c) (((c) == '\n') || ((c) == '\r'))
+#define IS_BLANK(c) (((c) == ' ') || ((c) == '\t'))
 #define CUR (*ctxt->cur)
 #define NEXT if (!IS_EOF) ctxt->cur++;
 
@@ -205,7 +206,7 @@ static int virKeyFileParseComment(virKeyFileParserCtxtPtr ctxt)
 
 static int virKeyFileParseBlank(virKeyFileParserCtxtPtr ctxt)
 {
-    while ((ctxt->cur < ctxt->end) && c_isblank(CUR))
+    while ((ctxt->cur < ctxt->end) && IS_BLANK(CUR))
         ctxt->cur++;
 
     if (!((ctxt->cur == ctxt->end) || IS_EOL(CUR))) {
@@ -226,7 +227,7 @@ static int virKeyFileParseStatement(virKeyFileParserCtxtPtr ctxt)
         ret = virKeyFileParseValue(ctxt);
     } else if (CUR == '#' || CUR == ';') {
         ret = virKeyFileParseComment(ctxt);
-    } else if (c_isblank(CUR) || IS_EOL(CUR)) {
+    } else if (IS_BLANK(CUR) || IS_EOL(CUR)) {
         ret = virKeyFileParseBlank(ctxt);
     } else {
         virKeyFileError(ctxt, VIR_ERR_CONF_SYNTAX, "unexpected statement");