From 81e2cc0578793a4dacacbd80fce3ba29f8781625 Mon Sep 17 00:00:00 2001 From: "hyunghwan.chung" Date: Mon, 28 May 2018 09:48:27 +0000 Subject: [PATCH] fixed MOO_SMOOI_TO_OOP to pacify clang about the warning 'warning: shifting a negative signed value is undefined' --- moo/lib/moo.h | 4 ++-- moo/lib/utf8.c | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/moo/lib/moo.h b/moo/lib/moo.h index 8d481c8..5c10568 100644 --- a/moo/lib/moo.h +++ b/moo/lib/moo.h @@ -240,10 +240,10 @@ typedef enum moo_method_type_t moo_method_type_t; #define MOO_OOP_IS_SMOOI(oop) (MOO_OOP_GET_TAG_LO(oop) == MOO_OOP_TAG_SMOOI) #define MOO_OOP_IS_SMPTR(oop) (MOO_OOP_GET_TAG_LO(oop) == MOO_OOP_TAG_SMPTR) -#define MOO_SMOOI_TO_OOP(num) ((moo_oop_t)((((moo_ooi_t)(num)) << MOO_OOP_TAG_BITS_LO) | MOO_OOP_TAG_SMOOI)) +#define MOO_SMOOI_TO_OOP(num) ((moo_oop_t)((((moo_oow_t)(moo_ooi_t)(num)) << MOO_OOP_TAG_BITS_LO) | MOO_OOP_TAG_SMOOI)) #define MOO_OOP_TO_SMOOI(oop) (((moo_ooi_t)oop) >> MOO_OOP_TAG_BITS_LO) /* -#define MOO_SMPTR_TO_OOP(num) ((moo_oop_t)((((moo_ooi_t)(num)) << MOO_OOP_TAG_BITS_LO) | MOO_OOP_TAG_SMPTR)) +#define MOO_SMPTR_TO_OOP(ptr) ((moo_oop_t)((((moo_oow_t)(ptr)) << MOO_OOP_TAG_BITS_LO) | MOO_OOP_TAG_SMPTR)) #define MOO_OOP_TO_SMPTR(oop) (((moo_ooi_t)oop) >> MOO_OOP_TAG_BITS_LO) */ #define MOO_SMPTR_TO_OOP(ptr) ((moo_oop_t)(((moo_oow_t)ptr) | MOO_OOP_TAG_SMPTR)) diff --git a/moo/lib/utf8.c b/moo/lib/utf8.c index 87c2796..c62a4a4 100644 --- a/moo/lib/utf8.c +++ b/moo/lib/utf8.c @@ -311,9 +311,13 @@ int moo_ucwidth (moo_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 (MOO_SIZEOF_UCH_T > 2) + || (uc >= 0x20000 && uc <= 0x2fffd) || - (uc >= 0x30000 && uc <= 0x3fffd)) + (uc >= 0x30000 && uc <= 0x3fffd) + #endif + ) { return 2; }