mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 12:35:17 +00:00
util: define IS_BLANK instead of using c_isblank from gnulib
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>
This commit is contained in:
parent
1a2934d61c
commit
243dbf5494
@ -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;
|
||||
|
@ -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");
|
||||
|
Loading…
x
Reference in New Issue
Block a user