From 6e4a8f60812a2b5d1f72c2a4bbfd07dcf52fc062 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Wed, 21 Feb 2018 13:13:25 +0000 Subject: [PATCH] enhanced pf_log to print a character without quotes. fixed formatting specifiers in log_char_object() in prim.c --- lib/prim.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/lib/prim.c b/lib/prim.c index c1454da..ba0a8e6 100644 --- a/lib/prim.c +++ b/lib/prim.c @@ -72,21 +72,21 @@ start_over: { if (*ptr == '\0') { - n = hcl_logbfmt (hcl, mask, "%C", *ptr); + n = hcl_logbfmt (hcl, mask, "%jc", *ptr); HCL_ASSERT (hcl, n == 1); rem -= n; ptr += n; goto start_over; } - n = hcl_logbfmt (hcl, mask, "%.*S", rem, ptr); + n = hcl_logbfmt (hcl, mask, "%.*js", rem, ptr); if (n <= -1) break; if (n == 0) { /* to skip the unprinted character. * actually, this check is not needed because of '\0' skipping * at the beginning of the loop */ - n = hcl_logbfmt (hcl, mask, "%C", *ptr); + n = hcl_logbfmt (hcl, mask, "%jc", *ptr); HCL_ASSERT (hcl, n == 1); } rem -= n; @@ -114,6 +114,10 @@ static hcl_pfrc_t pf_log (hcl_t* hcl, hcl_ooi_t nargs) { goto dump_object; } + else if (HCL_OOP_IS_CHAR(msg)) + { + hcl_logbfmt (hcl, mask, "%jc", HCL_OOP_TO_CHAR(msg)); + } else if (HCL_OOP_IS_POINTER(msg)) { if (HCL_OBJ_GET_FLAGS_TYPE(msg) == HCL_OBJ_TYPE_CHAR) @@ -135,8 +139,11 @@ static hcl_pfrc_t pf_log (hcl_t* hcl, hcl_ooi_t nargs) inner = ((hcl_oop_oop_t)msg)->slot[i]; if (i > 0) hcl_logbfmt (hcl, mask, " "); - if (HCL_OOP_IS_POINTER(inner) && - HCL_OBJ_GET_FLAGS_TYPE(inner) == HCL_OBJ_TYPE_CHAR) + if (HCL_OOP_IS_CHAR(inner)) + { + hcl_logbfmt (hcl, mask, "%jc", HCL_OOP_TO_CHAR(inner)); + } + else if (HCL_OOP_IS_POINTER(inner) && HCL_OBJ_GET_FLAGS_TYPE(inner) == HCL_OBJ_TYPE_CHAR) { log_char_object (hcl, mask, (hcl_oop_char_t)inner); } @@ -244,7 +251,7 @@ static hcl_pfrc_t pf_or (hcl_t* hcl, hcl_ooi_t nargs) rv = hcl->_false; for (i = 1; i < nargs; i++) { - arg = HCL_STACK_GETARG(hcl, nargs, i); + arg = HCL_STACK_GETARG(hcl, nargs, i); if (arg == hcl->_true) { rv = hcl->_true;