From 1b9190739f0c1ff25c62a9c234474d59975ec83f Mon Sep 17 00:00:00 2001 From: Markus Scherer Date: Thu, 15 Dec 2011 00:43:16 +0000 Subject: [PATCH] ICU-9008 version of RES_GET_INT(res) for when >> does not sign-extend X-SVN-Rev: 31119 --- icu4c/source/common/uresdata.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/icu4c/source/common/uresdata.h b/icu4c/source/common/uresdata.h index 2bedf00426a..3e63db917d9 100644 --- a/icu4c/source/common/uresdata.h +++ b/icu4c/source/common/uresdata.h @@ -66,7 +66,12 @@ typedef uint32_t Resource; #define RES_GET_POINTER(pRoot, res) ((pRoot)+RES_GET_OFFSET(res)) /* get signed and unsigned integer values directly from the Resource handle */ -#define RES_GET_INT(res) (((int32_t)((res)<<4L))>>4L) +#if U_SIGNED_RIGHT_SHIFT_IS_ARITHMETIC +# define RES_GET_INT(res) (((int32_t)((res)<<4L))>>4L) +#else +# define RES_GET_INT(res) (int32_t)(((res)&0x08000000) ? (res)|0xf0000000 : (res)&0x07ffffff) +#endif + #define RES_GET_UINT(res) ((res)&0x0fffffff) #define URES_IS_ARRAY(type) ((int32_t)(type)==URES_ARRAY || (int32_t)(type)==URES_ARRAY16) -- 2.40.0