From 346f3c35f9e9aa4b69b41baa8fd211bfee2d6e08 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Tue, 19 Mar 2019 13:58:40 +0000 Subject: [PATCH] changed PUT_BYTE_IN_HEX() --- lib/logfmtv.h | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/logfmtv.h b/lib/logfmtv.h index 3c8f991..4be05de 100644 --- a/lib/logfmtv.h +++ b/lib/logfmtv.h @@ -90,9 +90,9 @@ } \ } while (0) -#define PUT_BYTE_IN_HEX(byte) do { \ +#define PUT_BYTE_IN_HEX(byte,extra_flags) do { \ hcl_bch_t __xbuf[3]; \ - hcl_byte_to_bcstr (byte, __xbuf, HCL_COUNTOF(__xbuf), (16 | (ch == 'w'? HCL_BYTE_TO_BCSTR_LOWERCASE: 0)), '0'); \ + hcl_byte_to_bcstr ((byte), __xbuf, HCL_COUNTOF(__xbuf), (16 | (extra_flags)), '0'); \ PUT_OOCH(__xbuf[0], 1); \ PUT_OOCH(__xbuf[1], 1); \ } while (0) @@ -747,20 +747,22 @@ static int logfmtv (hcl_t* hcl, const fmtchar_t* fmt, hcl_fmtout_t* data, va_lis else if (!(lm_flag & LF_L) && *usp <= 0xFFFF) { hcl_uint16_t u16 = *usp; + int extra_flags = ((ch) == 'w'? HCL_BYTE_TO_BCSTR_LOWERCASE: 0); PUT_OOCH('\\', 1); PUT_OOCH('u', 1); - PUT_BYTE_IN_HEX((u16 >> 8) & 0xFF); - PUT_BYTE_IN_HEX(u16 & 0xFF); + PUT_BYTE_IN_HEX((u16 >> 8) & 0xFF, extra_flags); + PUT_BYTE_IN_HEX(u16 & 0xFF, extra_flags); } else { hcl_uint32_t u32 = *usp; + int extra_flags = ((ch) == 'w'? HCL_BYTE_TO_BCSTR_LOWERCASE: 0); PUT_OOCH('\\', 1); PUT_OOCH('U', 1); - PUT_BYTE_IN_HEX((u32 >> 24) & 0xFF); - PUT_BYTE_IN_HEX((u32 >> 16) & 0xFF); - PUT_BYTE_IN_HEX((u32 >> 8) & 0xFF); - PUT_BYTE_IN_HEX(u32 & 0xFF); + PUT_BYTE_IN_HEX((u32 >> 24) & 0xFF, extra_flags); + PUT_BYTE_IN_HEX((u32 >> 16) & 0xFF, extra_flags); + PUT_BYTE_IN_HEX((u32 >> 8) & 0xFF, extra_flags); + PUT_BYTE_IN_HEX(u32 & 0xFF, extra_flags); } usp++; }