From 1d6951f22d8082c1b1564a7a9aef438ef7f51e52 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Mon, 28 May 2018 09:49:32 +0000 Subject: [PATCH] fixed MOO_SMOOI_TO_OOP to pacify clang about the warning 'warning: shifting a negative signed value is undefined' --- lib/hcl.h | 4 ++-- lib/utf8.c | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/hcl.h b/lib/hcl.h index ea3dbe9..24b4dd4 100644 --- a/lib/hcl.h +++ b/lib/hcl.h @@ -297,10 +297,10 @@ typedef struct hcl_obj_word_t* hcl_oop_word_t; #define HCL_OOP_IS_SMOOI(oop) (HCL_OOP_GET_TAG_LO(oop) == HCL_OOP_TAG_SMOOI) #define HCL_OOP_IS_SMPTR(oop) (HCL_OOP_GET_TAG_LO(oop) == HCL_OOP_TAG_SMPTR) -#define HCL_SMOOI_TO_OOP(num) ((hcl_oop_t)((((hcl_ooi_t)(num)) << HCL_OOP_TAG_BITS_LO) | HCL_OOP_TAG_SMOOI)) +#define HCL_SMOOI_TO_OOP(num) ((hcl_oop_t)((((hcl_oow_t)(hcl_ooi_t)(num)) << HCL_OOP_TAG_BITS_LO) | HCL_OOP_TAG_SMOOI)) #define HCL_OOP_TO_SMOOI(oop) (((hcl_ooi_t)oop) >> HCL_OOP_TAG_BITS_LO) /* -#define HCL_SMPTR_TO_OOP(num) ((hcl_oop_t)((((hcl_ooi_t)(num)) << HCL_OOP_TAG_BITS_LO) | HCL_OOP_TAG_SMPTR)) +#define HCL_SMPTR_TO_OOP(ptr) ((hcl_oop_t)((((hcl_oow_t)(ptr)) << HCL_OOP_TAG_BITS_LO) | HCL_OOP_TAG_SMPTR)) #define HCL_OOP_TO_SMPTR(oop) (((hcl_ooi_t)oop) >> HCL_OOP_TAG_BITS_LO) */ #define HCL_SMPTR_TO_OOP(ptr) ((hcl_oop_t)(((hcl_oow_t)ptr) | HCL_OOP_TAG_SMPTR)) diff --git a/lib/utf8.c b/lib/utf8.c index 73a2eae..2988833 100644 --- a/lib/utf8.c +++ b/lib/utf8.c @@ -311,9 +311,13 @@ int hcl_ucwidth (hcl_uch_t uc) (uc >= 0xfe10 && uc <= 0xfe19) || /* Vertical forms */ (uc >= 0xfe30 && uc <= 0xfe6f) || /* CJK Compatibility Forms */ (uc >= 0xff00 && uc <= 0xff60) || /* Fullwidth Forms */ - (uc >= 0xffe0 && uc <= 0xffe6) || + (uc >= 0xffe0 && uc <= 0xffe6) + #if (HCL_SIZEOF_UCH_T > 2) + || (uc >= 0x20000 && uc <= 0x2fffd) || - (uc >= 0x30000 && uc <= 0x3fffd)) + (uc >= 0x30000 && uc <= 0x3fffd) + #endif + ) { return 2; }