Mercurial > hg > octave-nkf > gnulib-hg
changeset 17880:18371cbd9692
unictype: avoid undefined left-shift behavior
* lib/unictype/bidi_of.c (uc_bidi_class): Building libunistring with
gcc's -fsanitize=shift and running its tests triggered:
unictype/bidi_of.c:43:60: runtime error: left shift of 40167 by 16 \
places cannot be represented in type 'int'
Cast LHS to 'unsigned int' after integer promotion.
* lib/unictype/categ_of.c (lookup_withtable): Likewise.
* lib/unictype/joininggroup_of.c (uc_joining_group): Likewise.
author | Daiki Ueno <ueno@gnu.org> |
---|---|
date | Sat, 24 Jan 2015 11:11:34 +0900 |
parents | d9dbffaaedc5 |
children | 386b1175b738 |
files | ChangeLog lib/unictype/bidi_of.c lib/unictype/categ_of.c lib/unictype/joininggroup_of.c |
diffstat | 4 files changed, 14 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2015-01-24 Daiki Ueno <ueno@gnu.org> + + unictype: avoid undefined left-shift behavior + * lib/unictype/bidi_of.c (uc_bidi_class): Building libunistring with + gcc's -fsanitize=shift and running its tests triggered: + unictype/bidi_of.c:43:60: runtime error: left shift of 40167 by 16 \ + places cannot be represented in type 'int' + Cast LHS to 'unsigned int' after integer promotion. + * lib/unictype/categ_of.c (lookup_withtable): Likewise. + * lib/unictype/joininggroup_of.c (uc_joining_group): Likewise. + 2015-01-20 Daiki Ueno <ueno@gnu.org> libunistring: bump version of unitypes dependants
--- a/lib/unictype/bidi_of.c +++ b/lib/unictype/bidi_of.c @@ -40,7 +40,7 @@ /* level3 contains 5-bit values, packed into 16-bit words. */ unsigned int lookup3 = ((u_bidi_category.level3[index3>>4] - | (u_bidi_category.level3[(index3>>4)+1] << 16)) + | ((unsigned int) u_bidi_category.level3[(index3>>4)+1] << 16)) >> (index3 % 16)) & 0x1f;
--- a/lib/unictype/categ_of.c +++ b/lib/unictype/categ_of.c @@ -40,7 +40,7 @@ /* level3 contains 5-bit values, packed into 16-bit words. */ unsigned int lookup3 = ((u_category.level3[index3>>4] - | (u_category.level3[(index3>>4)+1] << 16)) + | ((unsigned int) u_category.level3[(index3>>4)+1] << 16)) >> (index3 % 16)) & 0x1f;
--- a/lib/unictype/joininggroup_of.c +++ b/lib/unictype/joininggroup_of.c @@ -40,7 +40,7 @@ /* level3 contains 7-bit values, packed into 16-bit words. */ unsigned int lookup3 = ((u_joining_group.level3[index3>>4] - | (u_joining_group.level3[(index3>>4)+1] << 16)) + | ((unsigned int) u_joining_group.level3[(index3>>4)+1] << 16)) >> (index3 % 16)) & 0x7f;