mirror of https://github.com/vitalif/e2fsprogs
Add support for quoted strings in tag and section names
Also changed top-level section name parsing to ignore leading and trailing whitespace. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>bitmap-optimize
parent
7d922f8bcb
commit
22fe674da4
|
@ -1,3 +1,10 @@
|
||||||
|
2006-01-06 Theodore Ts'o <tytso@mit.edu>
|
||||||
|
|
||||||
|
* profile.c (parse_std_line, dump_profile): Add support for
|
||||||
|
quoted strings in tag and section names. Changed
|
||||||
|
top-level section name parsing to ignore leading and
|
||||||
|
trailing whitespace.
|
||||||
|
|
||||||
2006-01-05 Theodore Ts'o <tytso@mit.edu>
|
2006-01-05 Theodore Ts'o <tytso@mit.edu>
|
||||||
|
|
||||||
* profile.c (profile_init): If a directory is passed to
|
* profile.c (profile_init): If a directory is passed to
|
||||||
|
|
|
@ -595,10 +595,20 @@ static errcode_t parse_std_line(char *line, struct parse_state *state)
|
||||||
if (state->group_level > 0)
|
if (state->group_level > 0)
|
||||||
return PROF_SECTION_NOTOP;
|
return PROF_SECTION_NOTOP;
|
||||||
cp++;
|
cp++;
|
||||||
|
cp = skip_over_blanks(cp);
|
||||||
p = strchr(cp, ']');
|
p = strchr(cp, ']');
|
||||||
if (p == NULL)
|
if (p == NULL)
|
||||||
return PROF_SECTION_SYNTAX;
|
return PROF_SECTION_SYNTAX;
|
||||||
*p = '\0';
|
if (*cp == '"') {
|
||||||
|
cp++;
|
||||||
|
parse_quoted_string(cp);
|
||||||
|
} else {
|
||||||
|
*p-- = '\0';
|
||||||
|
while (isspace(*p) && (p > cp))
|
||||||
|
*p-- = '\0';
|
||||||
|
if (*cp == 0)
|
||||||
|
return PROF_SECTION_SYNTAX;
|
||||||
|
}
|
||||||
retval = profile_find_node(state->root_section, cp, 0, 1,
|
retval = profile_find_node(state->root_section, cp, 0, 1,
|
||||||
&iter, &state->current_section);
|
&iter, &state->current_section);
|
||||||
if (retval == PROF_NO_SECTION) {
|
if (retval == PROF_NO_SECTION) {
|
||||||
|
@ -645,14 +655,19 @@ static errcode_t parse_std_line(char *line, struct parse_state *state)
|
||||||
if (cp == tag)
|
if (cp == tag)
|
||||||
return PROF_RELATION_SYNTAX;
|
return PROF_RELATION_SYNTAX;
|
||||||
*cp = '\0';
|
*cp = '\0';
|
||||||
/* Look for whitespace on left-hand side. */
|
if (*tag == '"') {
|
||||||
p = skip_over_nonblanks(tag);
|
tag++;
|
||||||
if (*p)
|
parse_quoted_string(tag);
|
||||||
*p++ = 0;
|
} else {
|
||||||
p = skip_over_blanks(p);
|
/* Look for whitespace on left-hand side. */
|
||||||
/* If we have more non-whitespace, it's an error. */
|
p = skip_over_nonblanks(tag);
|
||||||
if (*p)
|
if (*p)
|
||||||
return PROF_RELATION_SYNTAX;
|
*p++ = 0;
|
||||||
|
p = skip_over_blanks(p);
|
||||||
|
/* If we have more non-whitespace, it's an error. */
|
||||||
|
if (*p)
|
||||||
|
return PROF_RELATION_SYNTAX;
|
||||||
|
}
|
||||||
|
|
||||||
cp = skip_over_blanks(cp+1);
|
cp = skip_over_blanks(cp+1);
|
||||||
value = cp;
|
value = cp;
|
||||||
|
@ -828,17 +843,16 @@ static void dump_profile(struct profile_node *root, int level,
|
||||||
break;
|
break;
|
||||||
for (i=0; i < level; i++)
|
for (i=0; i < level; i++)
|
||||||
cb("\t", data);
|
cb("\t", data);
|
||||||
if (need_double_quotes(p->value)) {
|
if (need_double_quotes(p->name))
|
||||||
|
output_quoted_string(p->name, cb, data);
|
||||||
|
else
|
||||||
cb(p->name, data);
|
cb(p->name, data);
|
||||||
cb(" = ", data);
|
cb(" = ", data);
|
||||||
|
if (need_double_quotes(p->value))
|
||||||
output_quoted_string(p->value, cb, data);
|
output_quoted_string(p->value, cb, data);
|
||||||
cb(EOL, data);
|
else
|
||||||
} else {
|
|
||||||
cb(p->name, data);
|
|
||||||
cb(" = ", data);
|
|
||||||
cb(p->value, data);
|
cb(p->value, data);
|
||||||
cb(EOL, data);
|
cb(EOL, data);
|
||||||
}
|
|
||||||
} while (iter != 0);
|
} while (iter != 0);
|
||||||
|
|
||||||
iter = 0;
|
iter = 0;
|
||||||
|
@ -848,7 +862,10 @@ static void dump_profile(struct profile_node *root, int level,
|
||||||
break;
|
break;
|
||||||
if (level == 0) { /* [xxx] */
|
if (level == 0) { /* [xxx] */
|
||||||
cb("[", data);
|
cb("[", data);
|
||||||
cb(p->name, data);
|
if (need_double_quotes(p->name))
|
||||||
|
output_quoted_string(p->name, cb, data);
|
||||||
|
else
|
||||||
|
cb(p->name, data);
|
||||||
cb("]", data);
|
cb("]", data);
|
||||||
cb(p->final ? "*" : "", data);
|
cb(p->final ? "*" : "", data);
|
||||||
cb(EOL, data);
|
cb(EOL, data);
|
||||||
|
@ -857,7 +874,10 @@ static void dump_profile(struct profile_node *root, int level,
|
||||||
} else { /* xxx = { ... } */
|
} else { /* xxx = { ... } */
|
||||||
for (i=0; i < level; i++)
|
for (i=0; i < level; i++)
|
||||||
cb("\t", data);
|
cb("\t", data);
|
||||||
cb(p->name, data);
|
if (need_double_quotes(p->name))
|
||||||
|
output_quoted_string(p->name, cb, data);
|
||||||
|
else
|
||||||
|
cb(p->name, data);
|
||||||
cb(" = {", data);
|
cb(" = {", data);
|
||||||
cb(EOL, data);
|
cb(EOL, data);
|
||||||
dump_profile(p, level+1, cb, data);
|
dump_profile(p, level+1, cb, data);
|
||||||
|
|
Loading…
Reference in New Issue