From 184d8e09b60031b8e05babc2ab3b73a05f2d5493 Mon Sep 17 00:00:00 2001 From: Alexander Kuleshov Date: Wed, 18 Nov 2015 17:36:57 +0100 Subject: [PATCH] conform: convert complex fields with empty values in a consistent way (https://github.com/xerions/conform/issues/6) --- src/conf_parse.erl | 9 ++++++++- src/conf_parse.peg | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/conf_parse.erl b/src/conf_parse.erl index 66b5867..e9eed47 100644 --- a/src/conf_parse.erl +++ b/src/conf_parse.erl @@ -137,7 +137,14 @@ parse(Input) when is_binary(Input) -> Bin -> Len = erlang:byte_size(Bin), Unquoted = erlang:binary_part(Bin, {1, Len - 2}), - binary_to_list(Unquoted) + case Bin of + <<"\"\"">> -> + <<>>; + <<"\'\'">> -> + ""; + _ -> + binary_to_list(Unquoted) + end end end). diff --git a/src/conf_parse.peg b/src/conf_parse.peg index 174433d..0c6d622 100644 --- a/src/conf_parse.peg +++ b/src/conf_parse.peg @@ -69,7 +69,14 @@ string_value <- (!((ws* crlf) / comment) '"' (!'"' ("\\\\" / '\\"' / .))* ("\r"? Bin -> Len = erlang:byte_size(Bin), Unquoted = erlang:binary_part(Bin, {1, Len - 2}), - binary_to_list(Unquoted) + case Bin of + <<"\"\"">> -> + <<>>; + <<"\'\'">> -> + ""; + _ -> + binary_to_list(Unquoted) + end end %};