diff --git a/src/post_modules/Unicode/normalize.c b/src/post_modules/Unicode/normalize.c index 6c6e7db3451f874d5b5fd39e1d9ff63bba0b5cb9..3140773528c08046cd071166bf8bb650ff85fa6f 100644 --- a/src/post_modules/Unicode/normalize.c +++ b/src/post_modules/Unicode/normalize.c @@ -86,21 +86,21 @@ static void init_hashes() for( i = 0; i<sizeof(_d)/sizeof(_d[0]); i++ ) { - int h = _d[i].c%HSIZE; + unsigned int h = (unsigned int)_d[i].c%HSIZE; decomp_h[i].v = _d+i; decomp_h[i].next = decomp_hash[h]; decomp_hash[h] = decomp_h+i; } for( i = 0; i<sizeof(_c)/sizeof(_c[0]); i++ ) { - int h = ((_c[i].c1<<16)|_c[i].c2)%HSIZE; + unsigned int h = (((unsigned int)_c[i].c1<<16)|_c[i].c2)%HSIZE; comp_h[i].v = _c+i; comp_h[i].next = comp_hash[h]; comp_hash[h] = comp_h+i; } for( i = 0; i<sizeof(_ca)/sizeof(_ca[0]); i++ ) { - int h = _ca[i].c % HSIZE; + unsigned int h = (unsigned int)_ca[i].c % HSIZE; canonic_h[i].v = _ca+i; canonic_h[i].next = canonic_hash[h]; canonic_hash[h] = canonic_h+i; @@ -115,7 +115,7 @@ void unicode_normalize_init() const struct decomp *get_decomposition( int c ) { - int hv = c % HSIZE; + unsigned int hv = (unsigned int)c % HSIZE; const struct decomp_h *r = decomp_hash[hv]; while( r ) { @@ -128,7 +128,7 @@ const struct decomp *get_decomposition( int c ) int get_canonical_class( int c ) { - int hv = c % HSIZE; + unsigned int hv = (unsigned int)c % HSIZE; const struct canonic_h *r = canonic_hash[hv]; while( r ) { @@ -152,6 +152,8 @@ int get_canonical_class( int c ) int get_compose_pair( int c1, int c2 ) { const struct comp_h *r; + unsigned int hv; + if( c1 >= LBase ) { /* Perhaps hangul */ @@ -176,8 +178,10 @@ int get_compose_pair( int c1, int c2 ) } } + hv = (unsigned int)c1 << 16 | (unsigned int)c2; /* Nope. Not hangul. */ - for( r=comp_hash[ ((unsigned int)((c1<<16) | (c2))) % HSIZE ]; r; r=r->next ) + for( r=comp_hash[ hv % HSIZE ]; + r; r=r->next ) if( (r->v->c1 == c1) && (r->v->c2 == c2) ) return r->v->c;