Mercurial > hg > octave-kai > gnulib-hg
view lib/uninorm/composition.c @ 11224:5aa57cee93aa
avoid gcc 3.4.3 bug on long double NaN on Irix 6.5
* tests/nan.h (NaNl): Rewrite as function on Irix, to avoid
compilation bug by using runtime conversion.
* m4/isfinite.m4 (gl_ISFINITE): Likewise.
* m4/isnanl.m4 (gl_FUNC_ISNANL): Likewise.
* modules/ceill-tests (Files): Use nan.h.
* modules/floorl-tests (Files): Likewise.
* modules/frexpl-tests (Files): Likewise.
* modules/isnanl-tests (Files): Likewise.
* modules/ldexpl-tests (Files): Likewise.
* modules/roundl-tests (Files): Likewise.
* modules/truncl-tests (Files): Likewise.
* tests/test-ceill.c (main): Use a working NaN.
* tests/test-floorl.c (main): Likewise.
* tests/test-frexpl.c (main): Likewise.
* tests/test-isnan.c (test_long_double): Likewise.
* tests/test-isnanl.h (main): Likewise.
* tests/test-ldexpl.h (main): Likewise.
* tests/test-roundl.h (main): Likewise.
* tests/test-truncl.h (main): Likewise.
See http://lists.gnu.org/archive/html/bug-gnulib/2009-02/msg00190.html.
Signed-off-by: Eric Blake <ebb9@byu.net>
author | Eric Blake <ebb9@byu.net> |
---|---|
date | Thu, 26 Feb 2009 20:18:42 -0700 (2009-02-27) |
parents | 0849684e41dd |
children | 16e511eaf7d5 |
line wrap: on
line source
/* Canonical composition of Unicode characters. Copyright (C) 2002, 2006, 2009 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2009. This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> /* Specification. */ #include "uninorm.h" #include <string.h> struct composition_rule { char codes[4]; unsigned short combined; }; #include "composition-table.h" ucs4_t uc_composition (ucs4_t uc1, ucs4_t uc2) { if (uc1 < 0x10000 && uc2 < 0x10000) { if (uc2 >= 0x1161 && uc2 < 0x1161 + 21 && uc1 >= 0x1100 && uc1 < 0x1100 + 19) { /* Hangul: Combine single letter L and single letter V to form two-letter syllable LV. */ return 0xAC00 + ((uc1 - 0x1100) * 21 + (uc2 - 0x1161)) * 28; } else if (uc2 > 0x11A7 && uc2 < 0x11A7 + 28 && uc1 >= 0xAC00 && uc1 < 0xD7A4 && ((uc1 - 0xAC00) % 28) == 0) { /* Hangul: Combine two-letter syllable LV with single-letter T to form three-letter syllable LVT. */ return uc1 + (uc2 - 0x11A7); } else { #if 0 unsigned int uc = MUL1 * uc1 * MUL2 * uc2; unsigned int index1 = uc >> composition_header_0; if (index1 < composition_header_1) { int lookup1 = u_composition.level1[index1]; if (lookup1 >= 0) { unsigned int index2 = (uc >> composition_header_2) & composition_header_3; int lookup2 = u_composition.level2[lookup1 + index2]; if (lookup2 >= 0) { unsigned int index3 = (uc & composition_header_4); unsigned int lookup3 = u_composition.level3[lookup2 + index3]; if ((lookup3 >> 16) == uc2) return lookup3 & ((1U << 16) - 1); } } } #else char codes[4]; const struct composition_rule *rule; codes[0] = (uc1 >> 8) & 0xff; codes[1] = uc1 & 0xff; codes[2] = (uc2 >> 8) & 0xff; codes[3] = uc2 & 0xff; rule = gl_uninorm_compose_lookup (codes, 4); if (rule != NULL) return rule->combined; #endif } } return 0; }