1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-12 13:18:31 +03:00

Identifiers may now start with digits etc.

This commit is contained in:
Alasdair Kergon 2003-02-03 20:08:45 +00:00
parent 544a53a42b
commit e2884dcdb7

View File

@ -50,7 +50,7 @@ struct cs {
char *filename; char *filename;
}; };
static void _get_token(struct parser *p); static void _get_token(struct parser *p, int tok_prev);
static void _eat_space(struct parser *p); static void _eat_space(struct parser *p);
static struct config_node *_file(struct parser *p); static struct config_node *_file(struct parser *p);
static struct config_node *_section(struct parser *p); static struct config_node *_section(struct parser *p);
@ -175,7 +175,7 @@ int read_config_fd(struct config_tree *cf, int fd, const char *file,
/* parse */ /* parse */
p->tb = p->te = p->fb; p->tb = p->te = p->fb;
p->line = 1; p->line = 1;
_get_token(p); _get_token(p, TOK_SECTION_E);
if (!(cf->root = _file(p))) { if (!(cf->root = _file(p))) {
stack; stack;
goto out; goto out;
@ -536,15 +536,17 @@ static int _match_aux(struct parser *p, int t)
if (p->t != t) if (p->t != t)
return 0; return 0;
_get_token(p); _get_token(p, t);
return 1; return 1;
} }
/* /*
* tokeniser * tokeniser
*/ */
static void _get_token(struct parser *p) static void _get_token(struct parser *p, int tok_prev)
{ {
int values_allowed = 0;
p->tb = p->te; p->tb = p->te;
_eat_space(p); _eat_space(p);
if (p->tb == p->fe || !*p->tb) { if (p->tb == p->fe || !*p->tb) {
@ -552,6 +554,11 @@ static void _get_token(struct parser *p)
return; return;
} }
/* Should next token be interpreted as value instead of identifier? */
if (tok_prev == TOK_EQ || tok_prev == TOK_ARRAY_B ||
tok_prev == TOK_COMMA)
values_allowed = 1;
p->t = TOK_INT; /* fudge so the fall through for p->t = TOK_INT; /* fudge so the fall through for
floats works */ floats works */
switch (*p->te) { switch (*p->te) {
@ -621,17 +628,19 @@ static void _get_token(struct parser *p)
case '7': case '7':
case '8': case '8':
case '9': case '9':
p->te++; if (values_allowed) {
while ((p->te != p->fe) && (*p->te)) {
if (*p->te == '.') {
if (p->t == TOK_FLOAT)
break;
p->t = TOK_FLOAT;
} else if (!isdigit((int) *p->te))
break;
p->te++; p->te++;
while ((p->te != p->fe) && (*p->te)) {
if (*p->te == '.') {
if (p->t == TOK_FLOAT)
break;
p->t = TOK_FLOAT;
} else if (!isdigit((int) *p->te))
break;
p->te++;
}
break;
} }
break;
default: default:
p->t = TOK_IDENTIFIER; p->t = TOK_IDENTIFIER;