From 077e9bc46c4dca1d80fa38e4968340d0e4372dc5 Mon Sep 17 00:00:00 2001 From: Daniel Kolesa Date: Wed, 18 Jun 2014 12:59:22 +0100 Subject: [PATCH] eolian: strip leading whitespace from doc comments + trim the resulting buffer --- src/lib/eolian/eo_lexer.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/lib/eolian/eo_lexer.c b/src/lib/eolian/eo_lexer.c index 5bc4fbabcc..86e09435b8 100644 --- a/src/lib/eolian/eo_lexer.c +++ b/src/lib/eolian/eo_lexer.c @@ -83,10 +83,22 @@ static void next_line(Eo_Lexer *ls) eo_lexer_syntax_error(ls, "chunk has too many lines"); } +/* go to next line and strip leading whitespace */ +static void next_line_ws(Eo_Lexer *ls) +{ + next_line(ls); + while (isspace(ls->current) && !strchr("\r\n", ls->current)) + next_char(ls); +} + static void read_long_comment(Eo_Lexer *ls, const char **value) { eina_strbuf_reset(ls->buff); + + if (strchr("\r\n", ls->current)) + next_line_ws(ls); + for (;;) { if (!ls->current) @@ -104,7 +116,7 @@ read_long_comment(Eo_Lexer *ls, const char **value) else if (strchr("\r\n", ls->current)) { eina_strbuf_append_char(ls->buff, '\n'); - next_line(ls); + next_line_ws(ls); } else { @@ -112,6 +124,7 @@ read_long_comment(Eo_Lexer *ls, const char **value) next_char(ls); } } + eina_strbuf_trim(ls->buff); if (value) *value = eina_strbuf_string_get(ls->buff); }