Commit 86102a4d authored by Alessandro Rubini's avatar Alessandro Rubini

lib/conf: make comments extend up to end-of-line

comments used to extend to the next terminator (including the
semicolon), but editors paint comment-color the whole line, so we'd
better fix it rather than documenting an uncommon behaviour.
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent 2e5f272c
...@@ -324,7 +324,7 @@ static int pp_config_line(struct pp_globals *ppg, char *line, int lineno) ...@@ -324,7 +324,7 @@ static int pp_config_line(struct pp_globals *ppg, char *line, int lineno)
/* now line points to the next word, with no leading blanks */ /* now line points to the next word, with no leading blanks */
if (word[0] == '#') if (word[0] == '#')
return 0; return 1;
if (!*word) { if (!*word) {
/* empty or blank-only /* empty or blank-only
* FIXME: this sets cur_ppi_n to an unvalid value. this means * FIXME: this sets cur_ppi_n to an unvalid value. this means
...@@ -417,7 +417,7 @@ static int pp_config_line(struct pp_globals *ppg, char *line, int lineno) ...@@ -417,7 +417,7 @@ static int pp_config_line(struct pp_globals *ppg, char *line, int lineno)
/* Parse a whole string by splitting lines at '\n' or ';' */ /* Parse a whole string by splitting lines at '\n' or ';' */
static int pp_parse_conf(struct pp_globals *ppg, char *conf, int len) static int pp_parse_conf(struct pp_globals *ppg, char *conf, int len)
{ {
int errcount = 0; int ret, in_comment = 0, errcount = 0;
char *line, *rest, term; char *line, *rest, term;
int lineno = 1; int lineno = 1;
...@@ -432,11 +432,21 @@ static int pp_parse_conf(struct pp_globals *ppg, char *conf, int len) ...@@ -432,11 +432,21 @@ static int pp_parse_conf(struct pp_globals *ppg, char *conf, int len)
; ;
term = *rest; term = *rest;
*rest = '\0'; *rest = '\0';
if (*line) ret = 0;
errcount += pp_config_line(ppg, line, lineno) < 0; if (!in_comment) {
if (*line)
ret = pp_config_line(ppg, line, lineno);
if (ret == 1)
in_comment = 1;
if (ret < 0)
errcount++;
}
line = rest + 1; line = rest + 1;
if (term == '\n') if (term == '\n') {
lineno++; lineno++;
in_comment = 0;
}
} while (term); /* if terminator was already 0, we are done */ } while (term); /* if terminator was already 0, we are done */
return errcount ? -1 : 0; return errcount ? -1 : 0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment