diff options
author | Theodore Ts'o <tytso@mit.edu> | 2006-01-06 15:04:39 -0500 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2006-01-06 15:04:39 -0500 |
commit | 22fe674da4bdec2ff1c1abb7ad074df3a641377b (patch) | |
tree | 7e4623472fea6c59c15d91fe751e1d47712e7e9d | |
parent | 7d922f8bcba93f7d830825cb2e07b3eaee99b994 (diff) | |
download | e2fsprogs-22fe674da4bdec2ff1c1abb7ad074df3a641377b.tar.gz |
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>
-rw-r--r-- | e2fsck/ChangeLog | 7 | ||||
-rw-r--r-- | e2fsck/profile.c | 58 |
2 files changed, 46 insertions, 19 deletions
diff --git a/e2fsck/ChangeLog b/e2fsck/ChangeLog index 24e03de2..b713f4bb 100644 --- a/e2fsck/ChangeLog +++ b/e2fsck/ChangeLog @@ -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> * profile.c (profile_init): If a directory is passed to diff --git a/e2fsck/profile.c b/e2fsck/profile.c index 57623e52..89a8d237 100644 --- a/e2fsck/profile.c +++ b/e2fsck/profile.c @@ -595,10 +595,20 @@ static errcode_t parse_std_line(char *line, struct parse_state *state) if (state->group_level > 0) return PROF_SECTION_NOTOP; cp++; + cp = skip_over_blanks(cp); p = strchr(cp, ']'); if (p == NULL) 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, &iter, &state->current_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) return PROF_RELATION_SYNTAX; *cp = '\0'; - /* Look for whitespace on left-hand side. */ - p = skip_over_nonblanks(tag); - if (*p) - *p++ = 0; - p = skip_over_blanks(p); - /* If we have more non-whitespace, it's an error. */ - if (*p) - return PROF_RELATION_SYNTAX; + if (*tag == '"') { + tag++; + parse_quoted_string(tag); + } else { + /* Look for whitespace on left-hand side. */ + p = skip_over_nonblanks(tag); + if (*p) + *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); value = cp; @@ -828,17 +843,16 @@ static void dump_profile(struct profile_node *root, int level, break; for (i=0; i < level; i++) 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(" = ", data); + cb(" = ", data); + if (need_double_quotes(p->value)) output_quoted_string(p->value, cb, data); - cb(EOL, data); - } else { - cb(p->name, data); - cb(" = ", data); + else cb(p->value, data); - cb(EOL, data); - } + cb(EOL, data); } while (iter != 0); iter = 0; @@ -848,7 +862,10 @@ static void dump_profile(struct profile_node *root, int level, break; if (level == 0) { /* [xxx] */ 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(p->final ? "*" : "", data); cb(EOL, data); @@ -857,7 +874,10 @@ static void dump_profile(struct profile_node *root, int level, } else { /* xxx = { ... } */ for (i=0; i < level; i++) 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(EOL, data); dump_profile(p, level+1, cb, data); |