From 007b4d0b9ad44dd5c65594dc1b681b7f4024b38c Mon Sep 17 00:00:00 2001 From: Chris White Date: Sat, 29 Oct 2022 21:38:50 -0400 Subject: [PATCH] Add tests of #, \#, \; in values - Hash in value is part of the value, not a comment - Backslashes before hashes or semicolons are part of the value as well, not an escaping mechanism. https://github.com/editorconfig/specification/pull/31#issuecomment-1272393572 --- parser/CMakeLists.txt | 11 ++++++++--- parser/comments.in | 10 ++++++---- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/parser/CMakeLists.txt b/parser/CMakeLists.txt index 6a3de76..aaa266d 100644 --- a/parser/CMakeLists.txt +++ b/parser/CMakeLists.txt @@ -108,9 +108,14 @@ new_ec_test(comment_before_props comments.in test3.c new_ec_test_multiline(comment_between_props_ML comments.in test4.c "key1=value1[ \t]*[\n\r]+key2=value2[ \t\n\r]*") -# test semicolons at end of property value are included in value -new_ec_test(semicolon_in_property comments.in test5.c - "^key=value; not comment[ \t\n\r]*$") +# test semicolons and hashes at end of property value are included in value +new_ec_test(semicolon_or_hash_in_property comments.in test5.c + "^key1=value; not comment[\n\r]+key2=value # not comment[ \t\n\r]*$") + +# test that backslashes before semicolons and hashes in property values +# are included in value +new_ec_test(backslashed_semicolon_or_hash_in_property comments.in test5.c + "^key1=value \\; not comment[\n\r]+key2=value \\# not comment[ \t\n\r]*$") # test escaped semicolons are included in section names new_ec_test(escaped_semicolon_in_section comments.in "test;.c" diff --git a/parser/comments.in b/parser/comments.in index d3c37cf..3cd7d8d 100644 --- a/parser/comments.in +++ b/parser/comments.in @@ -17,13 +17,15 @@ key1=value1 ; Comment between properties ignored key2=value2 -; Semicolon at end of value read as part of value +; Semicolon or hash at end of value read as part of value [test5.c] -key=value; not comment +key1=value; not comment +key2=value # not comment -; Escaped semicolon in value +; Backslash before a semicolon or hash is part of the value [test6.c] -key=value \; not comment +key1=value \; not comment +key2=value \# not comment ; Escaped semicolon in section name [test\;.c]