From bf030731fd35101059093bd3e636c9611e3c97fa Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Tue, 24 Apr 2018 05:24:58 +0000 Subject: [PATCH] added '\n' to is_spacechar() --- lib/hcl-c.c | 2 ++ lib/json.c | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/hcl-c.c b/lib/hcl-c.c index c274659..1b2823a 100644 --- a/lib/hcl-c.c +++ b/lib/hcl-c.c @@ -154,6 +154,8 @@ static HCL_INLINE int is_spacechar (hcl_bch_t c) /* TODO: handle other space unicode characters */ switch (c) { + /* [NOTE]: '\n' is special and used as delimiter. so it's not treated + * as a space character */ case ' ': case '\f': /* formfeed */ case '\r': /* carriage return */ diff --git a/lib/json.c b/lib/json.c index f4bddb8..72a3343 100644 --- a/lib/json.c +++ b/lib/json.c @@ -134,6 +134,7 @@ static HCL_INLINE int is_spacechar (hcl_bch_t c) { case ' ': case '\f': /* formfeed */ + case '\n': /* new line */ case '\r': /* carriage return */ case '\t': /* horizon tab */ case '\v': /* vertical tab */ @@ -637,7 +638,7 @@ static int handle_char_in_array (hcl_json_t* json, hcl_ooci_t c) } else { - hcl_json_seterrbfmt (json, HCL_EINVAL, "wrong character inside array - %jc", (hcl_ooch_t)c); + hcl_json_seterrbfmt (json, HCL_EINVAL, "wrong character inside array - %jc[%d]", (hcl_ooch_t)c, (int)c); return -1; } } @@ -732,7 +733,7 @@ static int handle_char_in_dic (hcl_json_t* json, hcl_ooci_t c) } else { - hcl_json_seterrbfmt (json, HCL_EINVAL, "wrong character inside array - %jc", (hcl_ooch_t)c); + hcl_json_seterrbfmt (json, HCL_EINVAL, "wrong character inside dictionary - %jc[%d]", (hcl_ooch_t)c, (int)c); return -1; } }