mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
o Added new value type CFG_EMPTY_ARRAY, to indicate '[]', useful since we use
the arrays to hold a symbolic set of flags.
This commit is contained in:
parent
ffa879d092
commit
07bb413a8f
@ -177,6 +177,13 @@ static void _write_value(FILE * fp, struct config_value *v)
|
||||
case CFG_INT:
|
||||
fprintf(fp, "%d", v->v.i);
|
||||
break;
|
||||
|
||||
case CFG_EMPTY_ARRAY:
|
||||
fprintf(fp, "[]");
|
||||
break;
|
||||
|
||||
default:
|
||||
log_err("Unknown value type");
|
||||
}
|
||||
}
|
||||
|
||||
@ -325,6 +332,16 @@ static struct config_value *_value(struct parser *p)
|
||||
match(TOK_COMMA);
|
||||
}
|
||||
match(TOK_ARRAY_E);
|
||||
|
||||
/*
|
||||
* Special case an empty array.
|
||||
*/
|
||||
if (!h) {
|
||||
if (!(h = _create_value(p)))
|
||||
return NULL;
|
||||
|
||||
h->type = CFG_EMPTY_ARRAY;
|
||||
}
|
||||
} else
|
||||
h = _type(p);
|
||||
|
||||
@ -335,6 +352,8 @@ static struct config_value *_type(struct parser *p)
|
||||
{
|
||||
/* [0-9]+ | [0-9]*\.[0-9]* | ".*" */
|
||||
struct config_value *v = _create_value(p);
|
||||
if (!v)
|
||||
return NULL;
|
||||
|
||||
switch (p->t) {
|
||||
case TOK_INT:
|
||||
|
@ -13,6 +13,7 @@ enum {
|
||||
CFG_STRING,
|
||||
CFG_FLOAT,
|
||||
CFG_INT,
|
||||
CFG_EMPTY_ARRAY
|
||||
};
|
||||
|
||||
struct config_value {
|
||||
|
Loading…
Reference in New Issue
Block a user