aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Williams <andy@andywilliams.me>2017-02-06 23:38:23 +0000
committerAndy Williams <andy@andywilliams.me>2017-02-06 23:40:17 +0000
commit269affe753c4e79b230cf3149235f66e036d560d (patch)
tree7144fcbf6e9dfdf9fb65f94f3f8b4325a953523d
parentecore: make sure we always manipulate a valid timer. (diff)
downloadefl-269affe753c4e79b230cf3149235f66e036d560d.tar.gz
elm_code: syntax fix for comments with an escaped blackslash
-rw-r--r--src/lib/elementary/elm_code_syntax.c4
-rw-r--r--src/tests/elementary/elm_code_test_syntax.c4
2 files changed, 6 insertions, 2 deletions
diff --git a/src/lib/elementary/elm_code_syntax.c b/src/lib/elementary/elm_code_syntax.c
index 804dfb6c94..4f2ed6a0c7 100644
--- a/src/lib/elementary/elm_code_syntax.c
+++ b/src/lib/elementary/elm_code_syntax.c
@@ -215,7 +215,7 @@ elm_code_syntax_parse_line(Elm_Code_Syntax *syntax, Elm_Code_Line *line)
{
unsigned int start = i, end;
- for (i++; i < length && (content[i] != '"' || content[i-1] == '\\'); i++) {}
+ for (i++; i < length && (content[i] != '"' || (content[i-1] == '\\' && content[i-2] != '\\')); i++) {}
end = i;
elm_code_line_token_add(line, start, end, 1, ELM_CODE_TOKEN_TYPE_STRING);
@@ -226,7 +226,7 @@ elm_code_syntax_parse_line(Elm_Code_Syntax *syntax, Elm_Code_Line *line)
{
unsigned int start = i, end;
- for (i++; i < length && (content[i] != '\'' || content[i-1] == '\\'); i++) {}
+ for (i++; i < length && (content[i] != '\'' || (content[i-1] == '\\' && content[i-2] != '\\')); i++) {}
end = i;
elm_code_line_token_add(line, start, end, 1, ELM_CODE_TOKEN_TYPE_STRING);
diff --git a/src/tests/elementary/elm_code_test_syntax.c b/src/tests/elementary/elm_code_test_syntax.c
index 8d088789f9..959034abaa 100644
--- a/src/tests/elementary/elm_code_test_syntax.c
+++ b/src/tests/elementary/elm_code_test_syntax.c
@@ -72,6 +72,7 @@ START_TEST (elm_code_syntax_c)
_append_line(file, " */");
_append_line(file, "int main(int argc, char **argv)");
_append_line(file, "{");
+ _append_line(file, " char c = '\\\\';");
_append_line(file, " // display a welcome greeting");
_append_line(file, " if (argc > 0)");
_append_line(file, " printf(\"Hello, %s!\\n\", argv[0]);");
@@ -90,6 +91,9 @@ START_TEST (elm_code_syntax_c)
_assert_line_token_types(file, 6, 1, (Elm_Code_Token_Type[1]){ELM_CODE_TOKEN_TYPE_BRACE});
_assert_line_token_types(file, 7, 1, (Elm_Code_Token_Type[1]){ELM_CODE_TOKEN_TYPE_COMMENT});
_assert_line_token_types(file, 8, 5, (Elm_Code_Token_Type[5]){ELM_CODE_TOKEN_TYPE_KEYWORD, ELM_CODE_TOKEN_TYPE_BRACE,
+ _assert_line_token_types(file, 10, 4, (Elm_Code_Token_Type[4]){ELM_CODE_TOKEN_TYPE_KEYWORD, ELM_CODE_TOKEN_TYPE_BRACE,
+ ELM_CODE_TOKEN_TYPE_STRING, ELM_CODE_TOKEN_TYPE_BRACE});
+
ELM_CODE_TOKEN_TYPE_BRACE, ELM_CODE_TOKEN_TYPE_NUMBER, ELM_CODE_TOKEN_TYPE_BRACE});
_assert_line_token_types(file, 9, 8, (Elm_Code_Token_Type[8]){ELM_CODE_TOKEN_TYPE_BRACE, ELM_CODE_TOKEN_TYPE_STRING,
ELM_CODE_TOKEN_TYPE_BRACE, ELM_CODE_TOKEN_TYPE_BRACE, ELM_CODE_TOKEN_TYPE_NUMBER, ELM_CODE_TOKEN_TYPE_BRACE,