From: Markus Scherer Date: Thu, 15 Dec 2011 00:43:16 +0000 (+0000) Subject: ICU-9008 version of RES_GET_INT(res) for when >> does not sign-extend X-Git-Tag: milestone-59-0-1~4239 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1b9190739f0c1ff25c62a9c234474d59975ec83f;p=icu ICU-9008 version of RES_GET_INT(res) for when >> does not sign-extend X-SVN-Rev: 31119 --- 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)